Skip to content

fix: make Click flag_value defaults work across Click 8.1-8.3#855

Merged
DavidMinarsch merged 1 commit intomainfrom
fix/click-flag-value-default-v2
Mar 9, 2026
Merged

fix: make Click flag_value defaults work across Click 8.1-8.3#855
DavidMinarsch merged 1 commit intomainfrom
fix/click-flag-value-default-v2

Conversation

@DavidMinarsch
Copy link

Proposed changes

Summary

Fix registry_flag() and remote_registry_flag() in click_utils.py to use default=None with functools.wraps normalizing wrappers, so the correct configured default is used regardless of Click version
Apply the same default=None + normalization pattern to update_package_versions.py and add comments to packages.py (which already used this pattern)
Add inline documentation explaining the workaround and when it can be removed (Click lower bound raised to >=8.3)
Context

Click <8.3 ignores default= on flag_value options and uses the last-applied decorator's flag_value instead. Click >=8.3 honours default= but treats booleans literally. Previous fixes (PR fetchai#839 using booleans, PR
fetchai#848 using string defaults) each only worked on one Click version. This fix works across the full supported range (>=8.1.0,<8.4.0).

Test plan

Verified registry_flag and remote_registry_flag tests pass on Click 8.1.0
Verified registry_flag and remote_registry_flag tests pass on Click 8.3.1
Verified aea init flag combinations work correctly on both versions
All linters pass (black, isort, flake8, mypy, pylint)
Hash checks pass

Types of changes

What types of changes does your code introduce to agents-aea?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING doc
  • I am making a pull request against the main branch (left side). Also you should start your branch off our main.
  • Lint and unit tests pass locally with my changes and CI passes too
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that code coverage does not decrease.
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Click <8.3 ignores default= on flag_value options and uses the
last-applied decorator flag_value instead. Click >=8.3 honours
default= but treats booleans literally. Use default=None with
normalizing wrappers in registry_flag/remote_registry_flag to
work across all supported Click versions (>=8.1.0,<8.4.0).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DavidMinarsch DavidMinarsch merged commit 165468d into main Mar 9, 2026
243 of 251 checks passed
@DavidMinarsch DavidMinarsch deleted the fix/click-flag-value-default-v2 branch March 9, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants