diff --git a/dev-requirements.txt b/dev-requirements.txt index 0b7977f3..756bd6ff 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,5 @@ flake8 +flake8-bugbear hypothesis mypy==0.641 perf diff --git a/ppb_vector/vector2.py b/ppb_vector/vector2.py index 13abbfb1..8b85261e 100644 --- a/ppb_vector/vector2.py +++ b/ppb_vector/vector2.py @@ -239,7 +239,7 @@ def angle(self: VectorOrSub, other: VectorLike) -> float: def isclose(self: VectorOrSub, other: VectorLike, *, abs_tol: Realish = 1e-3, rel_tol: Realish = 1e-06, - rel_to: typing.Sequence[VectorLike] = []) -> bool: + rel_to: typing.Sequence[VectorLike] = ()) -> bool: """ Determine whether two vectors are close in value. diff --git a/setup.cfg b/setup.cfg index c8de6df4..39f42289 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,4 @@ [flake8] +select = E,F,W,B,B9 ignore = E704 max-line-length = 100 diff --git a/tests/utils.py b/tests/utils.py index 092110e8..d37f2ee7 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,6 +4,9 @@ import hypothesis.strategies as st +UNIT_X, UNIT_Y = Vector2(1, 0), Vector2(0, 1) + + def angles(): return st.floats(min_value=-360, max_value=360) @@ -25,7 +28,7 @@ def vectors(max_magnitude=1e75): def units(): - return st.builds(Vector2(1, 0).rotate, angles()) + return st.builds(UNIT_X.rotate, angles()) def angle_isclose(x, y, epsilon=6.5e-5): @@ -39,7 +42,7 @@ def isclose( abs_tol: float = 1e-9, rel_tol: float = 1e-9, rel_exp: float = 1, - rel_to: Sequence[Union[float, Vector2]] = [], + rel_to: Sequence[Union[float, Vector2]] = (), ): if rel_exp < 1: raise ValueError(f"Expected rel_exp >= 1, got {rel_exp}") @@ -84,5 +87,5 @@ def isclose( # Sequence of vector-likes equivalent to the input vector (def. to the x vector) -def vector_likes(v: Vector2 = Vector2(1, 0)): +def vector_likes(v: Vector2 = UNIT_X): return ((v.x, v.y), [v.x, v.y], {"x": v.x, "y": v.y})