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

Switch to ruff #543

Merged
merged 13 commits into from
Aug 12, 2024
Merged

Switch to ruff #543

merged 13 commits into from
Aug 12, 2024

Conversation

mfisher87
Copy link
Member

@JessicaS11 and I had a chat about this on the phone today. I feel Ruff's capacity to automatically fix so much stuff is a game-changer! I have to think about linting much less.

Copy link

github-actions bot commented Aug 8, 2024

Binder 👈 Launch a binder notebook on this branch for commit 84f2b1f

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit 0085b7e

Binder 👈 Launch a binder notebook on this branch for commit f9ac3d7

Binder 👈 Launch a binder notebook on this branch for commit 987ac7f

Binder 👈 Launch a binder notebook on this branch for commit e580112

Binder 👈 Launch a binder notebook on this branch for commit 447b8f4

Binder 👈 Launch a binder notebook on this branch for commit 9700eae

# bare except
"E722",
# unable to detect undefined names
"F403",
Copy link
Member Author

Choose a reason for hiding this comment

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

Some of these are pretty easy to polish off. F403 is one -- here we import * in an __init__.py. Instead, we should import the objects we want to expose by name. Any thoughts on what objects we want to expose here?

https://github.com/icesat2py/icepyx/blob/development/icepyx/quest/dataset_scripts/__init__.py

Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 66.05%. Comparing base (49501ec) to head (9700eae).
Report is 45 commits behind head on development.

Files with missing lines Patch % Lines
icepyx/core/is2ref.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           development     #543   +/-   ##
============================================
  Coverage        66.05%   66.05%           
============================================
  Files               36       36           
  Lines             3049     3049           
  Branches           537      537           
============================================
  Hits              2014     2014           
  Misses             947      947           
  Partials            88       88           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from remove-flake8-ignores to development August 12, 2024 00:07
# Use the Ruff linter to annotate code style / best-practice issues
# NOTE: More config provided in pyproject.toml
- name: Lint and annotate PR
uses: chartboost/ruff-action@v1
Copy link
Member

@weiji14 weiji14 Aug 12, 2024

Choose a reason for hiding this comment

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

Looks like this GitHub Action isn't compatible with ruff>=0.5.0 (ChartBoost/ruff-action#30) and there's also a separate issue that they're looking into transferring this to another organization (which might take a while).

So... could we just use pre-commit.ci instead? Or are the annotations good to have?

Copy link
Member Author

@mfisher87 mfisher87 Aug 12, 2024

Choose a reason for hiding this comment

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

I'm cool with just using pre-commit.ci. I was trying to avoid any regression in functionality. I personally don't find annotation of PRs to be that valuable, but I imagine the feature would be more valuable to someone who doesn't know how to use the linter at the CLI. 🤔

It looks to me from reading the issue like this isn't an incompatibility issue yet though? Or has Ruff gone forward with the breaking change? EDIT: Nevermind, we can see right here that it's broken :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed linting on this PR. I was using an outdated argument form!

Copy link
Member

Choose a reason for hiding this comment

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

I personally don't find annotation of PRs to be that valuable, but I imagine the feature would be more valuable to someone who doesn't know how to use the linter at the CLI.

You've identified exactly why we have the PR annotations set up. Precommit is an additional barrier to new contributors, so I wanted to be able to enforce the linting and formatting without absolutely requiring they complete yet another setup step to contribute.

Copy link
Member Author

Choose a reason for hiding this comment

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

💯

@mfisher87 mfisher87 requested a review from weiji14 August 12, 2024 14:49
Comment on lines -35 to -37
# GOAL:
# syntax check doctests in docstrings
# doctests = True
Copy link
Member

Choose a reason for hiding this comment

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

No way to syntax check docstrings in ruff yet - astral-sh/ruff#3542. But we can at least format the docstrings, see below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are we executing doctests? That'll give us the syntax check!

Copy link
Member

Choose a reason for hiding this comment

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

No, not yet, but can do that later!

@mfisher87 mfisher87 requested a review from weiji14 August 12, 2024 21:38
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Super, thanks again @mfisher87!

@mfisher87 mfisher87 merged commit e0e1738 into development Aug 12, 2024
5 checks passed
@mfisher87 mfisher87 deleted the switch-to-ruff branch August 12, 2024 21:52
Comment on lines -1 to -2
black
flake8
Copy link
Member

Choose a reason for hiding this comment

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

Suggest we add ruff here (unless it only ever runs on CI?)

Copy link
Member Author

Choose a reason for hiding this comment

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

It runs in GitHub Actions and in pre-commit.ci, but seems useful to also have it in the dev requirements!

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.

3 participants