|
18 | 18 | # This will get inlined if/when PyCharm no longer flags typing.AnyStr.
|
19 | 19 | AnyStr = ty.TypeVar('AnyStr', bytes, str)
|
20 | 20 |
|
21 |
| -if sys.version_info >= (3, 7): #PY37+ |
22 |
| - re_pattern_type = re.Pattern |
23 |
| - if ty.TYPE_CHECKING: |
24 |
| - re_pattern_t = re.Pattern[AnyStr] |
25 |
| - else: |
26 |
| - re_pattern_t = re.Pattern |
27 |
| -else: #PY36- |
28 |
| - re_pattern_t = re_pattern_type = type(re.compile("")) |
29 |
| - |
| 21 | +if ty.TYPE_CHECKING: |
| 22 | + re_pattern_t = re.Pattern[AnyStr] |
| 23 | +else: |
| 24 | + re_pattern_t = re.Pattern |
30 | 25 |
|
31 | 26 | # Windows does not have os.O_DIRECTORY
|
32 | 27 | O_DIRECTORY: int = getattr(os, "O_DIRECTORY", 0)
|
33 | 28 |
|
34 |
| - |
35 | 29 | # Neither Windows nor MacOS have os.fwalk even through Python 3.9
|
36 | 30 | HAVE_FWALK: bool = hasattr(os, "fwalk")
|
37 | 31 | HAVE_FWALK_BYTES = HAVE_FWALK and sys.version_info >= (3, 7)
|
@@ -483,7 +477,7 @@ def _matcher_from_spec(spec: match_spec_t[AnyStr], *,
|
483 | 477 |
|
484 | 478 | def _recursive_matcher_from_spec(spec: match_spec_t[AnyStr], *,
|
485 | 479 | period_special: bool = True) -> Matcher[AnyStr]:
|
486 |
| - if isinstance(spec, re_pattern_type): |
| 480 | + if isinstance(spec, re.Pattern): |
487 | 481 | return ReMatcher(spec)
|
488 | 482 | elif isinstance(spec, (str, bytes)):
|
489 | 483 | return GlobMatcher(spec, period_special=period_special)
|
@@ -584,8 +578,6 @@ def __init__(
|
584 | 578 | os.stat(directory_str)
|
585 | 579 |
|
586 | 580 | # … and possibly open it as a FD if this is supported by the platform
|
587 |
| - # |
588 |
| - # Note: `os.fwalk` support for binary paths was only added in 3.7+. |
589 | 581 | directory_str_or_fd: ty.Union[AnyStr, int] = directory_str
|
590 | 582 | if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES):
|
591 | 583 | fd = os.open(directory_str, os.O_RDONLY | O_DIRECTORY)
|
|
0 commit comments