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

Swap from flake8 to ruff #963

Merged
merged 3 commits into from
Mar 21, 2023

Conversation

glowatsk
Copy link
Contributor

@glowatsk glowatsk commented Mar 20, 2023

Fixes

Partially addresses #787

Description

Move the current configuration to the ruff linter. pre-commit will use ruff now for linting, extra configuration can be added as needed. I opted for .ruff.yaml as the dotfile is usually handled better with editors. This can be changed as needed.

E203 is made obsolete by black.
W503 is made obsolete by black.
Line length is by default 88.

https://beta.ruff.rs/docs/rules/

I do not see any documentation involving flake8.

Testing Instructions

Checklist

  • My pull request has a descriptive title (not a vague title like
    Update index.md).
  • My pull request targets the default branch of the repository (main) or
    a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible
    errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@glowatsk glowatsk requested review from a team as code owners March 20, 2023 18:09
@openverse-bot openverse-bot added the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Mar 20, 2023
@AetherUnbound AetherUnbound removed the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Mar 20, 2023
@openverse-bot openverse-bot added 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 🤖 aspect: dx Concerns developers' experience with the codebase 🧱 stack: mgmt Related to repo management and automations labels Mar 20, 2023
@glowatsk glowatsk force-pushed the fix/swap_flake8_to_ruff branch 5 times, most recently from 961e4d3 to cab785b Compare March 20, 2023 18:45
@zackkrida
Copy link
Member

Awesome, @glowatsk! It looks like in the CI the .ruff.toml file failed to parse:

error: Failed to parse `/home/runner/work/openverse/openverse/.ruff.toml`: TOML parse error at line 7, column 15
  |
7 | line-length = 88
  |               ^^
invalid type: integer `88`, expected a sequence

details of the CI run here: https://github.com/WordPress/openverse/actions/runs/4471769545/jobs/7857074527?pr=963

@glowatsk
Copy link
Contributor Author

Awesome, @glowatsk! It looks like in the CI the .ruff.toml file failed to parse:

error: Failed to parse `/home/runner/work/openverse/openverse/.ruff.toml`: TOML parse error at line 7, column 15
  |
7 | line-length = 88
  |               ^^
invalid type: integer `88`, expected a sequence

details of the CI run here: https://github.com/WordPress/openverse/actions/runs/4471769545/jobs/7857074527?pr=963

Thanks, looks like this is default and is no longer needed.
https://beta.ruff.rs/docs/settings/#line-length

Remove E203 W503 as these are handled by Black
Line length is by default 88
@glowatsk
Copy link
Contributor Author

@zackkrida think this is good to go now.

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks for the contribution @glowatsk.

Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

Sweet, nice work @glowatsk

@dhruvkb
Copy link
Member

dhruvkb commented Mar 20, 2023

CI has to pass before we merge this. Because if not, every other PR will fail CI.

Update: my mistake. I wrongly interpreted the lint check to be failing.

@glowatsk
Copy link
Contributor Author

CI has to pass before we merge this. Because if not, every other PR will fail CI.

Should just need the appropriate stack label.

@dhruvkb
Copy link
Member

dhruvkb commented Mar 21, 2023

Ah, sorry, my bad. I misread the lint check as failing. The 'CI + CD / Add stack label (pull_request)' check fails on PRs from forks, so we can merge it despite the failing check.

@sarayourfriend sarayourfriend merged commit da0769e into WordPress:main Mar 21, 2023
@AetherUnbound
Copy link
Contributor

Thanks so much for this contribution @glowatsk!! What an awesome improvement to have come from the PyCascades sprints 😄 🥳 🏎️

@AetherUnbound
Copy link
Contributor

Oh also, does #787 still need to remain open, or can it be closed?

AetherUnbound added a commit to AetherUnbound/ruff that referenced this pull request Mar 30, 2023
We had a community contributor take this on in WordPress/openverse#963 and we were so pleased with the results! Heard about this on Talk Python To Me and we're glad we did 😄 Thanks for the excellent tool!
dhruvkb pushed a commit that referenced this pull request Apr 14, 2023
* Fill creator name in finnish museum DAG (#978)

* Bump pre-commit from 2.21.0 to 3.0.2 (#983)

* 🔄 synced local '.pre-commit-config.yaml' with remote 'templates/.pre-commit-config.yaml.jinja'

* Update docstrings to conform to linting

* Update DAGs.md

---------

Co-authored-by: Krystle Salazar <krystle.salazar@automattic.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: openverse-bot <null>
Co-authored-by: Madison Swain-Bowden <bowdenm@spu.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants