opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Use ruff instead of black/isort for autoformatting

Open aabmass opened this issue 1 year ago • 10 comments

Description

Part 1/2 for https://github.com/open-telemetry/opentelemetry-python/issues/3260

This only migrates the auto formatting capabilities. Linting will be in a separate PR which could use more scrutiny. Most of these changes look formatting changes and small things. See https://docs.astral.sh/ruff/formatter/black/ for known differences.

Type of change

Please delete options that are not relevant.

  • [x] Chore

How Has This Been Tested?

N/A this only reformats the code

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
  • [x] Yes. - Link to PR: I will send a PR after discussions are done :)

Checklist:

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

aabmass avatar Mar 28 '24 20:03 aabmass

BTW do you see what's wrong with the Public API check?

xrmx avatar Mar 29 '24 08:03 xrmx

BTW do you see what's wrong with the Public API check?

I think it's just flaking, the output doesn't have any results even though its failing

aabmass avatar Mar 29 '24 20:03 aabmass

Actually @xrmx this PR fixes the check https://github.com/open-telemetry/opentelemetry-python/pull/3825

aabmass avatar Mar 29 '24 21:03 aabmass

BTW do you see what's wrong with the Public API check?

I think it's just flaking, the output doesn't have any results even though its failing

I think at least something like this is required:

diff --git a/scripts/public_symbols_checker.py b/scripts/public_symbols_checker.py
index 05b7ad4a..b9802267 100644
--- a/scripts/public_symbols_checker.py
+++ b/scripts/public_symbols_checker.py
@@ -124,10 +124,12 @@ def remove_common_symbols():
 
 
 if added_symbols or removed_symbols:
-
     # If a symbol is added and removed in the same commit, we consider it
     # as not added or removed.
     remove_common_symbols()
+
+# re-evaluate symbols after remove_common_symbols side-effects
+if added_symbols or removed_symbols:
     print("The code in this branch adds the following public symbols:")
     print()
     for file_path_, symbols_ in added_symbols.items():

UPDATE: ah seen your PR :)

xrmx avatar Mar 29 '24 21:03 xrmx

BTW changelog would be nice to have the ruff commit handy

xrmx avatar Mar 29 '24 21:03 xrmx

BTW changelog would be nice to have the ruff commit handy

I didn't add an entry initially because I don't think it's applicable to the changelog audience (consumers of the library). Happy to add if you think otherwise

aabmass avatar Apr 01 '24 14:04 aabmass

BTW changelog would be nice to have the ruff commit handy

I didn't add an entry initially because I don't think it's applicable to the changelog audience (consumers of the library). Happy to add if you think otherwise

It would be handy for people poking with the code :)

xrmx avatar Apr 02 '24 10:04 xrmx

Adding "do not merge label" until we decide for sure on Ruff replacing flake8 and pylint as well.

aabmass avatar Apr 02 '24 15:04 aabmass

Adding "do not merge label" until we decide for sure on Ruff replacing flake8 and pylint as well.

Marking as draft to prevent accidental merging.

ocelotl avatar Apr 04 '24 15:04 ocelotl

Once the conflict has been resolved this should be ready to land right?

xrmx avatar Apr 08 '24 10:04 xrmx

Closing it out as #4223 actually went through

aabmass avatar Apr 10 '25 15:04 aabmass