diff --git a/generate_stubs.py b/generate_stubs.py index 5af27ca1d..4407d2c69 100644 --- a/generate_stubs.py +++ b/generate_stubs.py @@ -49,10 +49,14 @@ sys.stdout.flush() # Check syntax - with tempfile.NamedTemporaryFile() as config: - config.write('[mypy]\nignore_errors = True\n'.encode()) - config.flush() - subprocess.check_call([sys.executable, '-m' 'mypy', f'{DIRECTORY}/{MODULE_NAME}', f'--config-file={config.name}'], env=env) + # Windows limitation - another process cannot normally read temporary file that is opened by this process + # Close first and delete manually afterwards + config = tempfile.NamedTemporaryFile(mode='w', delete=False) + config.write('[mypy]\nignore_errors = True\n') + config.close() + print(f'Mypy config file: {config.name}') + subprocess.check_call([sys.executable, '-m' 'mypy', f'{DIRECTORY}/{MODULE_NAME}', f'--config-file={config.name}'], env=env) + os.unlink(config.name) except subprocess.CalledProcessError as err: exit(err.returncode)