Skip to content

NewType documentation is incorrect  #11620

@AlexWaygood

Description

@AlexWaygood

The documentation for NewType at https://mypy.readthedocs.io/en/stable/more_types.html#newtypes states:

...the typing module provides a helper function NewType that creates simple unique types with almost zero runtime overhead.

However, as the cpython documentation for NewType` states:

Changed in version 3.10: NewType is now a class rather than a function. There is some additional runtime cost when calling NewType over a regular function. However, this cost will be reduced in 3.11.0.

In Python >=3.10, NewType is a class rather than a function, meaning the mypy documentation is now incorrect.

I'm not immediately sure how it could be rewritten in a more accurate way that is still concise, however.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions