Skip to content

Click >= 8.2 upgrade#2219

Merged
Flix6x merged 6 commits into
mainfrom
copilot/fix-issue-1485
Jun 3, 2026
Merged

Click >= 8.2 upgrade#2219
Flix6x merged 6 commits into
mainfrom
copilot/fix-issue-1485

Conversation

Copilot AI commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Click 8.2 introduced deprecated support on options, which collided with FlexMeasures’ custom DeprecatedOption attribute usage and broke multiple CLI commands. This PR removes that collision and lifts the temporary Click version pin.

  • Problem summary

    • CLI commands using DeprecatedOptionsCommand failed with TypeError: argument of type 'bool' is not iterable when running with Click 8.2+.
    • Root cause: custom code stored deprecated aliases on option.deprecated, which now conflicts with Click’s own Option.deprecated boolean/string field.
  • CLI compatibility fix

    • DeprecatedOption now stores deprecated aliases on a dedicated deprecated_options attribute.
    • DeprecatedOptionsCommand now reads deprecated_options when checking whether an invoked flag is deprecated.
    • Existing warning behavior for deprecated aliases is preserved.
    • Fix Python 3.10 MRO issue blocking test collection (see below)
  • Dependency update

    • Updated project constraint from click<8.2.0 to click>=8.2.0.
    • Regenerated uv.lock accordingly.
  • Regression coverage

    • Added focused tests for:
      • parsing a normal option on a command using DeprecatedOptionsCommand
      • parsing a deprecated alias and emitting the deprecation warning
# before: collided with Click's built-in Option.deprecated
self.deprecated = tuple(deprecated_aliases)

# after: dedicated storage for alias matching logic
self.deprecated_options = tuple(deprecated_aliases)

MRO issue

CI test collection on Python 3.10 started failing with TypeError: Cannot create a consistent method resolution order (MRO) for bases ABC, Generic after dependency updates. This PR removes the incompatible inheritance pattern.

  • Root cause addressed: Marshmallow/Click type compatibility on Python 3.10

    • Removed click.ParamType inheritance from MarshmallowClickMixin to avoid ABC/Generic MRO conflicts with marshmallow fields.
    • Added callable support on the mixin (__call__) and a stable __name__ so Click can still consume field instances where it falls back to callable conversion.
    • Kept existing convert() behavior for CLI parameter handling.
  • Field class inheritance cleanup

    • Reordered bases to consistently put MarshmallowClickMixin before marshmallow field classes in affected schema fields:
      • AccountIdField
      • DataSourceIdField
      • UserIdField
    • This keeps marshmallow behavior intact while avoiding problematic type-resolution paths.
  • Click 8.2 compatibility clarity

    • Preserved the DeprecatedOption compatibility approach (deprecated_options instead of deprecated) and added an inline rationale comment for maintainability.
class MarshmallowClickMixin:
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.name = self.__class__.__name__
        self.__name__ = self.name  # for click.FuncParamType fallback

    def convert(self, value, param, ctx, **kwargs):
        return self.deserialize(value, **kwargs)

    def __call__(self, value):
        return self.deserialize(value)

Copilot AI and others added 3 commits June 1, 2026 09:25
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
@Flix6x Flix6x linked an issue Jun 2, 2026 that may be closed by this pull request
@Flix6x Flix6x added dependencies Pull requests that update a dependency file CLI labels Jun 2, 2026
@Flix6x Flix6x added this to the 1.0.0 milestone Jun 2, 2026
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
@socket-security

socket-security Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedclick@​8.1.8 ⏵ 8.4.196100100100100

View full report

Copilot AI and others added 2 commits June 2, 2026 18:28
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI changed the title Make CLI deprecated-option parsing compatible with Click 8.2+ Fix Python 3.10 schema MRO breakage after Click 8.2 upgrade and align changelog entries Jun 2, 2026
Copilot finished work on behalf of Flix6x June 2, 2026 18:32
Copilot AI requested a review from Flix6x June 2, 2026 18:32
@Flix6x
Flix6x marked this pull request as ready for review June 2, 2026 18:58
@Flix6x Flix6x changed the title Fix Python 3.10 schema MRO breakage after Click 8.2 upgrade and align changelog entries Click >= 8.2 upgrade Jun 2, 2026
@Flix6x
Flix6x requested a review from nhoening June 2, 2026 21:15

@nhoening nhoening left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Was there also the option to move to Click's own (new) option.deprecated syntax? Or does that concern something else, actually?

@Flix6x

Flix6x commented Jun 3, 2026

Copy link
Copy Markdown
Member

This PR only avoids the naming conflict rather than rewriting the implementation to use Click’s native mechanism.

Click’s built-in deprecation support is about a whole parameter/option being deprecated, not about selectively deprecating one alias spelling while retaining another alias as first-class and giving a targeted replacement message.

@Flix6x
Flix6x merged commit 778878e into main Jun 3, 2026
12 checks passed
@Flix6x
Flix6x deleted the copilot/fix-issue-1485 branch June 3, 2026 07:03
Flix6x added a commit that referenced this pull request Jul 12, 2026
…2.2+, swallowed CLI validation messages, task page 500) (#2303)

* fix: three long-standing failures on main

- Forecasting with past/future regressors raised a TypeError on pandas 2.2+:
  _slice_closed used the deprecated Series.view("int64") detour and then
  set values into an existing column with .loc[:, col], which validates
  against that column's dtype. Search the datetime64 values directly, and
  replace the column instead of setting into it.
- CLI validation messages were swallowed for every marshmallow-typed option:
  since the click 8.2 upgrade (#2219) removed the click.ParamType base,
  click wraps these fields in FuncParamType, whose convert() reports the
  offending *value* and discards the reason. Raise a click error carrying the
  validation message instead (the ParamType base stays off, to keep the
  Python 3.10 MRO fix intact).
- The task detail page returned a 500 for jobs whose meta data is not
  JSON-serializable, because rq-dashboard serializes meta with a bare
  json.dumps(). Give it a tolerant default (see rq-dashboard#510).

Fixes #2302

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX

* fix: three more long-standing failures on main

- [GET] /api/ops/getLatestTaskRun turned any database error into an opaque
  500: the retry in get_task_run() ran on the still-aborted transaction,
  so it was rejected with InFailedSqlTransaction and the original error was
  never surfaced. Roll back before retrying.
- test_api_task_run_get_recent_entry did not declare the fixture seeding its
  data, so it queried a database without the latest_task_run table at all
  (which is what aborted the transaction above).
- test_build_asset_jobs_data and test_get_job_status_requires_read_access
  asserted on job counts and job identity without flushing the Redis job
  cache, so leftover jobs from earlier tests (which @job_cache also reuses
  for identical requests) made them fail depending on test order. Both now
  use the existing clean_redis fixture.

Fixes #2302

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update click==8.2

3 participants