Skip to content

Remove fake overload when typing_extensions is >= 4.4 #92

Open
@github-actions

Description

@github-actions

AttributeError happens if the object has __slots__ or a

read-only property, TypeError if it's a builtin class.

# TODO: Remove when typing_extensions is >= 4.4

)

import typing_extensions
from typing_extensions import Never, ParamSpec, TypeAlias, TypeGuard, TypeVarTuple

from basedtyping.runtime_only import OldUnionType

if TYPE_CHECKING:
    from typing_extensions import override
else:

    def override(arg, /):
        # TODO: Remove when typing_extensions is >= 4.4
        with contextlib.suppress(AttributeError, TypeError):
            # Skip the attribute silently if it is not writable.
            # AttributeError happens if the object has __slots__ or a
            # read-only property, TypeError if it's a builtin class.
            arg.__override__ = True
        return arg


if not TYPE_CHECKING:
    # TODO: remove the TYPE_CHECKING block once these are typed in basedtypeshed
    from typing import _GenericAlias, _remove_dups_flatten, _tp_cache, _type_check

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions