-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use tuple[object, ...]
and dict[str, object]
as upper bounds for ParamSpec.args
and ParamSpec.kwargs
#12668
Merged
Merged
Use tuple[object, ...]
and dict[str, object]
as upper bounds for ParamSpec.args
and ParamSpec.kwargs
#12668
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1c5c612
Use `tuple[Any, ...]` and ``dict[str, Any]` as fallbacks for `ParamSp…
AlexWaygood a8d623e
Fix newly broken tests
AlexWaygood 4616473
Add new test
AlexWaygood b9ddfcb
Make new test pass
AlexWaygood b9b98b9
Add newline at end of file
AlexWaygood 5ff2309
Cleanup the diff a little bit
AlexWaygood e1812ab
Minor style cleanup for the new stub
AlexWaygood 7f372f9
Use `object` instead of `Any`
AlexWaygood 913e903
Merge branch 'paramspec-args-kwargs' of https://github.com/AlexWaygoo…
AlexWaygood 0b71fca
Fix
AlexWaygood e57f9e5
Address review
AlexWaygood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we at least mostly avoid calling back to the type checker in
mypy.types
ormypy.nodes
(even through a callback), and I'd prefer to continue to maintain this principle, as a style issue. Also, it's better if constructors of essentially data objects such as types don't perform any non-trivial logic, such as callingget_fallback
.What about defining a helper function in
mypy.semanal_shared
that takes some of these arguments (named_type_func
etc.) and calculates the fallback?get_fallback
would be removed from here and would part of this helper function. You could name itcalculate_param_spec_fallback
, for example, similar tocalculate_tuple_fallback
that is already defined there.Also, can you add argument types for the callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the code into
semanal_shared
-- although it could actually possibly be moved intotypeanal
, since it seems paramspec args and paramspec kwargs are only ever constructed intypeanal
at the moment. (But perhaps that might change in the future -- what do you think?)Moving the code into
typeanal
would mean that we wouldn't have to use a callback protocol at all, the functions could just callself.named_type()
directly. But the functions might become more tightly coupled with the logic intypeanal.py
.