-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
Description
Description
RegexPattern crashes with UnboundLocalError when initialized with pattern=None and include=None, despite documentation stating that None is a valid pattern value for null operations.
Minimal Reproduction
from pathspec import RegexPattern
# This should create a null-operation pattern
pattern = RegexPattern(None, None)Traceback (most recent call last):
File "/data/src/test.py", line 4, in <module>
pattern = RegexPattern(None, None)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/py312/lib/python3.12/site-packages/pathspec/pattern.py", line 147, in __init__
self.regex: PatternHint = regex
^^^^^
UnboundLocalError: cannot access local variable 'regex' where it is not associated with a value
I think this is triggered when execution reaches self.regex = regex at the end, the uninitialized variable causes the error.
Environment
- pathspec version: 0.12.1
- Operating systems tested on: Linux