diff --git a/docs/source/config_file.rst b/docs/source/config_file.rst index 52d47140c78a..322716c91379 100644 --- a/docs/source/config_file.rst +++ b/docs/source/config_file.rst @@ -392,6 +392,8 @@ section of the command line docs. ``cache_dir`` (string, default ``.mypy_cache``) Specifies the location where mypy stores incremental cache info. + User home directory and environment variables will be expanded. + Note that the cache is only read when incremental mode is enabled but is always written to, unless the value is set to ``/dev/nul`` (UNIX) or ``nul`` (Windows). diff --git a/mypy/config_parser.py b/mypy/config_parser.py index 5f43badd1dca..18e7fe89338d 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -208,7 +208,7 @@ def parse_section(prefix: str, template: Options, print("%s%s: %s" % (prefix, key, err), file=stderr) continue if key == 'cache_dir': - v = os.path.expanduser(v) + v = os.path.expandvars(os.path.expanduser(v)) if key == 'silent_imports': print("%ssilent_imports has been replaced by " "ignore_missing_imports=True; follow_imports=skip" % prefix, file=stderr)