summaryrefslogtreecommitdiff
path: root/sphinx/util/matching.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/matching.py')
-rw-r--r--sphinx/util/matching.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/sphinx/util/matching.py b/sphinx/util/matching.py
index d33ae0333..f32d682f1 100644
--- a/sphinx/util/matching.py
+++ b/sphinx/util/matching.py
@@ -9,7 +9,7 @@
"""
import re
-from typing import Callable, Dict, Iterable, List, Match, Pattern
+from typing import Callable, Dict, Iterable, List, Match, Optional, Pattern
from sphinx.util.osutil import canon_path
@@ -21,7 +21,7 @@ def _translate_pattern(pat: str) -> str:
match slashes.
"""
i, n = 0, len(pat)
- res = '' # type: str
+ res = ''
while i < n:
c = pat[i]
i += 1
@@ -60,7 +60,7 @@ def _translate_pattern(pat: str) -> str:
return res + '$'
-def compile_matchers(patterns: List[str]) -> List[Callable[[str], Match[str]]]:
+def compile_matchers(patterns: List[str]) -> List[Callable[[str], Optional[Match[str]]]]:
return [re.compile(_translate_pattern(pat)).match for pat in patterns]
@@ -86,10 +86,10 @@ class Matcher:
DOTFILES = Matcher(['**/.*'])
-_pat_cache = {} # type: Dict[str, Pattern]
+_pat_cache: Dict[str, Pattern] = {}
-def patmatch(name: str, pat: str) -> Match[str]:
+def patmatch(name: str, pat: str) -> Optional[Match[str]]:
"""Return if name matches pat. Adapted from fnmatch module."""
if pat not in _pat_cache:
_pat_cache[pat] = re.compile(_translate_pattern(pat))