Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Update prompt-toolkit to 3.0.19 #974

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pyup-bot
Copy link
Contributor

This PR updates prompt-toolkit from 1.0.15 to 3.0.19.

Changelog

3.0.19

------------------

Fixes:
- Make the flush method of the vt100 output implementation re-entrant (fixes an
issue when using aiogevent).
- Fix off-by-one in `FormattedTextControl` mouse logic.
- Run `print_container` always in a thread (avoid interfering with possible
event loop).
- Make sphinx autodoc generation platform agnostic (don't import Windows stuff
when generating Sphinx docs).

3.0.18

------------------

New features:
- Added `in_thread` parameter to `Application.run`.
This is useful for running an application in a background thread, while the
main thread blocks. This way, we are sure not to interfere with an event loop
in the current thread. (This simplifies some code in ptpython and fixes an
issue regarding leaking file descriptors due to not closing the event loop
that was created in this background thread.)

3.0.17

------------------

Fixes:
- Fix leaking file descriptors due to not closing the asyncio event loop after
reading input in a thread.
- Fix race condition during retrieval of signatures.

3.0.16

------------------

(Commit 7f619e was missing in previous release.)

Fixes:
- Several fixes to the completion code:
* Give dictionary completions priority over path completions.
* Always call non-fuzzy completer after fuzzy completer to prevent that some
 completions were missed out if the fuzzy completer doesn't find them.

3.0.15

------------------

New features:
- When pressing control-w, only delete characters until a punctuation.

Fixes:
- Fix `AttributeError` during retrieval of signatures with type annotations.

3.0.14

------------------

New features:
- Display of signature and completion drop down together.
- If `DictionaryCompleter` is enabled, also retrieve signatures when Jedi
fails, using the same logic.
- List function parameters first and private attributes at the end in the
completion menu.
- Cleanup of the completion code.

Fixes:
- Handle exceptions raised when `repr()` is called.
- Fix leakage of `exc_info` from eval to exec call.
- Fix handling of `KeyboardInterrupt` in REPL during evaluation of `__repr__`.
- Fix style for signature toolbar.
- Hide signature when sidebar is visible.

3.0.13

------------------

New features:
- Added 'print all' option to pager.
- Improve handling of indented code:
* Allow multiline input to be indented as a whole (we will unindent before
 executing).
* Correctly visualize tabs (instead of ^I, which happens when pasted in
 bracketed paste).

Fixes:
- Fix line ending bug in pager.

3.0.12

------------------

New features:
- Expose a `get_ptpython` function in the global namespace, to get programmatic
access to the REPL.
- Expose `embed()` at the top level of the package. Make it possible to do
`from ptpython import embed`.

Fixes:
- Properly handle exceptions when trying to access `__pt_repr__`.
- Properly handle `SystemExit`.

3.0.11

------------------

New features:
- Add support for top-level await.
- Refactoring of event loop usage:

* The ptpython input UI will now run in a separate thread. This makes it
 possible to properly embed ptpython in an asyncio application, without
 having to deal with nested event loops (which asyncio does not support).

* The "eval" part doesn't anymore take place within a ptpython coroutine, so
 it can spawn its own loop if needed. This also fixes `asyncio.run()` usage
 in the REPL, which was broken before.

- Added syntax highlighting and autocompletion for !-style system commands.

Fixes:
- Remove unexpected additional line after output.
- Fix system prompt. Accept !-style inputs again.
- Don't execute PYTHONSTARTUP when -i flag was given.

3.0.10

------------------

Fixes:
- Do dictionary completion on Sequence and Mapping objects (from
collections.abc). Note that dictionary completion is still turned off by
default.

3.0.9

-----------------

New features:
- Allow replacing `PythonInput.completer` at runtime (useful for tools build on
top of ptpython).
- Show REPL title in pager.

3.0.8

-----------------

New features:
- Optional output formatting using Black.
- Optional pager for displaying outputs that don't fit on the screen.
- Added --light-bg and --dark-bg flags to automatically optimize the brightness
of the colors according to the terminal background.
- Addd `PTPYTHON_CONFIG_HOME` for explicitely setting the config directory.
- Show completion suffixes (like '(' for functions).

Fixes:
- Fix dictionary completion on Pandas objects.
- Stop using deprecated Jedi functions.

3.0.7

-----------------

New features:
- Option to show/hide private attributes during a completion
- Added `insert_blank_line_after_input` option similar to
`insert_blank_line_after_output`.

Fixes:
- Fixed some formatting issues of `__pt_repr__`.
- Abbreviate completion meta information for dictionary completer if needed.

3.0.6

-----------------

New features:
- (Experimental) support for `__pt_repr__` methods. If objects implement this
method, this will be used to print the result in the REPL instead of the
normal `__repr__`.
- Added py.typed file, to enable type checking for applications that are
embedding ptpython.

3.0.5

-----------------

Fixes:
- Handle bug in dictionary completion when numeric keys are used.

3.0.4

-----------------

New features:
- Allow leading whitespace before single line expressions.
- Show full syntax error in validator.
- Added `vi_start_in_navigation_mode` and `vi_keep_last_used_mode` options.

Fixes:
- Improved dictionary completion: handle keys that contain spaces and don't
recognize numbers as variable names.
- Fix in exit confirmation.

3.0.3

-----------------

Fixes:
- Sort attribute names for `DictionaryCompleter` and move underscored
attributes to the end.
- Handle unhandled exceptions in `get_compiler_flags`.
- Improved `run_async` code.
- Fix --version parameter.

3.0.2

-----------------

New features:
- Improved custom dictionary completion:
 * Also complete list indexes.
 * Also complete attributes after doing a dictionary lookup.
 * Also complete iterators in a for-loop.
- Added a 'title' option, so that applications embedding ptpython can set a
title in the status bar.

3.0.1

-----------------

- Fix backwards-compatibility of the `run_config` function. (used by
django-extensions).
- Fix input mode in status bar for block selection.

3.0.0

-----------------

Upgrade to prompt_toolkit 3.0.
Requires at least Python 3.6.

New features:
- Uses XDG base directory specification.

2.0.9

-----------------

Bug fixes:
- Fixed `Application.run_system_command` on Windows.
- Fixed bug in ANSI text formatting: correctly handle 256/true color sequences.
- Fixed bug in WordCompleter. Provide completions when there's a space before
the cursor.

2.0.8

-----------------

Bug fixes:
- Fixes the issue where changes made to the buffer in the accept handler were
not reflected in the history.
- Fix in the application invalidate handler. This prevents a significat slow
down in some applications after some time (especially if there is a refresh
interval).
- Make `print_container` utility work if the input is not a pty.

New features:
- Underline non breaking spaces instead of rendering as '&'.
- Added mouse support for radio list.
- Support completion styles for `READLINE_LIKE` display method.
- Accept formatted text in the display text of completions.
- Added a `FuzzyCompleter` and `FuzzyWordCompleter`.
- Improved error handling in Application (avoid displaying a meaningless
AssertionError in many cases).

2.0.7

-----------------

Bug fixes:
- Fixed assertion in PromptSession: the style_transformation check was wrong.
- Removed 'default' attribute in PromptSession. Only ask for it in the
`prompt()` method. This fixes the issue that passing `default` once, will
store it for all consequent calls in the `PromptSession`.
- Ensure that `__pt_formatted_text__` always returns a `FormattedText`
instance. This fixes an issue with `print_formatted_text`.

New features:
- Improved handling of situations where stdin or stdout are not a terminal.
(Print warning instead of failing with an assertion.)
- Added `print_container` utility.
- Sound bell when attempting to edit read-only buffer.
- Handle page-down and page-up keys in RadioList.
- Accept any `collections.abc.Sequence` for HSplit/VSplit children (instead of
lists only).
- Improved Vi key bindings: return to navigation mode when Insert is pressed.

2.0.6

-----------------

Bug fixes:
- Don't use the predefined ANSI colors for colors that are defined as RGB.
(Terminals can assign different color schemes for ansi colors, and we don't
want use any of those for colors that are defined like aabbcc for instance.)
- Fix in handling of CPRs when patch_stdout is used.

Backwards incompatible changes:
- Change to the `Buffer` class. Reset the buffer unless the `accept_handler`
returns `True` (which means: "keep_text"). This doesn't affect applications
that use `PromptSession`.

New features:
- Added `AdjustBrightnessStyleTransformation`. This is a simple style
transformation that improves the rendering on terminals with light or dark
background.
- Improved performance (string width caching and line height calculation).
- Improved `TextArea`:
* Exposed `focus_on_click`.
* Added attributes: `auto_suggest`, `complete_while_typing`, `history`,
 `get_line_prefix`, `input_processors`.
* Made attributes writable: `lexer`, `completer`, `complete_while_typing`,
 `accept_handler`, `read_only`, `wrap_lines`.

2.0.5

-----------------

New features:
- Added dictionary completer (off by default).
- Added fuzzy completion (off by default).
- Highlight keywords in completion dropdown menu.
- Enable universal wheels.

Fixes:
- Fixed embedding repl as asyncio coroutine.
- Fixed patching stdout in embedded repl.
- Fixed ResourceWarning in setup.py.

2.0.4

-----------------

- Fixed ptipython.
- Fixed config: setting of color depth.
- Fixed auto-suggest key bindings.
- Fixed Control-D key binding for exiting REPL when (confirm_exit=False).
- Correctly focus/unfocus sidebar.
- Fixed open_in_editor and suspend key bindings.

2.0.3

-----------------

- Allow changing the min/max brightness.
- Some changes for compatibility with the latest prompt_toolkit.

2.0.2

-----------------

Fixes:
- Don't crash the history browser when there was no history.
- Set last exception in the sys module, when an exception was raised.
- Require prompt_toolkit 2.0.5.

2.0.1

-----------------

Upgrade to prompt_toolkit 2.0.x.

2.0

includes the merge of the CommandLineInterface and the Application object, a
rewrite of how user controls are focused, a rewrite of how event loops work
and the removal of the buffers dictionary. This introduces many backwards
incompatible changes, but the result is a very nice and powerful architecture.

Most architectural changes effect full screen applications. For applications
that use `prompt_toolkit.shortcuts` for simple prompts, there are fewer
incompatibilities.

Changes:

- No automatic translation from \r into \n during the input processing. These
are two different keys that can be handled independently. This is a big
backward-incompatibility, because the `Enter` key is `ControlM`, not
`ControlJ`. So, now that we stopped translating \r into \n, it could be that
custom key bindings for `Enter` don't work anymore. Make sure to bind
`Keys.Enter` instead of `Keys.ControlJ` for handling the `Enter` key.

- The `CommandLineInterface` and the `Application` classes are merged. First,
`CommandLineInterface` contained all the I/O objects (like the input, output
and event loop), while the `Application` contained everything else. There was
no practical reason to keep this separation. (`CommandLineInterface` was
mostly a proxy to `Application`.)

A consequence is that almost all code which used to receive a
`CommandLineInterface`, will now use an `Application`. Usually, where we
had an attribute `cli`, we'll now have an attribute `app`.

Secondly, the `Application` object is no longer passed around. The `get_app`
function can be used at any time to acquire the active application.

(For backwards-compatibility, we have aliases to the old names, whenever
possible.)

- prompt_toolkit no longer depends on Pygments, but it can still use Pygments
for its color schemes and lexers. In many places we used Pygments "Tokens",
this has been replaced by the concept of class names, somewhat similar to
HTML and CSS.

* `PygmentsStyle` and `PygmentsLexer` adaptors are available for
  plugging in Pygments styles and lexers.

* Wherever we had a list of `(Token, text)` tuples, we now have lists of
 `(style_string, text)` tuples. The style string can contain both inline
 styling as well as refer to a class from the style sheet. `PygmentsTokens`
 is an adaptor that converts a list of Pygments tokens into a list of
 `(style_string, text)` tuples.

- Changes in the `Style` classes.

* `style.from_dict` does not exist anymore. Instantiate the ``Style`` class
 directory to create a new style. ``Style.from_dict`` can be used to create
 a style from a dictionary, where the dictionary keys are a space separated
 list of class names, and the values, style strings (like before).

* `print_tokens` was renamed to `print_formatted_text`.

* In many places in the layout, we accept a parameter named `style`. All the
 styles from the layout hierarchy are combined to decide what style to be
 used.

* The ANSI color names were confusing and inconsistent with common naming
 conventions. This has been fixed, but aliases for the original names were
 kept.

- The way focusing works is different. Before it was always a `Buffer` that
was focused, and because of that, any visible `BufferControl` that contained
this `Buffer` would be focused. Now, any user control can be focused. All
of this is handled in the `Application.layout` object.

- The `buffers` dictionary (`CommandLineInterface.buffers`) does not exist
anymore. Further, `buffers` was a `BufferMapping` that keeps track of which
buffer has the focus. This significantly reduces the freedom for creating
complex applications. We wanted to move toward a layout that can be defined
as a (hierarchical) collection of user widgets. A user widget does not need
to have a `Buffer` underneath and any widget should be focusable.

* `layout.Layout` was introduced to contain the root layout widget and keep
 track of the focus.

- The key bindings were refactored. It became much more flexible to combine
sets of key bindings.

* `Registry` has been renamed to `KeyBindings`.
* The `add_binding` function has been renamed to simply `add`.
* Every `load_*` function returns one `KeyBindings` objects, instead of
 populating an existing one, like before.
* `ConditionalKeyBindings` was added. This can be used to enable/disable
 all the key bindings from a given `Registry`.
* A function named `merge_key_bindings` was added. This takes a list of
 `KeyBindings` and merges them into one.
* `key_binding.defaults.load_key_bindings` was added to load all the key
 bindings.
* `KeyBindingManager` has been removed completely.
* `input_processor` was renamed to `key_processor`.

Further:

* The `Key` class does not exist anymore. Every key is a string and it's
 considered fine to use string literals in the key bindings. This is more
 readable, but we still have run-time validation. The `Keys` enum still
 exist (for backwards-compatibility, but also to have an overview of which
 keys are supported.)
* 'enter' and 'tab' are key aliases for 'c-m' and 'c-i'.

- User controls can define key bindings, which are active when the user control
is focused.

* `UIControl` got a `get_key_bindings` (abstract) method.

- Changes in the layout engine:

* `LayoutDimension` was renamed to `Dimension`.
* `VSplit` and `HSplit` now take a `padding` argument.
* `VSplit` and `HSplit` now take an `align` argument.
 (TOP/CENTER/BOTTOM/JUSTIFY) or (LEFT/CENTER/RIGHT/JUSTIFY).
* `Float` now takes `allow_cover_cursor` and `attach_to_window` arguments.
* `Window` got an `WindowAlign` argument. This can be used for the alignment
 of the content. `TokenListControl` (renamed to `FormattedTextControl`) does
 not have an alignment argument anymore.
* All container objects, like `Window`, got a `style` argument. The style for
 parent containers propagate to child containers, but can be overriden.
 This is in particular useful for setting a background color.
* `FillControl` does not exist anymore. Use the `style` and `char` arguments
 of the `Window` class instead.
* `DummyControl` was added.
* The continuation function of `PromptMargin` now takes `line_number` and
 `is_soft_wrap` as input.

- Changes to `BufferControl`:

* The `InputProcessor` class has been refactored. The `apply_transformation`
 method should now takes a `TransformationInput` object as input.

* The text `(reverse-i-search)` is now displayed through a processor. (See
 the `shortcuts` module for an example of its usage.)

- `widgets` and `dialogs` modules:

* A small collection of widgets was added. These are more complex collections
 of user controls that are ready to embed in a layout. A `shortcuts.dialogs`
 module was added as a high level API for displaying input, confirmation and
 message dialogs.

* Every class that exposes a ``__pt_container__`` method (which is supposed
 to return a ``Container`` instance) is considered a widget. The
 ``to_container`` shortcut will call this method in situations where a
 ``Container`` object is expected. This avoids inheritance from other
 ``Container`` types, but also having to unpack the container object from
 the widget, in case we would have used composition.

* Warning: The API of the widgets module is not considered stable yet, and
 can change is the future, if needed.

- Changes to `Buffer`:

* A `Buffer` no longer takes an `accept_action`.  Both `AcceptAction` and
 `AbortAction` have been removed. Instead it takes an `accept_handler`.

- Changes regarding auto completion:

* The left and right arrows now work in the multi-column auto completion
 menu.
* By default, autocompletion is synchronous. The completer needs to be
 wrapped in `ThreadedCompleter` in order to get asynchronous autocompletion.
* When the completer runs in a background thread, completions will be
 displayed as soon as they are generated. This means that we don't have to
 wait for all the completions to be generated, before displaying the first
 one. The completion menus are updated as soon as new completions arrive.

- Changes regarding input validation:

* Added the `Validator.from_callable` class method for easy creation of
 new validators.

- Changes regarding the `History` classes:

* The `History` base class has a different interface. This was needed for
 asynchronous loading of the history. `ThreadedHistory` was added for this.

- Changes related to `shortcuts.prompt`:

* There is now a class `PromptSession` which also has a method `prompt`. Both
 the class and the method take about the same arguments. This can be used to
 create a session. Every `prompt` call of the same instance will reuse all
 the arguments given to the class itself.

 The input history is always shared during the entire session.

 Of course, it's still possible to call the global `prompt` function. This
 will create a new `PromptSession` every time when it's called.

* The `prompt` function now takes a `key_bindings` argument instead of
 `key_bindings_registry`. This should only contain the additional bindings.
 (The default bindings are always included.)

- Changes to the event loops:

* The event loop API is now closer to how asyncio works. A prompt_toolkit
 `Application` now has a `Future` object. Calling the `.run_async()` method
 creates and returns that `Future`. An event loop has a `run_until_complete`
 method that takes a future and runs the event loop until the Future is set.

 The idea is to be able to transition easily to asyncio when Python 2
 support can be dropped in the future.

* `Application` still has a method `run()` that underneath still runs the
 event loop until the `Future` is set and returns that result.

* The asyncio adaptors (like the asyncio event loop integration) now require
 Python 3.5. (We use the async/await syntax internally.)

* The `Input` and `Output` classes have some changes. (Not really important.)

* `Application.run_sub_applications` has been removed. The alternative is to
 call `run_coroutine_in_terminal` which returns a `Future`.

- Changes to the `filters` module:

* The `Application` is no longer passed around, so both `CLIFilter` and
 `SimpleFilter` were merged into `Filter`. `to_cli_filter` and
 `to_simple_filter` became `to_filter`.

* All filters have been turned into functions. For instance, `IsDone`
 became `is_done` and `HasCompletions` became `has_completions`.

 This was done because almost all classes were called without any arguments
 in the `__init__` causing additional braces everywhere. This means that
 `HasCompletions()` has to be replaced by `has_completions` (without
 parenthesis).

 The few filters that took arguments as input, became functions, but still
 have to be called with the given arguments.

 For new filters, it is recommended to use the `Condition` decorator,
 rather then inheriting from `Filter`.

- Other renames:

* `IncrementalSearchDirection` was renamed to `SearchDirection`.
* The `use_alternate_screen` parameter has been renamed to `full_screen`.
* `Buffer.initial_document` was renamed to `Buffer.document`.
* `TokenListControl` has been renamed to `FormattedTextControl`.
* `Application.set_return_value` has been renamed to `Application.set_result`.

- Other new features:

* `DummyAutoSuggest` and `DynamicAutoSuggest` were added.
* `DummyClipboard` and `DynamicClipboard` were added.
* `DummyCompleter` and `DynamicCompleter` were added.
* `DummyHistory` and `DynamicHistory` was added.

* `to_container` and `to_window` utilities were added.
Links

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant