Repository navigation
ruff format or ruff check returns "nested alternate groups are not allowed" error #9381
Description
Activity
- addedbugAn issue describing something that isn't working, or a PR that fixes a bugAn issue describing something that isn't working, or a PR that fixes a bug
on Jan 4, 2024 To clarify, the whole config is:
extend-exclude = [ "__pycache__", ]
Is that right? And you're running from the
/Users/me/project/{{cookiecutter.project_dirname}}directory?The whole config is:
extend-exclude = [ "__pycache__", ".vscode*", ]and I am running from
Users/me/project/.{{cookiecutter.project_dirname}}is a subdir in that path.Got it, thanks!
Got it, thanks!
Thank YOU! Are you able to confirm it is a bug and not something I have to tweak on my side?
From the description it looks like a bug. What you could do though is omit that directory entirely:
extend-exclude = [ "[{][{]cookiecutter.project_dirname[}][}]", ]
Reacted by Markus Bilz, maoding and William Huster(Taken from: #7959 (comment))
From the description it looks like a bug. What you could do though is omit that directory entirely:
extend-exclude = [ "[{][{]cookiecutter.project_dirname[}][}]", ]
Unfortunately I need to target specific subdirs of that unusual dir, so that's not viable for me.
Reacted by Marius BurfeyHi @charliermarsh, you might be already aware of this, but this is occurring with the base
ruffcommand as well, not just withruff format.Reacted by Micha Reiser and Ronny V.- addedcliRelated to the command-line interface of Ruff or tyRelated to the command-line interface of Ruff or tyconfigurationRelated to settings and configuration of Ruff or tyRelated to settings and configuration of Ruff or tyand removedcliRelated to the command-line interface of Ruff or tyRelated to the command-line interface of Ruff or ty
on Jan 8, 2024 - changed the title
[-]`ruff format` returns "nested alternate groups are not allowed" error[/-][+]`ruff format` or `ruff check` returns "nested alternate groups are not allowed" error[/+]on Jan 8, 2024 We have the same issue in combination with cookiecutter 😕 The curly brackets seem to be a problem.
Reacted by Rafael Weingartner-OrtnerAny update on this?
Reacted by Niccolò Mineo, Aaron Sewall and EmCeeEsYep I'm running in exactly the same in combination with cookiecutter.
In my case it's with the per-file-ignores, but that probably translates to the same underlying issueI have a folder structure:
. ├── pyproject.toml └── {{ cookiecutter.repo_name }} ├── tests │ └── maintest.py ├── main.py └── pyproject.tomlWhere my pyproject.toml contains this setting that is causing the issue, removing this line fixes the error
[tool.ruff.lint.per-file-ignores] "tests/*" = ["F811"]
Then running ruff from the root using
cookiecutter format .will cause:ruff failed Cause: error parsing glob '/workspaces/reponame/{{cookiecutter.repo_name}}/tests/*': nested alternate groups are not allowedDoes anyone have a link to a repo or gist where I could reproduce this? I'm trying to take a look but having some trouble reproducing it locally with this file tree:
. ├── ruff.toml └── {{cookiecutter.project_dirname}} ├── __pycache__ │ └── try.py └── try.pyWe use globset for most of our path globs, which has the comment "Nesting {...} is not currently allowed" in the docs, so I think the curly braces are definitely the problem.
For now the best workarounds are still "escaping" the curly braces with square brackets (
[{]) or backslashes (\{, if you're not on Windows), but I agree that it would be nice if we had some heuristics for detecting this automatically.Thank you for taking your time to looking into it! This monday I should have some time to setup a small example repo for you to make it reproducible.
The issue with this cookiecutter example is that the glob part with the curly brackets is not included in the ignore list field, as that part should be relative paths. However the curly brackets part are included when running ruff from the root (for this example we might need a second pyproject.toml above the ccokiecutter.project_dirname to get it reproduced.
This explanation might not be very clear, I'll work on an example repo for you:)
Reacted by Brent Westbrook@lucasfijen Thank you so much! I cloned the repo and can now reproduce!
Reacted by lucasfijen, Ronny V. and Valentin Oliver Melberg Loftsson- added a commit that references this issue
on Mar 3, 2025 - added a commit that references this issue
on May 1, 2026
I am attempting to exclude this dir from inspection:
but I am getting:
Any ideas?
On a side note, according to this experiment, this syntax should be valid
but it still gets me the error above.