Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optparse: Improve Option typing #13282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hamdanal
Copy link
Contributor

No description provided.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@@ -27,8 +29,8 @@ NO_DEFAULT: tuple[str, ...]
SUPPRESS_HELP: str
SUPPRESS_USAGE: str

def check_builtin(option: Option, opt, value: str): ...
def check_choice(option: Option, opt, value: str) -> str: ...
def check_builtin(option: Option, opt: str, value: str) -> complex: ...
Copy link
Member

Choose a reason for hiding this comment

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

This can return complex, float, or int. I guess that does indeed simplify to complex but I think it's worth adding a comment.

Suggested change
def check_builtin(option: Option, opt: str, value: str) -> complex: ...
# Can return complex, float, or int depending on the option's type
def check_builtin(option: Option, opt: str, value: str) -> complex: ...

choices: list[str] | tuple[str, ...] | None = None,
# TODO: callback, callback_args, callback_kwargs must be all supplied or all omitted. Add overloads.
# Revisit if ParamSpec is ever changed to support non-unpacked args and kwargs.
callback: Callable[..., Incomplete] | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

Should these Incompletes be Any as the correct type cannot currently be represented in the type system?

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.

2 participants