Compatibility with click 8.2+ - #132
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates click-repl to work with Click 8.2+ where Context.protected_args is no longer assignable, preventing REPL sessions from crashing with AttributeError.
Changes:
- Add compatibility helpers to read/write protected args across Click versions and use them in REPL dispatch + context resolution.
- Relax Click dependency constraint to allow Click 8.2+ (
<9.0). - Adjust completion-related tests to use explicit command names for stability.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
click_repl/utils.py |
Adds _get_protected_args / _set_protected_args and uses them in _resolve_context. |
click_repl/_repl.py |
Uses the new protected-args helpers to avoid assigning to a read-only property on Click 8.2+. |
setup.cfg |
Updates Click requirement from <8.2.0 to <9.0. |
tests/test_basic.py |
Uses explicit command names in completion tests. |
tests/test_command_collection.py |
Uses explicit command names for command collection completion. |
tests/test_completion/test_common_tests/test_hidden_cmd_and_args.py |
Uses explicit names for hidden commands and nested group name. |
tests/test_completion/test_click_version_le_7/test_arg_completion_v7.py |
Uses explicit name for tuple-type autocompletion command. |
tests/test_completion/test_click_version_ge_8/test_option_completion_v8.py |
Uses explicit command name in option shell-complete test. |
tests/test_completion/test_click_version_ge_8/test_arg_completion_v8.py |
Uses explicit command names and updates the invoked completion strings accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
auvipy
left a comment
There was a problem hiding this comment.
please also check the failing tests in the CI
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Click 8.2 auto-strips _cmd/_command/_group/_grp suffixes from function-derived command names. Pin names with explicit name= parameters so tests work across click versions.
|
Made some more changes for the CI, as well as for future deprecations. I can either split those into different PRs or squash some commits. The main change on top is to provide a proper CI coverage for newest python's and click versions. |
|
=================================== FAILURES ===================================
tests/test_completion/test_click_version_le_7/test_arg_completion_v7.py:25: |
Click 8.2 made Context.protected_args a read-only property, renaming the underlying storage to _protected_args. Add compat helpers that use the private attribute when available, falling back to the public one for older click versions.
Drop Python 3.6/3.7/3.8, add 3.12/3.13/3.14 to match the test matrix.
|
Rebased, should hopefully be resolved. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
auvipy
left a comment
There was a problem hiding this comment.
please cross check the auto suggestions. some might be valid
Removed the click-version matrix dimension in GH Actions as it had no effect on tox's isolated virtualenvs. Add dedicated tox envs that pin click 8.1.8, 8.2.1 and 8.3.1, run on all compatible Python versions. Use basepython = python3 for mypy and flake8 so they work on any local Python. The gh-actions mapping controls the CI version.
click.__version__ is deprecated and will be removed in click 9.1. Use importlib.metadata.version() to determine the major version for the skippable tests.
Fixes #128