This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author GBeauregard
Recipients GBeauregard
Date 2022-02-06.07:30:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
typing.TypeAlias is allowed to be bare, but it's not listed in the list of types in typing._type_check that are allowed to be bare. This means it's possible to reach the wrong error `TypeError: Plain typing.TypeAlias is not valid as type argument` at runtime.

Examples offhand:
from typing import TypeAlias, get_type_hints
class A:
    a: "TypeAlias" = int

from typing import Annotated, TypeAlias
b: Annotated[TypeAlias, ""] = int

There's likely more and/or more realistic ways to trigger the problem. Anything that triggers typing._type_check on typing.TypeAlias will give this error (TypeError: Plain typing.TypeAlias is not valid as type argument).

I will fix this by adding TypeAlias to the list of typing special forms allowed to be bare/plain. I intend to move these to their own named var to reduce the chance of types not getting added in the future.
Date User Action Args
2022-02-06 07:30:06GBeauregardsetrecipients: + GBeauregard
2022-02-06 07:30:06GBeauregardsetmessageid: <>
2022-02-06 07:30:06GBeauregardlinkissue46655 messages
2022-02-06 07:30:06GBeauregardcreate