Skip to content

Improve the self types situation #5676

@JelleZijlstra

Description

@JelleZijlstra

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]'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions