-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Avoid infinite-propagation of inline comments when force-splitting imports #4074
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
renovate bot
referenced
this pull request
in ixm-one/pytest-cmake-presets
Apr 25, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.262` -> `^0.0.263` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/compatibility-slim/0.0.262)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/confidence-slim/0.0.262)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.263`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.263) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.262...v0.0.263) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`flake8-bugbear`] Add `pytest.raises(Exception)` support to B017 by [@​alanhdu](https://togithub.com/alanhdu) in [https://github.com/charliermarsh/ruff/pull/4052](https://togithub.com/charliermarsh/ruff/pull/4052) - \[`flake8-import-conventions`] Implement new rule `ICN003` to ban `from ... import ...` for selected modules by [@​edgarrmondragon](https://togithub.com/edgarrmondragon) in [https://github.com/charliermarsh/ruff/pull/4040](https://togithub.com/charliermarsh/ruff/pull/4040) - \[`pylint`] Implement PLE0302 `unexpected-special-method-signature` by [@​mccullocht](https://togithub.com/mccullocht) in [https://github.com/charliermarsh/ruff/pull/4075](https://togithub.com/charliermarsh/ruff/pull/4075) - \[`pep8-naming`] Ignore `N815` for `TypedDict` fields by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4066](https://togithub.com/charliermarsh/ruff/pull/4066) ##### Bug Fixes - Avoid `PYI015` for valid default value without annotation by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4043](https://togithub.com/charliermarsh/ruff/pull/4043) - Avoid infinite-propagation of inline comments when force-splitting imports by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4074](https://togithub.com/charliermarsh/ruff/pull/4074) - Fix SIM222 and SIM223 false positives and auto-fix by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4063](https://togithub.com/charliermarsh/ruff/pull/4063) - Unify positional and keyword arguments when checking for missing arguments in docstring by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4067](https://togithub.com/charliermarsh/ruff/pull/4067) - Avoid `RUF008` if field annotation is immutable by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4039](https://togithub.com/charliermarsh/ruff/pull/4039) - Increment priority should be (branch-local, global) by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4070](https://togithub.com/charliermarsh/ruff/pull/4070) - Ignore `ClassVar` annotation for `RUF008`, `RUF009` by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4081](https://togithub.com/charliermarsh/ruff/pull/4081) - Support --fix in watch mode by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4035](https://togithub.com/charliermarsh/ruff/pull/4035) #### New Contributors - [@​alanhdu](https://togithub.com/alanhdu) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4052](https://togithub.com/charliermarsh/ruff/pull/4052) - [@​pronoym99](https://togithub.com/pronoym99) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4055](https://togithub.com/charliermarsh/ruff/pull/4055) - [@​Secrus](https://togithub.com/Secrus) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4085](https://togithub.com/charliermarsh/ruff/pull/4085) - [@​madkinsz](https://togithub.com/madkinsz) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4084](https://togithub.com/charliermarsh/ruff/pull/4084) - [@​mccullocht](https://togithub.com/mccullocht) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4075](https://togithub.com/charliermarsh/ruff/pull/4075) **Full Changelog**: astral-sh/ruff@v0.0.262...v0.0.263 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41OC4yIiwidXBkYXRlZEluVmVyIjoiMzUuNTguMiJ9--> Signed-off-by: Renovate Bot <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot
referenced
this pull request
in allenporter/flux-local
Apr 27, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `==0.0.262` -> `==0.0.263` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/compatibility-slim/0.0.262)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/confidence-slim/0.0.262)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.263`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.263) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.262...v0.0.263) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`flake8-bugbear`] Add `pytest.raises(Exception)` support to B017 by [@​alanhdu](https://togithub.com/alanhdu) in [https://github.com/charliermarsh/ruff/pull/4052](https://togithub.com/charliermarsh/ruff/pull/4052) - \[`flake8-import-conventions`] Implement new rule `ICN003` to ban `from ... import ...` for selected modules by [@​edgarrmondragon](https://togithub.com/edgarrmondragon) in [https://github.com/charliermarsh/ruff/pull/4040](https://togithub.com/charliermarsh/ruff/pull/4040) - \[`pylint`] Implement PLE0302 `unexpected-special-method-signature` by [@​mccullocht](https://togithub.com/mccullocht) in [https://github.com/charliermarsh/ruff/pull/4075](https://togithub.com/charliermarsh/ruff/pull/4075) - \[`pep8-naming`] Ignore `N815` for `TypedDict` fields by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4066](https://togithub.com/charliermarsh/ruff/pull/4066) ##### Bug Fixes - Avoid `PYI015` for valid default value without annotation by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4043](https://togithub.com/charliermarsh/ruff/pull/4043) - Avoid infinite-propagation of inline comments when force-splitting imports by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4074](https://togithub.com/charliermarsh/ruff/pull/4074) - Fix SIM222 and SIM223 false positives and auto-fix by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4063](https://togithub.com/charliermarsh/ruff/pull/4063) - Unify positional and keyword arguments when checking for missing arguments in docstring by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4067](https://togithub.com/charliermarsh/ruff/pull/4067) - Avoid `RUF008` if field annotation is immutable by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4039](https://togithub.com/charliermarsh/ruff/pull/4039) - Increment priority should be (branch-local, global) by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4070](https://togithub.com/charliermarsh/ruff/pull/4070) - Ignore `ClassVar` annotation for `RUF008`, `RUF009` by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4081](https://togithub.com/charliermarsh/ruff/pull/4081) - Support --fix in watch mode by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4035](https://togithub.com/charliermarsh/ruff/pull/4035) #### New Contributors - [@​alanhdu](https://togithub.com/alanhdu) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4052](https://togithub.com/charliermarsh/ruff/pull/4052) - [@​pronoym99](https://togithub.com/pronoym99) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4055](https://togithub.com/charliermarsh/ruff/pull/4055) - [@​Secrus](https://togithub.com/Secrus) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4085](https://togithub.com/charliermarsh/ruff/pull/4085) - [@​madkinsz](https://togithub.com/madkinsz) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4084](https://togithub.com/charliermarsh/ruff/pull/4084) - [@​mccullocht](https://togithub.com/mccullocht) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4075](https://togithub.com/charliermarsh/ruff/pull/4075) **Full Changelog**: astral-sh/ruff@v0.0.262...v0.0.263 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41OC4yIiwidXBkYXRlZEluVmVyIjoiMzUuNTguMiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot
referenced
this pull request
in allenporter/pyrainbird
Apr 27, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `==0.0.262` -> `==0.0.263` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/compatibility-slim/0.0.262)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.263/confidence-slim/0.0.262)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.263`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.263) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.262...v0.0.263) <!-- Release notes generated using configuration in .github/release.yml at main --> ##### What's Changed ##### Rules - \[`flake8-bugbear`] Add `pytest.raises(Exception)` support to B017 by [@​alanhdu](https://togithub.com/alanhdu) in [https://github.com/charliermarsh/ruff/pull/4052](https://togithub.com/charliermarsh/ruff/pull/4052) - \[`flake8-import-conventions`] Implement new rule `ICN003` to ban `from ... import ...` for selected modules by [@​edgarrmondragon](https://togithub.com/edgarrmondragon) in [https://github.com/charliermarsh/ruff/pull/4040](https://togithub.com/charliermarsh/ruff/pull/4040) - \[`pylint`] Implement PLE0302 `unexpected-special-method-signature` by [@​mccullocht](https://togithub.com/mccullocht) in [https://github.com/charliermarsh/ruff/pull/4075](https://togithub.com/charliermarsh/ruff/pull/4075) - \[`pep8-naming`] Ignore `N815` for `TypedDict` fields by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4066](https://togithub.com/charliermarsh/ruff/pull/4066) ##### Bug Fixes - Avoid `PYI015` for valid default value without annotation by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4043](https://togithub.com/charliermarsh/ruff/pull/4043) - Avoid infinite-propagation of inline comments when force-splitting imports by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4074](https://togithub.com/charliermarsh/ruff/pull/4074) - Fix SIM222 and SIM223 false positives and auto-fix by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4063](https://togithub.com/charliermarsh/ruff/pull/4063) - Unify positional and keyword arguments when checking for missing arguments in docstring by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4067](https://togithub.com/charliermarsh/ruff/pull/4067) - Avoid `RUF008` if field annotation is immutable by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4039](https://togithub.com/charliermarsh/ruff/pull/4039) - Increment priority should be (branch-local, global) by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4070](https://togithub.com/charliermarsh/ruff/pull/4070) - Ignore `ClassVar` annotation for `RUF008`, `RUF009` by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4081](https://togithub.com/charliermarsh/ruff/pull/4081) - Support --fix in watch mode by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4035](https://togithub.com/charliermarsh/ruff/pull/4035) ##### New Contributors - [@​alanhdu](https://togithub.com/alanhdu) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4052](https://togithub.com/charliermarsh/ruff/pull/4052) - [@​pronoym99](https://togithub.com/pronoym99) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4055](https://togithub.com/charliermarsh/ruff/pull/4055) - [@​Secrus](https://togithub.com/Secrus) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4085](https://togithub.com/charliermarsh/ruff/pull/4085) - [@​madkinsz](https://togithub.com/madkinsz) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4084](https://togithub.com/charliermarsh/ruff/pull/4084) - [@​mccullocht](https://togithub.com/mccullocht) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4075](https://togithub.com/charliermarsh/ruff/pull/4075) **Full Changelog**: astral-sh/ruff@v0.0.262...v0.0.263 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/pyrainbird). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41OC4yIiwidXBkYXRlZEluVmVyIjoiMzUuNTguMiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
In #3521, we modified our
force-single-line = true
behavior to preserve inline comments on imports when splitting multi-member imports into multiple single-member imports. This is useful, since those inline comments are often suppressions that we want to propagate and preserve. For example given:After #3521, we reformatted that (with
force-single-line = true
) to:This is all well and good, but #4062 pointed out a case in which this comment propagate caused us to infinitely duplicate those inline comments in certain cases, leading to an exponential blowup.
Given:
After one round of fixing, we'd produce:
On the next pass, we'd recombine these imports, and notice that
from mypackage.subpackage import items
is missing the inline comment# long comment that seems to be a problem
, which is instead attached to the member importitems
. When we then force-split these imports, we'd duplicate the comment:On the next pass, we'd find two inline comments, and we'd duplicate them on each import statement.
Anyway, the fix here is to avoid ever combining separate import statements if they're going to eventually be split. Previously, we'd combine those statements during normalization, then split them up at a later pass via a dedicated method. Instead, if we avoid combining imports and handle the splitting during normalization itself, we avoid all of these issues.
Closes #4062.