Skip to content

Commit 09d469f

Browse files
authored
Make stubgen respect MYPY_CACHE_DIR (#14722)
This is required when using stubgen in a parallel build system, such as GNU make.
1 parent bf6b21d commit 09d469f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mypy/stubgen.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,13 @@ def mypy_options(stubgen_options: Options) -> MypyOptions:
15891589
options.show_traceback = True
15901590
options.transform_source = remove_misplaced_type_comments
15911591
options.preserve_asts = True
1592+
1593+
# Override cache_dir if provided in the environment
1594+
environ_cache_dir = os.getenv("MYPY_CACHE_DIR", "")
1595+
if environ_cache_dir.strip():
1596+
options.cache_dir = environ_cache_dir
1597+
options.cache_dir = os.path.expanduser(options.cache_dir)
1598+
15921599
return options
15931600

15941601

0 commit comments

Comments
 (0)