Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move to using Ruff #315

Merged
merged 2 commits into from
Feb 17, 2023
Merged

chore: move to using Ruff #315

merged 2 commits into from
Feb 17, 2023

Conversation

henryiii
Copy link
Member

  • chore: move to using Ruff
  • style: make Ruff happy

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii henryiii force-pushed the henryiii/chore/ruff branch from 289a7d6 to 3a09183 Compare February 17, 2023 15:12
Comment on lines 736 to 742
len(returns) == 2
and isinstance(returns[0], type)
and issubclass(returns[0], Azimuthal)
and returns[1] is None
):
azcoords = _coord_object_type[returns[0]](result[0], result[1])
return cls.ProjectionClass2D(azimuthal=azcoords)

elif (
len(returns) == 2
and isinstance(returns[0], type)
and issubclass(returns[0], Azimuthal)
and isinstance(returns[1], type)
and issubclass(returns[1], Longitudinal)
):
azcoords = _coord_object_type[returns[0]](result[0], result[1])
lcoords = _coord_object_type[returns[1]](result[2])
return cls.ProjectionClass3D(azimuthal=azcoords, longitudinal=lcoords)

elif (
len(returns) == 3
or (len(returns) == 3 and returns[2] is None)
and isinstance(returns[0], type)
and issubclass(returns[0], Azimuthal)
and isinstance(returns[1], type)
and issubclass(returns[1], Longitudinal)
and returns[2] is None
):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to manually make these changes, but pretty impressed Ruff noticed it could be made. :)

- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-docstrings
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, Ruff's "D" code catches a lot of stuff the old one didn't. So I've removed it for now, and we can enable new codes (including "D") in the future.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii henryiii force-pushed the henryiii/chore/ruff branch from 3a09183 to 44f5cf2 Compare February 17, 2023 15:27
@@ -694,7 +694,7 @@ def momentum_rhophizt():
assert out.pt == pytest.approx(2)
assert out.phi == pytest.approx(3.3)
assert out.z == pytest.approx(5)
assert out.E == pytest.approx(10)
assert out.E == pytest.approx(10) # noqa: SIM300
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yoda conditions thinks ".E" is a constant.


@numba.njit
def get_false(v):
return False if v else True
return False if v else True # noqa: SIM211
Copy link
Member Author

@henryiii henryiii Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support not v, which is a little strange, but just noqa'd it. not bool(v) probably would have worked, since I think bool(v) above worked. But that also might have been simplified by a SIM code.

@Saransh-cpp
Copy link
Member

Ruff looks amazing! 🤩

@henryiii henryiii merged commit 8f25cbc into main Feb 17, 2023
@henryiii henryiii deleted the henryiii/chore/ruff branch February 17, 2023 19:25
@Saransh-cpp Saransh-cpp added this to the v1.0.0 milestone Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants