|
10 | 10 |
|
11 | 11 | from . import utils
|
12 | 12 |
|
13 |
| - |
14 |
| -if sys.version_info >= (3, 7): #PY37+ |
15 |
| - re_pattern_type = re.Pattern |
16 |
| - if ty.TYPE_CHECKING: |
17 |
| - re_pattern_t = re.Pattern[ty.AnyStr] |
18 |
| - else: |
19 |
| - re_pattern_t = re.Pattern |
20 |
| -else: #PY36- |
21 |
| - re_pattern_t = re_pattern_type = type(re.compile("")) |
22 |
| - |
| 13 | +if ty.TYPE_CHECKING: |
| 14 | + re_pattern_t = re.Pattern[ty.AnyStr] |
| 15 | +else: |
| 16 | + re_pattern_t = re.Pattern |
23 | 17 |
|
24 | 18 | # Windows does not have os.O_DIRECTORY
|
25 | 19 | O_DIRECTORY: int = getattr(os, "O_DIRECTORY", 0)
|
26 | 20 |
|
27 |
| - |
28 | 21 | # Neither Windows nor MacOS have os.fwalk even through Python 3.9
|
29 | 22 | HAVE_FWALK: bool = hasattr(os, "fwalk")
|
30 | 23 | HAVE_FWALK_BYTES = HAVE_FWALK and sys.version_info >= (3, 7)
|
@@ -394,7 +387,7 @@ def matcher_from_spec(spec: match_spec_t[ty.AnyStr], *, # type: ignore[misc] #
|
394 | 387 |
|
395 | 388 | if spec is None:
|
396 | 389 | return MATCH_ALL # mypy bug: This should cause a type error but does not?
|
397 |
| - elif isinstance(spec, re_pattern_type): |
| 390 | + elif isinstance(spec, re.Pattern): |
398 | 391 | return ReMatcher(spec)
|
399 | 392 | elif isinstance(spec, (str, bytes)):
|
400 | 393 | return GlobMatcher(spec, period_special=period_special)
|
@@ -510,8 +503,6 @@ def __init__(
|
510 | 503 | os.stat(directory_str)
|
511 | 504 |
|
512 | 505 | # … and possibly open it as a FD if this is supported by the platform
|
513 |
| - # |
514 |
| - # Note: `os.fwalk` support for binary paths was only added in 3.7+. |
515 | 506 | directory_str_or_fd: ty.Union[ty.AnyStr, int] = directory_str
|
516 | 507 | if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES):
|
517 | 508 | fd = os.open(directory_str, os.O_RDONLY | O_DIRECTORY)
|
|
0 commit comments