Skip to content

ParamType and other typing improvements#3371

Merged
Rowlando13 merged 5 commits intomainfrom
typing/paramtype
Apr 29, 2026
Merged

ParamType and other typing improvements#3371
Rowlando13 merged 5 commits intomainfrom
typing/paramtype

Conversation

@kdeldycke
Copy link
Copy Markdown
Collaborator

@kdeldycke kdeldycke commented Apr 22, 2026

PR to track and study the unmerged changes from @AndreasBackx that were left in the stale typing/paramtype. See the discussion at #3329 for context.

I was able to salvage and rebase on top of stable the majority of the initial changes like:

  • making ParamType a generic ABC and introducing ParamTypeInfoDict
  • adding ParamTypeInfoDict
  • updating FuncParamType to a generic
  • narrowing of convert() return types
  • CompositeParamType generic with abstract arity

Stuff that were made obsolete from PRs merged upstream since the last commit in 2024:

Other stuff that I skipped as too strict:

  • _compat.py t.Any to t.AnyStr
  • File generic with t.AnyStr
  • _is_file_like with t.AnyStr

I also extracted from the original typing/paramtype the refactor of convert_type which is not strictly related to typing improvements and live in its own PR for later evaluation at: #3372

Related to #2805

@kdeldycke kdeldycke marked this pull request as draft April 22, 2026 16:23
@kdeldycke kdeldycke changed the base branch from main to stable April 22, 2026 16:23
Co-authored-by: Kevin Deldycke <kevin@deldycke.com>
@kdeldycke kdeldycke marked this pull request as ready for review April 22, 2026 17:29
@kdeldycke kdeldycke added this to the 8.4.0 milestone Apr 22, 2026
Copy link
Copy Markdown
Collaborator

@AndreasBackx AndreasBackx left a comment

Choose a reason for hiding this comment

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

We should probably update the example in the docs as well: https://click.palletsprojects.com/en/stable/parameter-types/. Maybe also inline the version updates in the docs.

Approving as this is already an improvement and I don't see any regressions from popping up, besides perhaps the tuple type checking?

Comment thread src/click/core.py
Comment thread src/click/types.py Outdated
Comment thread src/click/types.py
Comment thread src/click/types.py Outdated
Comment thread src/click/types.py Outdated
Comment thread src/click/types.py
Comment thread src/click/types.py
kdeldycke added a commit that referenced this pull request Apr 27, 2026
Refs: #3371 (comment)

Co-authored-by: Kevin Deldycke <kevin@deldycke.com>
@kdeldycke
Copy link
Copy Markdown
Collaborator Author

We should probably update the example in the docs as well: https://click.palletsprojects.com/en/stable/parameter-types/. Maybe also inline the version updates in the docs.

Just updated the docs at: ded5b69

@kdeldycke
Copy link
Copy Markdown
Collaborator Author

Thanks @AndreasBackx for reviewing your own code and the approval! 😎 Unless you find some quick win to add, I propose to consider this PR ready for final review/merge.

Again, the main objective here is to clear the backlog of PRs and close global branches like typing/paramtype.

kdeldycke added a commit to kdeldycke/click that referenced this pull request Apr 27, 2026
This is a refactor that was original part of `typing/paramtype` branch but split out of pallets#3371 to keep the latter focused on typing only.

Co-authored-by: Kevin Deldycke <kevin@deldycke.com>
@Rowlando13 Rowlando13 changed the base branch from stable to main April 29, 2026 06:30
@Rowlando13 Rowlando13 merged commit 8a2b489 into main Apr 29, 2026
12 checks passed
@Rowlando13 Rowlando13 deleted the typing/paramtype branch April 29, 2026 06:31
@kdeldycke
Copy link
Copy Markdown
Collaborator Author

Any reason @Rowlando13 that you merged into main and not stable? Anyway, thanks for the merge and removal of typing/paramtype!

@kdeldycke kdeldycke mentioned this pull request Apr 29, 2026
2 tasks
kdeldycke added a commit to kdeldycke/click that referenced this pull request Apr 29, 2026
This is a refactor that was original part of `typing/paramtype` branch but split out of pallets#3371 to keep the latter focused on typing only.

Co-authored-by: Kevin Deldycke <kevin@deldycke.com>
@kdeldycke
Copy link
Copy Markdown
Collaborator Author

Any reason @Rowlando13 that you merged into main and not stable?

Just answered my question based on yesterday's activity: seems like we target main because we stated an 8.x release cycle (8.4.0 in this case), and it seems the tradition is to target stable for 8.3.x/8.4.x kind of releases.

@Rowlando13
Copy link
Copy Markdown
Collaborator

Yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants