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

Improve the self types situation #5676

Closed
JelleZijlstra opened this issue Jun 22, 2021 · 5 comments
Closed

Improve the self types situation #5676

JelleZijlstra opened this issue Jun 22, 2021 · 5 comments

Comments

@JelleZijlstra
Copy link
Member

From micro codery on typing-sig:

It was only after seeing the solution that I could find docs describing it on mypy.readthedocs. There is a note claiming that a generic self is still experimental but maybe a convention should be added to the typeshed contributing guide about using it, just like Sequence is recommended over list.

From @srittau on #5675:

I suggest that in the future we shouldn't accept __enter__() methods returning self anymore that don't use a type var.

I think we should do both of these things. We can find some existing offenders with git grep 'def __enter__(self) -> [A-Z]'.

@srittau
Copy link
Collaborator

srittau commented Jun 22, 2021

We can also add a Self type var to _typeshed:

Self = TypeVar("Self")

This can help us finding places where we should use typing.Self if this proposal is accepted.

@gruebel
Copy link
Contributor

gruebel commented Jul 6, 2021

I think all of the work is done in the stdlib, except for Python 2 types. Do you also want to tackle it or just leave it as it is?

@srittau
Copy link
Collaborator

srittau commented Jul 6, 2021

Personally, I would not put the work into Python 2 stubs, but I would accept PRs improving them.

@gruebel
Copy link
Contributor

gruebel commented Jul 6, 2021

I'm also not up to put some work into Python 2 stubs 😄 so next would be the stubs under the stubs folder, right?

@JelleZijlstra
Copy link
Member Author

Looks like there's no work left. (I forgot what Python 2 is.)

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

No branches or pull requests

3 participants