summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-12-15 15:12:28 +0100
committerGitHub <noreply@github.com>2021-12-15 15:12:28 +0100
commit8ce5987c88a578ab0f4f4a64aceff0577082f787 (patch)
treee0767bcaf950d8d68f802cf9152e13ac22ce4789
parent50087dfdec81e43083b859ef1035091aa9c920a5 (diff)
downloadastroid-git-8ce5987c88a578ab0f4f4a64aceff0577082f787.tar.gz
Add typing to ``_normalize_path`` and ``_cache_normalize_path`` (#1291)
-rw-r--r--astroid/modutils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py
index b2a67b23..e2f6e886 100644
--- a/astroid/modutils.py
+++ b/astroid/modutils.py
@@ -49,7 +49,7 @@ import sys
import types
from distutils.errors import DistutilsPlatformError # pylint: disable=import-error
from distutils.sysconfig import get_python_lib # pylint: disable=import-error
-from typing import Set
+from typing import Dict, Set
from astroid.interpreter._import import spec, util
@@ -159,8 +159,11 @@ class NoSourceFile(Exception):
def _normalize_path(path: str) -> str:
"""Resolve symlinks in path and convert to absolute path.
+
Note that environment variables and ~ in the path need to be expanded in
advance.
+
+ This can be cached by using _cache_normalize_path.
"""
return os.path.normcase(os.path.realpath(path))
@@ -186,7 +189,7 @@ def _handle_blacklist(blacklist, dirnames, filenames):
filenames.remove(norecurs)
-_NORM_PATH_CACHE = {}
+_NORM_PATH_CACHE: Dict[str, str] = {}
def _cache_normalize_path(path: str) -> str: