Skip to content

Commit e34254d

Browse files
committed
Python 3.10 cleanup.
1 parent db1bd7b commit e34254d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
77
### Changed
88
* Python >=3.10 required
99

10+
### Fixed
11+
* `multidispatch` allows pending references
12+
1013
## [2.0](https://pypi.org/project/multimethod/2.0/) - 2024-12-26
1114
### Removed
1215
* Resolving ambiguity using positional distance

multimethod/__init__.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
import types
88
import typing
99
from collections.abc import Callable, Iterable, Iterator, Mapping
10-
from typing import Any, Literal, TypeVar, Union, get_type_hints, overload
10+
from typing import Any, Literal, NewType, TypeVar, Union, get_type_hints, overload
1111

1212

13-
class DispatchError(TypeError):
14-
pass
13+
class DispatchError(TypeError): ...
1514

1615

1716
def get_origin(tp):
@@ -48,7 +47,7 @@ class subtype(abc.ABCMeta):
4847
def __new__(cls, tp, *args):
4948
if tp is Any:
5049
return object
51-
if hasattr(tp, '__supertype__'): # isinstance(..., NewType) only supported >=3.10
50+
if isinstance(tp, NewType):
5251
return cls(tp.__supertype__, *args)
5352
if hasattr(typing, 'TypeAliasType') and isinstance(tp, typing.TypeAliasType):
5453
return cls(tp.__value__, *args)
@@ -414,8 +413,7 @@ class multimeta(type):
414413
"""Convert all callables in namespace to multimethods."""
415414

416415
class __prepare__(dict):
417-
def __init__(*args):
418-
pass
416+
def __init__(*args): ...
419417

420418
def __setitem__(self, key, value):
421419
if callable(value):

tests/test_subscripts.py

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def func(arg: Literal['a', 0]):
3131
func(0.0)
3232

3333

34-
@pytest.mark.skipif(sys.version_info < (3, 10), reason="Union syntax added in 3.10")
3534
def test_union():
3635
assert issubclass(int, subtype(int | float))
3736
assert issubclass(subtype(int | float), subtype(int | float | None))

0 commit comments

Comments
 (0)