Skip to content

Mypy fails on Python 3.12 TypeAliasType compatibility branch #178

Description

@abhinavkr26104

Description

Running the repository's pinned mypy (1.17) under supported Python 3.12 fails in the shared typing helper because _TYPE_ALIAS_TYPES is annotated as containing type[typing_extensions.TypeAliasType], then appends the distinct stdlib typing.TypeAliasType class.

Code reference

src/browserbase/_utils/_typing.py:54-56

Reproduction

With Python 3.12 and the repository dev dependencies:

python -m mypy src

Actual error:

src/browserbase/_utils/_typing.py:56: error: Argument 2 to <tuple> has incompatible type
type[typing.TypeAliasType]; expected type[typing_extensions.TypeAliasType] [arg-type]

Expected behavior

The strict type-check command should pass on supported Python versions, including Python 3.12 where typing.TypeAliasType exists. The tuple annotation/type guard should model both runtime implementations (or use a suitably common type[object] representation while preserving narrowing).

Actual behavior

Mypy reports a source error on Python 3.12. The current CI lint job uses the repository's minimum Python selected by .python-version, so this version-dependent branch is not checked.

Why it matters

This is a core/shared typing utility used to recognize both stdlib and backport aliases. A Python-version matrix for type checking would catch this class of conditional typing regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions