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

Migrate formatting and linting to ruff #3816

Closed
wants to merge 7 commits into from

Conversation

aabmass
Copy link
Member

@aabmass aabmass commented Mar 28, 2024

Description

Migrates pylint, flake8, black, and isort to ruff. Ruff is very fast and has complete feature parity with all of the above except some pylint features. Ruff does not use the python environment at all, so it no longer requires any deps to be installed in the virtualenv.

Dropping pylint is definitely worth discusing, because we don't run mypy on all of our sources. See here for a list of tradeoffs and recommendations. I think this is a decent trade off given how clunky, difficult to use (e.g. #3814), and slow pylint is. We should try to enable mypy on the rest of our sources imo.

Fixes #3260 and numerous complaints about the painfully slow lint/formatting process

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Contrib Repo Change?

Answer the following question based on these examples of changes that would require a Contrib Repo Change:

  • The OTel specification has changed which prompted this PR to update the method interfaces of opentelemetry-api/ or opentelemetry-sdk/

  • The method interfaces of test/util have changed

  • Scripts in scripts/ that were copied over to the Contrib repo have changed

  • Configuration files that were copied over to the Contrib repo have changed (when consistency between repositories is applicable) such as in

    • pyproject.toml
    • isort.cfg
    • .flake8
  • When a new .github/CODEOWNER is added

  • Major changes to project information, such as in:

    • README.md
    • CONTRIBUTING.md
  • Yes. - Link to PR:

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

I was going to do it after bumping black but thanks for beating me to it :)

dev-requirements.txt Show resolved Hide resolved
@@ -660,7 +649,14 @@ def format_args(args):
)
runsubprocess(
args.dry_run,
("isort", "--settings-path", f"{root_dir}/.isort.cfg", "--profile", "black", "."),
(
"isort",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you still keep isort and black here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops i missed this thanks

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 in new PR

@aabmass
Copy link
Member Author

aabmass commented Mar 28, 2024

I was going to do it after bumping black but thanks for beating me to it :)

Sorry didn't realize you were working on it! I can give you permission to push to the PR if you'd like to collaborate here

Fyi I should probably split this into two PRs (or at least commits) for easier reviewing:

  1. replace black and isort
  2. replace linters and swap any pylint-disable with ruff noqa comments

I think the second will be more useful to actually scrutinize for missing coverage

@xrmx
Copy link
Contributor

xrmx commented Mar 28, 2024

I was going to do it after bumping black but thanks for beating me to it :)

Sorry didn't realize you were working on it! I can give you permission to push to the PR if you'd like to collaborate here

Don't worry, it was just a plan :)

Fyi I should probably split this into two PRs (or at least commits) for easier reviewing:

1. replace black and isort

2. replace linters and swap any `pylint-disable` with ruff `noqa` comments

I think the second will be more useful to actually scrutinize for missing coverage

Separate commits for formatting and linting will be appreciated, thanks!

@aabmass
Copy link
Member Author

aabmass commented Mar 28, 2024

Closing in favor of two PRs. First one here #3822

@aabmass aabmass closed this Mar 28, 2024
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.

adopt ruff?
2 participants