Skip to content

NewType type restrictions are not enforced by pyright #6830

Closed

Description

@erictraut

When creating a new type with the NewType call, there are several restrictions that pyright doesn't currently enforce but mypy does. Mypy is conformant with the spec in this regard.

  • A TypedDict type isn't allowed because it's a structural type
  • Another type created with NewType isn't allowed
  • Any isn't allowed

Pyright already detects and flags several other conditions:

  • Protocol classes
  • Unions
  • Generics
  • Literal types

Activity

  1. added
    bug
    on Dec 28, 2023
  2. added
    addressed in next version
    on Dec 28, 2023
  3. erictraut commented on Dec 30, 2023

    @erictraut
    CollaboratorAuthor

    This is addressed in pyright 1.1.344, which I just published. It will also be included in a future release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions