prompt-toolkit / prompt-toolkit/python-prompt-toolkit

print does not work as expected

Open
#542 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

In branch 2.0. I run the example of docstring

from __future__ import unicode_literals
from prompt_toolkit import print
from prompt_toolkit.styles import Style

style = Style.from_dict({
    'hello': '#ff0066',
    'world': '#884444 italic',
})
fragments = [
('class:hello', 'Hello'),
('class:world', 'World'),
]
print(fragments, style=style)

output

[('class:hello', 'Hello'), ('class:world', 'World')]

But when I commented the two lines, it work

 66     # Merges values.
 67     def to_text(val):
 68         # if isinstance(val, list):
 69             # return to_formatted_text('{0}'.format(val))
 70         return to_formatted_text(val, auto_convert=True)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided Python docstring example on the 2.0 branch and compare its output with the expected styled Hello World output. Start by examining the shown to_text function and how print processes the fragments; the commented list-handling lines identify the behavior to investigate. Done means the example renders the fragments as styled text without requiring those lines to be commented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.