Skip to content

Commit

Permalink
flake8: Enable bugbear plugin, fix exposed warts
Browse files Browse the repository at this point in the history
This mostly included mutable data structures being used as default parameters.
  • Loading branch information
nbraud committed Feb 24, 2019
1 parent 86a1841 commit d603255
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flake8
flake8-bugbear
hypothesis
mypy==0.641
perf
Expand Down
2 changes: 1 addition & 1 deletion ppb_vector/vector2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
select = E,F,W,B,B9
ignore = E704
max-line-length = 100
9 changes: 6 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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):
Expand All @@ -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}")
Expand Down Expand Up @@ -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})

0 comments on commit d603255

Please sign in to comment.