diff options
author | blag <blag@users.noreply.github.com> | 2023-09-12 12:46:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-12 12:46:34 -0700 |
commit | ed89c154ee2af7edcdacc092fe357e8ceeb30312 (patch) | |
tree | 27ac3fe8e2cd461e76fb6033c4d90408757c8940 | |
parent | 69dcceb5f6d3ecbcc9e7a0a48c9bdabeed470dcd (diff) |
For Python >= 3.11 directly use packaging to compare package versions (#1416)
* For Python >= 3.11 directly use packaging to compare package versions
* Improve prompt-toolkit check to test for feature explicitly
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog.rst | 1 | ||||
-rw-r--r-- | pgcli/pgtoolbar.py | 8 |
3 files changed, 4 insertions, 6 deletions
@@ -127,6 +127,7 @@ Contributors: * Anna Glasgall (annathyst) * Andy Schoenberger (andyscho) * Damien Baty (dbaty) + * blag Creator: -------- diff --git a/changelog.rst b/changelog.rst index 7f73a0ba..f6e99520 100644 --- a/changelog.rst +++ b/changelog.rst @@ -24,6 +24,7 @@ Bug fixes: * Fix 'invalid connection option "dsn"' ([issue 1373](https://github.com/dbcli/pgcli/issues/1373)). * Fix explain mode when used with `expand`, `auto_expand`, or `--explain-vertical-output` ([issue 1393](https://github.com/dbcli/pgcli/issues/1393)). * Fix sql-insert format emits NULL as 'None' ([issue 1408](https://github.com/dbcli/pgcli/issues/1408)). +* Improve check for prompt-toolkit 3.0.6 ([issue 1416](https://github.com/dbcli/pgcli/issues/1416)). 3.5.0 (2022/09/15): =================== diff --git a/pgcli/pgtoolbar.py b/pgcli/pgtoolbar.py index 7b5883e6..4a12ff4e 100644 --- a/pgcli/pgtoolbar.py +++ b/pgcli/pgtoolbar.py @@ -1,18 +1,14 @@ -from pkg_resources import packaging - -import prompt_toolkit from prompt_toolkit.key_binding.vi_state import InputMode from prompt_toolkit.application import get_app -parse_version = packaging.version.parse - vi_modes = { InputMode.INSERT: "I", InputMode.NAVIGATION: "N", InputMode.REPLACE: "R", InputMode.INSERT_MULTIPLE: "M", } -if parse_version(prompt_toolkit.__version__) >= parse_version("3.0.6"): +# REPLACE_SINGLE is available in prompt_toolkit >= 3.0.6 +if "REPLACE_SINGLE" in {e.name for e in InputMode}: vi_modes[InputMode.REPLACE_SINGLE] = "R" |