-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongdocumentationfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-newtypeNewTypeNewType
Description
I want to create a new type derived from ObjectId in similar way as is described in documentation for new type UserId derived from int:
from bson import ObjectId
UserId = NewType('UserId', ObjectId)
But Mypy gives Argument 2 to NewType(...) must be subclassable (got "Any").
There is written in documentation:
NewType accepts exactly two arguments. The first argument must be a string literal containing the name of the new type and must equal the name of the variable to which the new type is assigned. The second argument must be a properly subclassable class, i.e., not a type construct like Union, etc.
It is not clear what properly subclassable class means and why ObjectId is not properly subclassable class. Could please someone clarify this to me and in documentation?
roganov, tbelhalfaoui, bcolloran, JarnoRFB, gitttt and 7 more
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongdocumentationfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-newtypeNewTypeNewType