Skip to content

Commit 15c318a

Browse files
hetmankpJukkaL
authored andcommitted
Expand environment variables in cache_dir config (#7022)
The 'cache_dir' configuration option will expand environment variables in addition to the user home directory. This makes it much easier to integrate with wrapper tools that use mypy. Closes #7259.
1 parent 33d3df5 commit 15c318a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

docs/source/config_file.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ section of the command line docs.
405405

406406
``cache_dir`` (string, default ``.mypy_cache``)
407407
Specifies the location where mypy stores incremental cache info.
408+
User home directory and environment variables will be expanded.
409+
408410
Note that the cache is only read when incremental mode is enabled
409411
but is always written to, unless the value is set to ``/dev/nul``
410412
(UNIX) or ``nul`` (Windows).

mypy/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def parse_section(prefix: str, template: Options,
224224
print("%s%s: %s" % (prefix, key, err), file=stderr)
225225
continue
226226
if key == 'cache_dir':
227-
v = os.path.expanduser(v)
227+
v = os.path.expandvars(os.path.expanduser(v))
228228
if key == 'silent_imports':
229229
print("%ssilent_imports has been replaced by "
230230
"ignore_missing_imports=True; follow_imports=skip" % prefix, file=stderr)

0 commit comments

Comments
 (0)