Skip to content

Commit

Permalink
Merge pull request #91 from KotlinIsland/fix-overload
Browse files Browse the repository at this point in the history
fix overload
  • Loading branch information
KotlinIsland authored Dec 12, 2023
2 parents 01ac8d0 + af5bd49 commit 4689c3c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 34 deletions.
24 changes: 16 additions & 8 deletions basedtyping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import contextlib
import sys
from typing import (
TYPE_CHECKING,
Expand All @@ -21,17 +22,24 @@
)

import typing_extensions
from typing_extensions import (
Never,
ParamSpec,
TypeAlias,
TypeGuard,
TypeVarTuple,
override,
)
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
Expand Down
53 changes: 28 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = "0.1.3"

[tool.poetry.dependencies]
python = "^3.8"
typing_extensions = "^4"
typing_extensions = "^4.1"

[tool.poetry.group.dev.dependencies]
basedmypy = "^2"
Expand Down

0 comments on commit 4689c3c

Please sign in to comment.