File tree Expand file tree Collapse file tree
pathspec/patterns/gitignore Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,6 +133,14 @@ def pattern_to_regex(
133133 """
134134 Convert the pattern into a regular expression.
135135
136+ Raises :class:`~pathspec.patterns.gitignore.base.GitIgnorePatternError`
137+ for invalid patterns, including a bare ``!`` (also when followed by
138+ unescaped trailing spaces) or an unmatched trailing backslash. Unlike
139+ blank lines and comments, these inputs do not return ``(None, None)``.
140+ Git accepts these lines without a diagnostic, so callers reading ignore
141+ files must be prepared to handle this exception even when Git accepts
142+ the file.
143+
136144 *pattern* (:class:`str` or :class:`bytes`) is the pattern to convert into a
137145 regular expression.
138146
Original file line number Diff line number Diff line change @@ -167,6 +167,14 @@ def pattern_to_regex(
167167 """
168168 Convert the pattern into a regular expression.
169169
170+ Raises :class:`~pathspec.patterns.gitignore.base.GitIgnorePatternError`
171+ for invalid patterns, including a bare ``!`` (also when followed by
172+ unescaped trailing spaces) or an unmatched trailing backslash. Unlike
173+ blank lines and comments, these inputs do not return ``(None, None)``.
174+ Git accepts these lines without a diagnostic, so callers reading ignore
175+ files must be prepared to handle this exception even when Git accepts
176+ the file.
177+
170178 *pattern* (:class:`str` or :class:`bytes`) is the pattern to convert into a
171179 regular expression.
172180
You can’t perform that action at this time.
0 commit comments