Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Ensure that split_on_trailing_comma works with as imports#2340

Merged
staticdev merged 5 commits intomainfrom
fix-split-trailing
Jan 20, 2025
Merged

Ensure that split_on_trailing_comma works with as imports#2340
staticdev merged 5 commits intomainfrom
fix-split-trailing

Conversation

@DanielNoord
Copy link
Member

Closes #2338

Took the tests as recommended in #2339

I don't think we should fix the tests by disabling the new profile flag, that would mean that our tests work but anybody using the profile would still get broken imports.
Instead, let's try to fix config.split_on_trailing_comma itself. I believe this does this.

@codecov
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.12%. Comparing base (4ae58fa) to head (b96c0ea).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2340   +/-   ##
=======================================
  Coverage   99.12%   99.12%           
=======================================
  Files          40       40           
  Lines        3096     3096           
  Branches      787      787           
=======================================
  Hits         3069     3069           
  Misses         15       15           
  Partials       12       12           

Comment on lines +5580 to +5582
test_input = "from lib import (a as b,)"
expected_output = """from lib import a as b
"""
Copy link
Contributor

@matthewhughes934 matthewhughes934 Jan 18, 2025

Choose a reason for hiding this comment

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

what's expected for multiple as imports an a trailing comma, e.g. from lib import (a as b, c as d,)?

from lib import a as b
from lib import c as d

or

from lib import (
    a as b,
    c as d,
)

Copy link
Member Author

Choose a reason for hiding this comment

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

Current code will do:

from lib import a as b
from lib import c as d

@staticdev
Copy link
Collaborator

@DanielNoord this Django integration test still failimg, did you have time to check if it is related or not to these black changes?

@DanielNoord
Copy link
Member Author

Like I told you in the message: by changing the black style django is no longer conformant. The tests will fail until we release and they reformat their repository.

Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

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

@DanielNoord ok, then we can temporarily disable it and put a comment to re-enable when they upgrade to 6.0.0+

@DanielNoord DanielNoord requested a review from staticdev January 20, 2025 07:56
@DanielNoord
Copy link
Member Author

@staticdev There we go.

I double checked and the offending line is:
https://github.com/django/django/blob/ec8cbea91ed6362d43298caa43f3d868452f7efa/django/db/backends/postgresql/compiler.py#L6

django does indeed use the black profile:
https://github.com/django/django/blob/ec8cbea91ed6362d43298caa43f3d868452f7efa/pyproject.toml#L61
Which surprised me considering there is a django profile as well...

I think this is fine to merge now :)

Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

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

@DanielNoord LGTM, thanks.

@staticdev staticdev merged commit bced410 into main Jan 20, 2025
38 checks passed
@staticdev staticdev deleted the fix-split-trailing branch January 20, 2025 11:20
@nessita
Copy link

nessita commented Jan 28, 2025

Thank you for considering Django in this change. As you can see in the linked PR #19109 this is forcing a reformat which does not seem correct. What do you think?

- from django.db.models.sql.compiler import SQLUpdateCompiler
+ from django.db.models.sql.compiler import (
+     SQLUpdateCompiler,
+ )

@DanielNoord
Copy link
Member Author

That was raised as an issue in #2352.

Current status is: we're still determining whether this is a bug and are trying to see if we can provide a fix.

736-c41-2c1-e464fc974 added a commit to Swiss-Armed-Forces/Loom that referenced this pull request Feb 20, 2026
This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [isort](https://github.com/PyCQA/isort) ([changelog](https://github.com/PyCQA/isort/releases)) | dev | major | `^5.13.2` → `^7.0.0` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/PyCQA/isort/badge)](https://securityscorecards.dev/viewer/?uri=github.com/PyCQA/isort) |

---

### Release Notes

<details>
<summary>PyCQA/isort (isort)</summary>

### [`v7.0.0`](https://github.com/PyCQA/isort/releases/tag/7.0.0)

[Compare Source](PyCQA/isort@6.1.0...7.0.0)

#### Changes

#### 💥 Breaking Changes

- Drop support for Python 3.9 ([#&#8203;2430](PyCQA/isort#2430)) [@&#8203;DanielNoord](https://github.com/DanielNoord)

#### 🚀 Features

- Show absolute paths in skipped file messages ([#&#8203;2416](PyCQA/isort#2416)) [@&#8203;pranlawate](https://github.com/pranlawate)

#### 🪲 Fixes

- Some fixes for Python 3.14 ([#&#8203;2433](PyCQA/isort#2433)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Test on `3.14` and fix any bugs ([#&#8203;2425](PyCQA/isort#2425)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Update CHANGELOG.md + Fix Formatting and Grammar ([#&#8203;2419](PyCQA/isort#2419)) [@&#8203;lukbrew25](https://github.com/lukbrew25)
- Fix output of hanging indent for long lines with noqa ([#&#8203;2407](PyCQA/isort#2407)) [@&#8203;matan1008](https://github.com/matan1008)

#### :construction\_worker: Continuous Integration

- Format with `ruff` instead of `black` ([#&#8203;2432](PyCQA/isort#2432)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Target 3.10 for `ruff` ([#&#8203;2431](PyCQA/isort#2431)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Update development dependencies to latest version ([#&#8203;2426](PyCQA/isort#2426)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- docs: update pre-commit examples to version 6.1.0 ([#&#8203;2413](PyCQA/isort#2413)) [@&#8203;pranlawate](https://github.com/pranlawate)
- Small cleanup for developer environment ([#&#8203;2418](PyCQA/isort#2418)) [@&#8203;DanielNoord](https://github.com/DanielNoord)

#### 📦 Dependencies

- Bump actions/setup-python from 5 to 6 in the github-actions group ([#&#8203;2411](PyCQA/isort#2411)) @&#8203;[dependabot\[bot\]](https://github.com/apps/dependabot)

### [`v6.1.0`](https://github.com/PyCQA/isort/blob/HEAD/CHANGELOG.md#610-October-1-2025)

[Compare Source](PyCQA/isort@6.0.1...6.1.0)

- Add python 3.14 classifier and badge ([#&#8203;2409](PyCQA/isort#2409)) [@&#8203;staticdev](https://github.com/staticdev)
  - Drop use of non-standard pkg\_resources API ([#&#8203;2405](PyCQA/isort#2405)) [@&#8203;dvarrazzo](https://github.com/dvarrazzo)

### [`v6.0.1`](https://github.com/PyCQA/isort/blob/HEAD/CHANGELOG.md#601-Febuary-26-2025)

[Compare Source](PyCQA/isort@6.0.0...6.0.1)

- Add OSError handling in find\_imports\_in\_file ([#&#8203;2331](PyCQA/isort#2331)) [@&#8203;kobarity](https://github.com/kobarity)

### [`v6.0.0`](https://github.com/PyCQA/isort/blob/HEAD/CHANGELOG.md#600-January-27-2025)

[Compare Source](PyCQA/isort@5.13.2...6.0.0)

- Remove support for Python 3.8 ([#&#8203;2327](PyCQA/isort#2327)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
  - Python 3.13 support ([#&#8203;2306](PyCQA/isort#2306)) [@&#8203;mayty](https://github.com/mayty)
  - Speed up exists\_case\_sensitive calls ([#&#8203;2264](PyCQA/isort#2264)) [@&#8203;correctmost](https://github.com/correctmost)
  - Ensure that split\_on\_trailing\_comma works with as imports ([#&#8203;2340](PyCQA/isort#2340)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
  - Black profile: enable magic comma ([#&#8203;2236](PyCQA/isort#2236)) [@&#8203;MrMino](https://github.com/MrMino)
  - Update line\_length and single\_line\_exclusions in google profile ([#&#8203;2149](PyCQA/isort#2149)) [@&#8203;jagapiou](https://github.com/jagapiou)
  - Allow --diff to be used with --jobs ([#&#8203;2302](PyCQA/isort#2302)) [@&#8203;mnakama](https://github.com/mnakama)
  - Fix wemake profile to have correct character limit ([#&#8203;2241](PyCQA/isort#2241)) [@&#8203;sobolevn](https://github.com/sobolevn)
  - Fix sort\_reexports code mangling ([#&#8203;2283](PyCQA/isort#2283)) [@&#8203;Helveg](https://github.com/Helveg)
  - Fix correct group by package tokenization ([#&#8203;2136](PyCQA/isort#2136)) [@&#8203;glasnt](https://github.com/glasnt)

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yLjQiLCJ1cGRhdGVkSW5WZXIiOiI0My4yNS43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

See merge request swiss-armed-forces/cyber-command/cea/loom!284

Co-authored-by: Loom MR Pipeline Trigger <group_103951964_bot_9504bb8dead6d4e406ad817a607f24be@noreply.gitlab.com>
Co-authored-by: shrewd-laidback palace <shrewd-laidback-palace-736-c41-2c1-e464fc974@swiss-armed-forces-open-source.ch>
736-c41-2c1-e464fc974 added a commit to Swiss-Armed-Forces/Loom that referenced this pull request Feb 20, 2026
chore(deps): update isort (major)

This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [isort](https://github.com/PyCQA/isort) ([changelog](https://github.com/PyCQA/isort/releases)) | dev | major | `^5.13.2` → `^7.0.0` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/PyCQA/isort/badge)](https://securityscorecards.dev/viewer/?uri=github.com/PyCQA/isort) |

---

### Release Notes

<details>
<summary>PyCQA/isort (isort)</summary>

### [`v7.0.0`](https://github.com/PyCQA/isort/releases/tag/7.0.0)

[Compare Source](PyCQA/isort@6.1.0...7.0.0)

#### Changes

#### 💥 Breaking Changes

- Drop support for Python 3.9 ([#&#8203;2430](PyCQA/isort#2430)) [@&#8203;DanielNoord](https://github.com/DanielNoord)

#### 🚀 Features

- Show absolute paths in skipped file messages ([#&#8203;2416](PyCQA/isort#2416)) [@&#8203;pranlawate](https://github.com/pranlawate)

#### 🪲 Fixes

- Some fixes for Python 3.14 ([#&#8203;2433](PyCQA/isort#2433)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Test on `3.14` and fix any bugs ([#&#8203;2425](PyCQA/isort#2425)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Update CHANGELOG.md + Fix Formatting and Grammar ([#&#8203;2419](PyCQA/isort#2419)) [@&#8203;lukbrew25](https://github.com/lukbrew25)
- Fix output of hanging indent for long lines with noqa ([#&#8203;2407](PyCQA/isort#2407)) [@&#8203;matan1008](https://github.com/matan1008)

#### :construction\_worker: Continuous Integration

- Format with `ruff` instead of `black` ([#&#8203;2432](PyCQA/isort#2432)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Target 3.10 for `ruff` ([#&#8203;2431](PyCQA/isort#2431)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- Update development dependencies to latest version ([#&#8203;2426](PyCQA/isort#2426)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
- docs: update pre-commit examples to version 6.1.0 ([#&#8203;2413](PyCQA/isort#2413)) [@&#8203;pranlawate](https://github.com/pranlawate)
- Small cleanup for developer environment ([#&#8203;2418](PyCQA/isort#2418)) [@&#8203;DanielNoord](https://github.com/DanielNoord)

#### 📦 Dependencies

- Bump actions/setup-python from 5 to 6 in the github-actions group ([#&#8203;2411](PyCQA/isort#2411)) @&#8203;[dependabot\[bot\]](https://github.com/apps/dependabot)

### [`v6.1.0`](https://github.com/PyCQA/isort/blob/HEAD/CHANGELOG.md#610-October-1-2025)

[Compare Source](PyCQA/isort@6.0.1...6.1.0)

- Add python 3.14 classifier and badge ([#&#8203;2409](PyCQA/isort#2409)) [@&#8203;staticdev](https://github.com/staticdev)
  - Drop use of non-standard pkg\_resources API ([#&#8203;2405](PyCQA/isort#2405)) [@&#8203;dvarrazzo](https://github.com/dvarrazzo)

### [`v6.0.1`](https://github.com/PyCQA/isort/blob/HEAD/CHANGELOG.md#601-Febuary-26-2025)

[Compare Source](PyCQA/isort@6.0.0...6.0.1)

- Add OSError handling in find\_imports\_in\_file ([#&#8203;2331](PyCQA/isort#2331)) [@&#8203;kobarity](https://github.com/kobarity)

### [`v6.0.0`](https://github.com/PyCQA/isort/blob/HEAD/CHANGELOG.md#600-January-27-2025)

[Compare Source](PyCQA/isort@5.13.2...6.0.0)

- Remove support for Python 3.8 ([#&#8203;2327](PyCQA/isort#2327)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
  - Python 3.13 support ([#&#8203;2306](PyCQA/isort#2306)) [@&#8203;mayty](https://github.com/mayty)
  - Speed up exists\_case\_sensitive calls ([#&#8203;2264](PyCQA/isort#2264)) [@&#8203;correctmost](https://github.com/correctmost)
  - Ensure that split\_on\_trailing\_comma works with as imports ([#&#8203;2340](PyCQA/isort#2340)) [@&#8203;DanielNoord](https://github.com/DanielNoord)
  - Black profile: enable magic comma ([#&#8203;2236](PyCQA/isort#2236)) [@&#8203;MrMino](https://github.com/MrMino)
  - Update line\_length and single\_line\_exclusions in google profile ([#&#8203;2149](PyCQA/isort#2149)) [@&#8203;jagapiou](https://github.com/jagapiou)
  - Allow --diff to be used with --jobs ([#&#8203;2302](PyCQA/isort#2302)) [@&#8203;mnakama](https://github.com/mnakama)
  - Fix wemake profile to have correct character limit ([#&#8203;2241](PyCQA/isort#2241)) [@&#8203;sobolevn](https://github.com/sobolevn)
  - Fix sort\_reexports code mangling ([#&#8203;2283](PyCQA/isort#2283)) [@&#8203;Helveg](https://github.com/Helveg)
  - Fix correct group by package tokenization ([#&#8203;2136](PyCQA/isort#2136)) [@&#8203;glasnt](https://github.com/glasnt)

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yLjQiLCJ1cGRhdGVkSW5WZXIiOiI0My4yNS43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

See merge request swiss-armed-forces/cyber-command/cea/loom!284

Co-authored-by: Loom MR Pipeline Trigger <group_103951964_bot_9504bb8dead6d4e406ad817a607f24be@noreply.gitlab.com>
Co-authored-by: open-source Pipeline <group_90701827_bot_ed04ae348bc5f40af9966fb8b6867e99@noreply.gitlab.com>
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.

Fix regressions from #2236

4 participants