ruff: `ruff format` or `ruff check` returns "nested alternate groups are not allowed" error

I am attempting to exclude this dir from inspection:

extend-exclude = [
    "__pycache__",
]

but I am getting:

$ python3 -m ruff format .
ruff failed
  Cause: error parsing glob '/Users/me/project/{{cookiecutter.project_dirname}}/__pycache__': nested alternate groups are not allowed

Any ideas?

On a side note, according to this experiment, this syntax should be valid

extend-exclude = [
    "[{][{]cookiecutter[.]project_dirname[}][}]/__pycache__",
]

but it still gets me the error above.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 9
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@lucasfijen Thank you so much! I cloned the repo and can now reproduce!

Any update on this?

From the description it looks like a bug. What you could do though is omit that directory entirely:

extend-exclude = [
    "[{][{]cookiecutter.project_dirname[}][}]",
]

@ntBre as promised I created a repository to showcase the issue here.

Hi @charliermarsh, you might be already aware of this, but this is occurring with the base ruff command as well, not just with ruff format.

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:)

We have the same issue in combination with cookiecutter 😕 The curly brackets seem to be a problem.

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.