From 8ce5987c88a578ab0f4f4a64aceff0577082f787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Wed, 15 Dec 2021 15:12:28 +0100 Subject: Add typing to ``_normalize_path`` and ``_cache_normalize_path`` (#1291) --- astroid/modutils.py | 7 +++++-- 1 file 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: -- cgit v1.2.1