Skip to content

Commit

Permalink
Minor changes + running ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipVinc committed Sep 30, 2023
1 parent a13366e commit ae83f86
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plum/dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union
from typing import Any, Dict, Optional, Tuple, TypeVar, Union

from .function import Function
from .overload import get_overloads
Expand Down
3 changes: 2 additions & 1 deletion plum/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import wraps
from types import MethodType
from typing import Any, Callable, List, Optional, Tuple, TypeVar, Union
from copy import copy

from .resolver import AmbiguousLookupError, NotFoundLookupError, Resolver
from .signature import Signature, append_default_args, extract_signature
Expand Down Expand Up @@ -281,7 +282,7 @@ def _resolve_pending_registrations(self) -> None:
else:
# Ensure that the implementation is `f`, but make a copy before
# mutating.
signature = signature.__copy__()
signature = copy(signature)
signature.implementation = f

# Ensure that the implementation has the right name, because this name
Expand Down
6 changes: 3 additions & 3 deletions plum/promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def rule(t1: type1, t2: type2):
# If the types are the same, the method will get overwritten.

@_promotion_rule.dispatch
def rule(t1: type2, t2: type1):
def rule(t1: type2, t2: type1): # noqa F811
return type_to


Expand Down Expand Up @@ -161,11 +161,11 @@ def _promote_types(t0, t1):


@_dispatch
def promote(obj: object):
def promote(obj: object): # noqa F811
# Promote should always return a tuple to avoid edge cases.
return (obj,)


@_dispatch
def promote():
def promote(): # noqa F811
return ()
14 changes: 8 additions & 6 deletions plum/signature.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Callable, List, Tuple, Optional

import typing
import inspect
import operator
import typing
from typing import Callable, List, Optional, Tuple
from copy import copy

import beartype.door
from beartype.peps import resolve_pep563
Expand Down Expand Up @@ -286,15 +288,15 @@ def append_default_args(signature: Signature, f: Callable) -> List[Signature]:
if p.kind == p.VAR_POSITIONAL:
continue

copy = signatures[-1].__copy__()
signature_copy = copy(signatures[-1])

# As specified over, these additional signatures should never have variable
# arguments.
copy.varargs = Missing
signature_copy.varargs = Missing

# Remove the last positional argument.
copy.types = copy.types[:-1]
signature_copy.types = signature_copy.types[:-1]

signatures.append(copy)
signatures.append(signature_copy)

return signatures
2 changes: 1 addition & 1 deletion plum/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
import sys
import typing
from typing import Callable, List
from typing import List

if sys.version_info.minor <= 8: # pragma: specific no cover 3.9 3.10 3.11
from typing import Callable
Expand Down

0 comments on commit ae83f86

Please sign in to comment.