-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-metaclassestopic-type-aliasTypeAlias and other type alias issuesTypeAlias and other type alias issues
Description
Here's a quick sample of a problem:
from typing_extensions import TypeAlias
Explicit: TypeAlias = type
Implicit = type
class E(metaclass=Explicit): ... # Invalid metaclass "Explicit"
class I(metaclass=Implicit): ... # Invalid metaclass "Implicit"I think that using type aliases should be allowed in metaclasses.
Why?
- This blocks conditional metaclasses in
typeshed, see Add missing metaclasses typeshed#8497
For example, see dataclasses.pyi definition:
if sys.version_info >= (3, 9):
_InitVarMeta = type
else:
class _InitVarMeta(type): ... # whatever methods- It is valid in runtime
- I don't think that unaliasing an alias here can lead to some type-checking problems (yes-yes, we have recursive type-aliases and what not 😒)
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-metaclassestopic-type-aliasTypeAlias and other type alias issuesTypeAlias and other type alias issues