Skip to content

Commit 152cdc7

Browse files
committed
fix: don't forbid plus signs in file names. #1513
1 parent 31513b4 commit 152cdc7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGES.rst

+4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ development at the same time, such as 4.5.x and 5.0.
2020
Unreleased
2121
----------
2222

23+
- File pattern rules were too strict, forbidding plus signs and curly braces in
24+
directory and file names. This is now fixed, closing `issue 1513`_.
25+
2326
- The PyPy wheel now installs on PyPy 3.7, 3.8, and 3.9, closing `issue 1510`_.
2427

2528
.. _issue 1510: https://github.com/nedbat/coveragepy/issues/1510
29+
.. _issue 1513: https://github.com/nedbat/coveragepy/issues/1513
2630

2731

2832
.. _changes_7-0-0:

coverage/files.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def sep(s):
325325
(r"\?", r"[^/\\\\]"), # ? matches one non slash-like
326326
(r"\[.*?\]", r"\g<0>"), # [a-f] matches [a-f]
327327
(r"[a-zA-Z0-9_-]+", r"\g<0>"), # word chars match themselves
328-
(r"[\[\]+{}]", None), # Can't have regex special chars
328+
(r"[\[\]]", None), # Can't have single square brackets
329329
(r".", r"\\\g<0>"), # Anything else is escaped to be safe
330330
]]
331331

tests/test_files.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,18 @@ def globs_to_regex_params(
230230
matches=["foo", "hello/foo", "hi/there/foo"],
231231
nomatches=["foob", "hello/foob", "hello/Foo"],
232232
),
233+
globs_to_regex_params(
234+
["a+b/foo*", "x{y}z/foo*"],
235+
matches=["a+b/foo", "a+b/foobar", "x{y}z/foobar"],
236+
nomatches=["aab/foo", "ab/foo", "xyz/foo"],
237+
),
233238
]))
234239
)
235240
def test_globs_to_regex(patterns, case_insensitive, partial, text, result):
236241
regex = globs_to_regex(patterns, case_insensitive=case_insensitive, partial=partial)
242+
print(patterns)
243+
print(regex)
244+
print(text)
237245
assert bool(regex.match(text)) == result
238246

239247

@@ -243,8 +251,6 @@ def test_globs_to_regex(patterns, case_insensitive, partial, text, result):
243251
("*****/foo.py", "*****"),
244252
("Hello]there", "]"),
245253
("Hello[there", "["),
246-
("Hello+there", "+"),
247-
("{a,b}c", "{"),
248254
("x/a**/b.py", "a**"),
249255
("x/abcd**/b.py", "abcd**"),
250256
("x/**a/b.py", "**a"),

0 commit comments

Comments
 (0)