Skip to content

Commit

Permalink
feat: bump ruff (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Nov 15, 2024
1 parent 9139641 commit 4895547
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.1"
rev: "v0.7.3"
hooks:
# Run the linter
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion plum/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,4 @@ def __repr__(self) -> str:
return repr_short(type(self)) + "()"

def __eq__(self, other):
return type(self) == type(other)
return type(self) is type(other)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dev = [
"jupyter-book",
"mypy",
"pyright>=1.1.331",
"ruff==0.1.0",
"ruff>=0.2.1",
"sybil",
]

Expand Down
10 changes: 5 additions & 5 deletions tests/advanced/test_precedence.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def test_precedence():
el = Element()
spel = SpecialisedElement()

assert type(mul(zero, el)) == ZeroElement
assert type(mul(el, spel)) == SpecialisedElement
assert type(mul(zero, el)) is ZeroElement
assert type(mul(el, spel)) is SpecialisedElement
with pytest.raises(AmbiguousLookupError):
mul(zero, spel)

assert type(mul_precedence(zero, el)) == ZeroElement
assert type(mul_precedence(el, spel)) == SpecialisedElement
assert type(mul_precedence(zero, spel)) == ZeroElement
assert type(mul_precedence(zero, el)) is ZeroElement
assert type(mul_precedence(el, spel)) is SpecialisedElement
assert type(mul_precedence(zero, spel)) is ZeroElement
4 changes: 2 additions & 2 deletions tests/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ def f(x: int):
# Redirect `float`s to `int`s.
dispatch.multi((float,))(f.invoke(int))

assert f(1) == int
assert f(1.0) == float
assert f(1) is int
assert f(1.0) is float

assert f.methods[0].implementation is f_orig
assert f.methods[1].implementation is not f_orig
Expand Down
4 changes: 2 additions & 2 deletions tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def f2(x) -> float:
for _ in range(2):
assert m.function_name == "different_name"
assert m.signature == sig
assert m.return_type == complex
assert m.return_type is complex
assert m.implementation == f

# Test copying.
Expand Down Expand Up @@ -79,7 +79,7 @@ def f(x) -> float:

m = Method(f, sig)
assert m.function_name == "f"
assert m.return_type == float
assert m.return_type is float


def test_equality():
Expand Down
24 changes: 12 additions & 12 deletions tests/test_parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class A(Base1, metaclass=metaclass):
a1 = A[1]()
a2 = A[2]()

assert type(a1) == A[1]
assert type(a2) == A[2]
assert type(a1) is A[1]
assert type(a2) is A[2]
assert isinstance(a1, A[1])
assert not isinstance(a1, A[2])
assert issubclass(type(a1), A)
Expand Down Expand Up @@ -157,11 +157,11 @@ def __init__(self, v, w, x, y, z):
assert not issubclass(E[1], D[1, 2])
assert not issubclass(E[1], D[2])

assert type(A(1)) == A
assert type(B(1, 2)) == B[int, int]
assert type(C(1, 2, 3)) == C
assert type(D(1, 2, 3, 4)) == D[int, int, int, int]
assert type(E(1, 2, 3, 4, 5)) == E[int, int, int, int, int]
assert type(A(1)) is A
assert type(B(1, 2)) is B[int, int]
assert type(C(1, 2, 3)) is C
assert type(D(1, 2, 3, 4)) is D[int, int, int, int]
assert type(E(1, 2, 3, 4, 5)) is E[int, int, int, int, int]


def test_parametric_covariance():
Expand Down Expand Up @@ -249,7 +249,7 @@ def __init__(self, x, *, y=3):

assert A[float].parametric
assert A[float].concrete
assert A[float].type_parameter == float
assert A[float].type_parameter is float

a1 = A[float](5.0)
a2 = A(5.0)
Expand All @@ -259,9 +259,9 @@ def __init__(self, x, *, y=3):
assert a1.y == 3
assert a2.y == 3

assert type_parameter(a1) == float
assert type_parameter(a2) == float
assert type(a1) == type(a2)
assert type_parameter(a1) is float
assert type_parameter(a2) is float
assert type(a1) is type(a2)
assert type(a1).__name__ == type(a2).__name__ == "A[float]"


Expand Down Expand Up @@ -547,7 +547,7 @@ def test_val():
(Val[3, 4], Val((3, 4))),
(Val[(3, 4)], Val((3, 4))),
]:
assert type(v) == T
assert type(v) is T
assert T() == v

# Test all checks for numbers of arguments and the like.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_instantiation_copy():
for _ in range(2):
assert s.types == (int, int)
assert s.has_varargs
assert s.varargs == float
assert s.varargs is float
assert s.precedence == 1
assert s.is_faithful

Expand Down

0 comments on commit 4895547

Please sign in to comment.