Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or 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
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.
With
split_on_trailing_comma, isort isn't idempotent when an aliased import splits one module's names into several statements. Running--profile appnexusover the CPython 3.12 stdlib,csv.pyandssl.pychange again on the second run. Minimal case:The first run gives
from _csv import __doc__, the aliased import, and the remaining names wrapped with a trailing comma. On the second run,parserecords the trailing comma for the whole_csvmodule, so_build_grouped_from_importsalso explodes the single-namefrom _csv import __doc__intofrom _csv import (\n __doc__,\n).trailing_commasnow maps each module to the names of the statements that had the trailing comma. A grouped statement is only exploded for that reason if it contains one of those names. When a module ends up as a single statement (the usual case) the result is the same as before.Added a regression test with the case above. It fails on
mainand passes here. The unit tests give the same results as onmain(two tests fail locally withFileNotFoundErroron both). ruff, mypy and flake8 are clean. With the change, running every built-in profile twice over the 3.12 stdlib produces no further changes.