Skip to content

Commit

Permalink
chore: simplify code after typing-extension dep
Browse files Browse the repository at this point in the history
The dependency is now installed for Python 3.10 and 3.11 as well, allowing to
use it in the codebase for those versions.
  • Loading branch information
Rogdham committed May 20, 2024
1 parent 86e6918 commit 76fd313
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
13 changes: 6 additions & 7 deletions src/bigxml/handle_mgr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -20,16 +21,14 @@
)
from bigxml.utils import last_item_or_none

if TYPE_CHECKING:
import sys
if sys.version_info < (3, 11): # pragma: no cover
from typing_extensions import Never
else: # pragma: no cover
from typing import Never

if TYPE_CHECKING:
from bigxml.nodes import XMLElement, XMLText

if sys.version_info < (3, 11): # pragma: no cover
from typing import NoReturn as Never
else: # pragma: no cover
from typing import Never


class HandleMgr:
_handle: Optional[
Expand Down
13 changes: 3 additions & 10 deletions tests/integration/test_typing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
import sys
from typing import TYPE_CHECKING, Any, Iterable, Iterator, Optional, Tuple, Union
from typing import Iterable, Iterator, Optional, Tuple, Union

from bigxml import (
HandlerTypeHelper,
Expand All @@ -12,16 +12,9 @@
)

if sys.version_info < (3, 11):
from typing import NoReturn as Never
from typing_extensions import Never, assert_type
else:
from typing import Never

if TYPE_CHECKING:
from typing_extensions import assert_type
else:

def assert_type(val: Any, _: Any) -> Any: # noqa: ANN401
return val
from typing import Never, assert_type


# Note: the aim of this file is to test the typing of return-values
Expand Down

0 comments on commit 76fd313

Please sign in to comment.