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

add ruff lint rule to remove unused imports via ruff #969

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

jimexist
Copy link
Contributor

@jimexist jimexist commented Sep 28, 2024

  • include stricter linter rules for the allowlisted files
  • add more comments
  • use python 11 for ruff run
  • fix ruff to 0.6.8 to make it consistent

Copy link

pytorch-bot bot commented Sep 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/969

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 9006929 with merge base c0a81f9 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 28, 2024
@msaroufim
Copy link
Member

So for linting feel free to add a new file or folder here and make all the changes you need https://github.com/pytorch/ao/blob/main/ruff.toml

It's tricky for us to merge something like this since eveyrone would need to rebase their code

@jimexist jimexist changed the title remove unused imports via ruff add ruff lint rule to remove unused imports via ruff Sep 28, 2024
@jimexist
Copy link
Contributor Author

So for linting feel free to add a new file or folder here and make all the changes you need https://github.com/pytorch/ao/blob/main/ruff.toml

It's tricky for us to merge something like this since eveyrone would need to rebase their code

thank you for the reference. that makes sense.
i then only updated the GitHub workflow to include the new rule. this renders no difference on the list of included files in the toml config.

@msaroufim
Copy link
Member

Ok cool! Can you remove unused imports in files erroring in CI and we can merge this

@jimexist
Copy link
Contributor Author

Ok cool! Can you remove unused imports in files erroring in CI and we can merge this

turns out the ruff linter is configured to:

  1. format w.r.t the listed files
  2. apply the limited ruleset for all files

my change is to include a stricter linter rule but only applies to the allowlist, kind of between 1 and 2

- name: Analyzing the code with ruff
run: |
ruff check .
- name: Check all Python files for syntax errors (E999) and undefined vars (F821)
- name: Check *all* Python files for F821, F823, and W191
Copy link
Contributor Author

Choose a reason for hiding this comment

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

e999 was deprecated and by default applied

@@ -25,13 +25,18 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
pip install ruff==0.6.8
Copy link
Member

Choose a reason for hiding this comment

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

how come?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rule set changes with versions so this is to avoid sudden breakage if they release a newer version

Copy link
Member

Choose a reason for hiding this comment

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

@drisspg any preference on this?

Cause btw now locally vs remotely there'll be ruff deviations https://github.com/pytorch/ao/blob/main/dev-requirements.txt#L22

Copy link
Contributor

@drisspg drisspg Oct 1, 2024

Choose a reason for hiding this comment

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

That's fine; I think we just need to also pin in dev-requirments.txt

I kept it loose since it's a pretty common dependency and didn't want to thrash environments, but pinning is better practice

@@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.11"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
python-version: ["3.11"]
python-version: ["3.9"]

@msaroufim msaroufim requested a review from drisspg October 1, 2024 01:58
@msaroufim msaroufim merged commit 1137f39 into pytorch:main Oct 1, 2024
17 checks passed
@jimexist jimexist deleted the ruff-apply-e401 branch October 2, 2024 13:50
melvinebenezer pushed a commit to melvinebenezer/ao that referenced this pull request Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants