馃悰 fix(config): stop splitting factor names that look like ranges - #4053
Merged
gaborbernat merged 5 commits intoAug 31, 2026
Conversation
Two of the three alternatives in expand_ranges were unanchored, so any
digit-hyphen-digit run followed by a comma or a closing brace was expanded
as a generative range even in the middle of an ordinary factor name.
env_list = py313-django4-2,py313-django5-1 produced four environments
instead of two: the requested py313-django4-2 was never created, and two
junk environments named 3 and 2 appeared in its place.
The left-open alternative keeps its existing (?<= [{,] ) anchor. Giving it
the same lookbehind would break py3{10-11}-2,x by reading the trailing -2
as a left-open range and dropping it.
for more information, see https://pre-commit.ci
The two range alternatives each repeated the lookbehind, and neither said why digits carrying on a name are not a range. A non-capturing group over both keeps the group numbering `_expand` unpacks while stating the rule once. Dropping the dot from the guard left every test passing while `3.10-2` started expanding again, so the two added cases pin that half of it.
The reference lists which ranges expand and which do not, but never where one is looked for, so a name like py313-django4-2 coming apart read as arbitrary. The rule now sits beside the other non-expanding cases, and notes that it holds for -e as well as env_list.
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.
tox pulled an environment name ending in a digit, a hyphen and another digit apart, as though the tail were a generative range.
py313-django4-2never got created: tox madepy313-django4,3and2instead, and said nothing.py310-1,py310-2turned into more than three hundred environments, counting down from 310.A range now has to open a factor, so digits carrying on a name stay part of it. The documented range forms keep working, including one written after a comma and a space, and a version-shaped name such as
3.10-2survives too.The same expansion sits behind
-eon the command line, behind generative section names and behind factor conditions, so those pick up the fix as well.The left-open form
{-13}keeps its narrower rule. Widening it to match would swallow the trailing-2inpy3{10-11}-2,x.