Skip to content

Commit 8ce5987

Browse files
authored
Add typing to _normalize_path and _cache_normalize_path (#1291)
1 parent 50087df commit 8ce5987

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

astroid/modutils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import types
5050
from distutils.errors import DistutilsPlatformError # pylint: disable=import-error
5151
from distutils.sysconfig import get_python_lib # pylint: disable=import-error
52-
from typing import Set
52+
from typing import Dict, Set
5353

5454
from astroid.interpreter._import import spec, util
5555

@@ -159,8 +159,11 @@ class NoSourceFile(Exception):
159159

160160
def _normalize_path(path: str) -> str:
161161
"""Resolve symlinks in path and convert to absolute path.
162+
162163
Note that environment variables and ~ in the path need to be expanded in
163164
advance.
165+
166+
This can be cached by using _cache_normalize_path.
164167
"""
165168
return os.path.normcase(os.path.realpath(path))
166169

@@ -186,7 +189,7 @@ def _handle_blacklist(blacklist, dirnames, filenames):
186189
filenames.remove(norecurs)
187190

188191

189-
_NORM_PATH_CACHE = {}
192+
_NORM_PATH_CACHE: Dict[str, str] = {}
190193

191194

192195
def _cache_normalize_path(path: str) -> str:

0 commit comments

Comments
 (0)