-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Supports __future__.annotations #7963
Supports __future__.annotations #7963
Conversation
However, tests are lacked. I'm not sure about in which unit-test file should the test be created. @ilevkivskyi |
You can add a new test file, since no existing file seems to be a very good fit. Maybe |
Good idea, I will get it done once I wake up tomorrow |
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.
After thinking about this more, it's unclear how this should work exactly (and if anything needs to change). Let's discuss the desired semantics first in #7907.
_KT = TypeVar('_KT') | ||
_VT = TypeVar('_VT') | ||
|
||
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): |
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.
We try to keep test stubs as small as possible. Basically we only include things that are required by test cases. In this case, it would be sufficient to have a non-overloaded __init__
, since the test case doesn't depend on most of the overload variants.
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.
Agreed. I'll fix it once along with further changes if we have an agreement in #7907
@TH3CHARLie would you like to resurrect this PR? I believe the semantics are better defined now. |
Great, I'll read through the new PEP and update the changes in this PR. |
@TH3CHARLie note that the total set of things being supported is more than just those enumerated in the PEP. |
@ethanhs If I understand correctly, to support PEP585 in mypy, all items listed in gvanrossum/cpython#1 (comment) can now be parameterized, so this PR actually needs to spot such use cases and suppress currently reported errors, right? |
@TH3CHARLie that is essentially correct. I think the best way to think of it is "anything in the stdlib that is Generic in typeshed". That may be easier to implement too. |
I had one initial version now but it's simply enumerating all the cases using a long list so I am interested in you mentioned "anything in the stdlib that is Generic in typeshed". Can this be achieved through some interaction with typeshed so mypy computes the generic list automatically?(I'm actually not pretty familiar with typeshed codebase) |
Sorry for the delay. I carelessly forget to push my initial version but thanks to this I think twice and find my first attempt to suppress more errors than it should. The PR now suppresses errors on generic built-ins, the only nontrivial change(compared to original version before PEP585 is accepted) is to handle |
Is this planned to be released before Python 3.9 release, that will implement PEP 585? |
Thanks for asking! This PR is delayed since we spent a significant amount of time working on compiler kinds of stuff. I'll try to mention this with core developers and move this forward. |
@TH3CHARLie I've read over the PR, but I believe as written it currently only supports |
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.
Thank you for working on this!
Thanks for the review! then I'll rename this PR and merge it. |
This PR partially addresses #7907.