Add mypy annotations for utils/appdirs
@@ -10,9 +10,16 @@ import sys
from pip._vendor.six import PY2, text_type
from pip._internal.utils.compat import WINDOWS, expanduser
+from pip._internal.utils.typing import MYPY_CHECK_RUNNING
+
+if MYPY_CHECK_RUNNING:
+ from typing import ( # noqa: F401
+ List, Union
+ )
def user_cache_dir(appname):
+ # type: (str) -> str
r"""
Return full path to the user-specific cache dir for this application.
@@ -61,6 +68,7 @@ def user_cache_dir(appname):
def user_data_dir(appname, roaming=False):
+ # type: (str, bool) -> str
r"""
Return full path to the user-specific data dir for this application.
@@ -113,6 +121,7 @@ def user_data_dir(appname, roaming=False):
def user_config_dir(appname, roaming=True):
+ # type: (str, bool) -> str
"""Return full path to the user-specific config dir for this application.
"appname" is the name of application.
@@ -146,6 +155,7 @@ def user_config_dir(appname, roaming=True):
# for the discussion regarding site_config_dirs locations
# see <https://github.com/pypa/pip/issues/1733>
def site_config_dirs(appname):
+ # type: (str) -> List[str]
r"""Return a list of potential user-shared config dirs for this application.
"appname" is the name of application.
@@ -186,6 +196,7 @@ def site_config_dirs(appname):
# -- Windows support functions --
def _get_win_folder_from_registry(csidl_name):
+ # type: (str) -> str
"""
This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
@@ -208,6 +219,7 @@ def _get_win_folder_from_registry(csidl_name):
def _get_win_folder_with_ctypes(csidl_name):
+ # type: (str) -> str
csidl_const = {
"CSIDL_APPDATA": 26,
"CSIDL_COMMON_APPDATA": 35,
@@ -241,6 +253,7 @@ if WINDOWS:
def _win_path_to_bytes(path):
+ # type: (str) -> Union[bytes, str]
"""Encode Windows paths to bytes. Only used on Python 2.
Motivation is to be consistent with other operating systems where paths
