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

Upgrade isort and enable black compat mode #248

Merged
merged 1 commit into from
Jan 5, 2021

Conversation

owais
Copy link
Contributor

@owais owais commented Dec 11, 2020

isort and black can be incompatible. Often isort re-writes files in a
way black doesn't like. It takes quite some time and manual effort to
make changes that satisfy both isort and black.

Fortunately, newer versions of isort support a black compatibility mode by setting
isort profile to "black". This makes isort order imports in a way that
is compatible with how black formats Python code. This PR configures
isort to use the black profile by default

Depends on #231

@owais owais requested review from a team, toumorokoshi and ocelotl and removed request for a team December 11, 2020 10:48
@owais owais added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Dec 11, 2020
@owais owais force-pushed the isort-and-black-be-friends branch 5 times, most recently from a833aa1 to 2fb39eb Compare December 11, 2020 11:41
@owais
Copy link
Contributor Author

owais commented Dec 11, 2020

pylint is crashing after the upgrade. I'll look into that and ping here when this is ready for review.

@owais owais force-pushed the isort-and-black-be-friends branch 6 times, most recently from 16c685f to d9f1178 Compare December 11, 2020 13:35
@lzchen
Copy link
Contributor

lzchen commented Dec 11, 2020

Why does this PR depend on [#231]?

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

I am ok with these changes, @owais, tag me when the lint issues are fixed and I'll approve. 👍

scripts/eachdist.py Show resolved Hide resolved
@owais
Copy link
Contributor Author

owais commented Dec 11, 2020

I am ok with these changes, @owais, tag me when the lint issues are fixed and I'll approve. 👍

Might take some time given that the upgrade revealed tons of issues but will do, thanks.

@owais
Copy link
Contributor Author

owais commented Dec 11, 2020

Why does this PR depend on [#231]?

Doesn't hard depend on 231, just that there is duplicate work involved. Newer pylint reports exact issues as errors that 231 fixes so to make this PR pass, we either need to copy over changes from 231 or wait for it to merge and rebase.

@owais owais force-pushed the isort-and-black-be-friends branch 9 times, most recently from d3cbc30 to 97fa190 Compare December 11, 2020 21:51
@owais owais force-pushed the isort-and-black-be-friends branch 4 times, most recently from 6c62cc2 to afd8c5e Compare December 11, 2020 22:31
@owais
Copy link
Contributor Author

owais commented Dec 11, 2020

@ocelotl @lzchen This is ready now. Feel free to review whenever.

@@ -23,6 +23,7 @@ __pycache__
venv*/
.venv*/
opentelemetry-python-core*/
/opentelemetry-python-core
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between this and above? Maybe they can be combined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used symlink instead of checking out another copy of core which did not work with the existing rule. Probably could be combined but I didn't understand fully how others checkout the repo so didn't want to break anyone's flow.

Copy link
Member

Choose a reason for hiding this comment

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

might be better to move this to a .gitignore_global, if it's user-flow related.

But either not way not really worried about slightly bloating the gitignore. It may be good to add a comment to clarify this is for local dev scenarios.

@@ -98,7 +98,7 @@ async def _(param: str):
return {"message": param}

@app.get("/healthzz")
async def health():
async def health(): # pylint: disable=unused-variable
Copy link
Member

Choose a reason for hiding this comment

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

How did this even trigger pylint. Seems like the new version is very noisy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an unused var actually but there is no reason why it can't be named _ like the rest of the handlers defined inside this method. Updated.

Comment on lines +74 to +80
super-with-arguments, # temp-pylint-upgrade
isinstance-second-argument-not-valid-type, # temp-pylint-upgrade
raise-missing-from, # temp-pylint-upgrade
unused-argument, # temp-pylint-upgrade
protected-access, # temp-pylint-upgrade
super-init-not-called, # temp-pylint-upgrade
invalid-overridden-method, # temp-pylint-upgrade
Copy link
Member

Choose a reason for hiding this comment

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

what is is temp-pylint-upgrade?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a comment to note down the rules we disabled when we upgraded pylint. Intention is to come back and fix these lint issues and remove the ignore rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 70 to 72
wrong-import-order, # Leave this up to isort
bad-continuation, # Leave this up to black
line-too-long, # Leave this up to black
Copy link
Member

Choose a reason for hiding this comment

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

Can these all be removed after upgrade? Looking at the black docs, the config for compatibility should be pretty minimal https://black.readthedocs.io/en/stable/compatible_configs.html#pylint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't looked into it but I'm for removing rules if we can automate the fixes with black+isort. I really really miss gofmt :(

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -23,6 +23,7 @@ __pycache__
venv*/
.venv*/
opentelemetry-python-core*/
/opentelemetry-python-core
Copy link
Member

Choose a reason for hiding this comment

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

might be better to move this to a .gitignore_global, if it's user-flow related.

But either not way not really worried about slightly bloating the gitignore. It may be good to add a comment to clarify this is for local dev scenarios.

@owais owais force-pushed the isort-and-black-be-friends branch 6 times, most recently from d7ec26d to 90b836f Compare December 20, 2020 03:30
@owais
Copy link
Contributor Author

owais commented Dec 20, 2020

Fixed new lint issues. We need to merge this soon as changes to master keeps breaking this PR.

isort and black can be incompatible. Often isort re-writes files in a
way black doesn't like. It takes quite some time and manual effort to
make changes that satisfy both isort and black.

Fortunately, newer versions of isort support a black compatibility mode by setting
isort profile to "black". This makes isort order imports in a way that
is compatible with how black formats Python code. This PR configures
isort to use the black profile by default.
@owais owais force-pushed the isort-and-black-be-friends branch from 90b836f to ee0f81d Compare January 5, 2021 07:13
@lzchen lzchen merged commit 472f845 into open-telemetry:master Jan 5, 2021
@owais owais deleted the isort-and-black-be-friends branch January 6, 2021 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants