Skip to content

A NewType is reported as "Class created with NewType" when used in isinstance #10601

@jorenham

Description

@jorenham
A = NewType("A", int)
isinstance(1, A)

causes the following error to be reported

Second argument to "isinstance" must be a class or tuple of classes
  Class created with NewType cannot be used with instance and class checks  (reportArgumentType)

A is referred to as the "Class created with NewType", but A is not a class.

pyright-play

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions