Skip to content

ValueError(f"{patterns=!r} cannot be empty.") when using black #100

@barv-jfrog

Description

@barv-jfrog

Hi, we are using black like this:

black <folder_name> '(<dir_a>|<dir_b>)'

and now we are getting this traceback:

Traceback (most recent call last):
  File "venv/bin/black", line 7, in <module>
    sys.exit(patched_main())
  File "src/black/__init__.py", line 1650, in patched_main
  File "venv/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "venv/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "venv/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "venv/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "src/black/__init__.py", line 676, in main
  File "src/black/__init__.py", line 805, in get_sources
  File "venv/lib/python3.10/site-packages/black/files.py", line 249, in get_gitignore
    return PathSpec.from_lines("gitwildmatch", lines)
  File "venv/lib/python3.10/site-packages/pathspec/pathspec.py", line 259, in from_lines
    return cls(patterns, backend=backend, _test_backend_factory=_test_backend_factory)
  File "venv/lib/python3.10/site-packages/pathspec/pathspec.py", line 80, in __init__
    use_backend = self._make_backend(backend, patterns)
  File "venv/lib/python3.10/site-packages/pathspec/pathspec.py", line 279, in _make_backend
    return make_pathspec_backend(name, patterns)
  File "venv/lib/python3.10/site-packages/pathspec/_backends/agg.py", line 100, in make_pathspec_backend
    return Re2PsBackend(cast(Sequence[RegexPattern], patterns))
  File "venv/lib/python3.10/site-packages/pathspec/_backends/re2/pathspec.py", line 61, in __init__
    raise ValueError(f"{patterns=!r} cannot be empty.")
ValueError: patterns=[] cannot be empty.

Versions:
pathspec 1.0.0
black 25.12.0

This is a new error that appears after the latest pathspec upgrade to 1.0.0.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions