Skip to content

Commit

Permalink
Finish fixing support for 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
bswck committed Apr 21, 2024
1 parent 56c53b9 commit 5394792
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
26 changes: 14 additions & 12 deletions class_singledispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@

from __future__ import annotations

import sys
from contextlib import suppress
from functools import partial, singledispatch
from typing import (
TYPE_CHECKING,
Any,
ForwardRef,
Generic,
Type,
TypeVar,
Expand All @@ -29,22 +32,21 @@
from typing import overload


OldFashionGenericAlias = type(Type[object])
OldFashionGenericAlias: type[object] = type(Type[object])

try:
from types import GenericAlias # type: ignore # noqa: PGH003
except ImportError: # pragma: no cover
if sys.version_info < (3, 9):
GenericAlias = OldFashionGenericAlias
else:
from types import GenericAlias

try: # pragma: no cover
from typing_extensions import ParamSpec # type: ignore # noqa: PGH003
except ImportError: # pragma: no cover
from typing import ParamSpec # type: ignore # noqa: PGH003

try:
from eval_type_backport import ForwardRef # type: ignore # noqa: PGH003
except ImportError: # pragma: no cover
from typing import ForwardRef # type: ignore # noqa: PGH003
if sys.version_info < (3, 10):
from typing_extensions import ParamSpec
else:
from typing import ParamSpec

with suppress(ImportError):
from eval_type_backport import ForwardRef # noqa: F811


__all__ = (
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

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

10 changes: 4 additions & 6 deletions tests/test_class_singledispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import enum
import sys
from contextlib import suppress
from dataclasses import dataclass
from typing import Type
from typing import ForwardRef, Type

import pytest

from class_singledispatch import class_singledispatch, resolve_annotated_type


try:
from eval_type_backport import ForwardRef # type: ignore # noqa: PGH003
except ImportError:
from typing import ForwardRef # type: ignore # noqa: PGH003
with suppress(ImportError):
from eval_type_backport import ForwardRef


@dataclass
Expand Down

0 comments on commit 5394792

Please sign in to comment.