Change envvar type from list[str] to Sequence[str]#1610
Open
thakoreh wants to merge 4 commits intofastapi:masterfrom
Open
Change envvar type from list[str] to Sequence[str]#1610thakoreh wants to merge 4 commits intofastapi:masterfrom
thakoreh wants to merge 4 commits intofastapi:masterfrom
Conversation
The envvar parameter type annotation used list[str] but should accept any sequence type (tuple, list, etc.). Changed to Sequence[str] which is the abstract interface from collections.abc that Click also accepts. Fixes: fastapi#283
The overload signatures use Sequence[str] but the implementation annotations still used list[str], causing mypy overload checking errors.
Update models.py to use Sequence[str] for envvar parameter to match the type annotations in params.py overloads.
Author
|
I noticed the mypy check is still failing. The issue is that while the PR updated You need to update the # In TyperArgument (around line 263)
envvar: str | Sequence[str] | None = None,
# In TyperOption (around line 410)
envvar: str | Sequence[str] | None = None,The I've created a branch with the fix at https://github.com/thakoreh/typer/tree/pr-1610 if you'd like to reference it. |
Update core.py to use Sequence[str] for envvar to match params.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #283 - envvar type annotation should accept Sequence[str] instead of list[str]
Problem
The parameter type annotation used but Click accepts . This is overly restrictive and doesn't follow Python best practices for type hints.
From the issue:
Solution
Changed to in all 4 occurrences in .
This allows users to pass any sequence type (tuple, list, etc.) for the parameter.
Changes