Skip to content

Commit

Permalink
Python 3.10 cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
coady committed Jan 31, 2025
1 parent db1bd7b commit e34254d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Changed
* Python >=3.10 required

### Fixed
* `multidispatch` allows pending references

## [2.0](https://pypi.org/project/multimethod/2.0/) - 2024-12-26
### Removed
* Resolving ambiguity using positional distance
Expand Down
10 changes: 4 additions & 6 deletions multimethod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import types
import typing
from collections.abc import Callable, Iterable, Iterator, Mapping
from typing import Any, Literal, TypeVar, Union, get_type_hints, overload
from typing import Any, Literal, NewType, TypeVar, Union, get_type_hints, overload


class DispatchError(TypeError):
pass
class DispatchError(TypeError): ...


def get_origin(tp):
Expand Down Expand Up @@ -48,7 +47,7 @@ class subtype(abc.ABCMeta):
def __new__(cls, tp, *args):
if tp is Any:
return object
if hasattr(tp, '__supertype__'): # isinstance(..., NewType) only supported >=3.10
if isinstance(tp, NewType):
return cls(tp.__supertype__, *args)
if hasattr(typing, 'TypeAliasType') and isinstance(tp, typing.TypeAliasType):
return cls(tp.__value__, *args)
Expand Down Expand Up @@ -414,8 +413,7 @@ class multimeta(type):
"""Convert all callables in namespace to multimethods."""

class __prepare__(dict):
def __init__(*args):
pass
def __init__(*args): ...

def __setitem__(self, key, value):
if callable(value):
Expand Down
1 change: 0 additions & 1 deletion tests/test_subscripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def func(arg: Literal['a', 0]):
func(0.0)


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

0 comments on commit e34254d

Please sign in to comment.