Files
pytorch/mypy_plugins/check_mypy_version.py
kstant0725 ff58899b5e Pull request to run CI for #72556 (#73404)
Summary:
This PR moves the Dockerfile conda dependencies into a requirements-ci.txt (and begins the requirements file for other parts of CI as well).  Packages are listed alphabetically in the requirements-ci.txt.  Uncommented packages before the mkl package have been tested and confirmed to work on all platforms.  Commented out packages before mkl have broken at least one platform and so have been comment out.  There appears to be some randomness with certain platforms not passing tests so it might be good to run a number of tests for the same configuration to confirm if it is indeed these commented out packages that cause the errors.

Remaining is to test all commented out packages to ensure they work on all platforms.  This will likely involve repeat runs of the same configurations to ensure it is indeed the packages that break the platforms and not random errors.

This PR makes progress on task https://github.com/pytorch/pytorch/issues/72556

Pull Request resolved: https://github.com/pytorch/pytorch/pull/73404

Reviewed By: janeyx99

Differential Revision: D34730797

Pulled By: kstant0725

fbshipit-source-id: 3e4b171720fa33b604cebb9c6101d38ba11f2f8b
(cherry picked from commit 99cc445aadb95f92f6ef040f2d4b7c6c6d5b7f8b)
2022-03-24 18:04:08 +00:00

34 lines
849 B
Python

import re
import sys
from pathlib import Path
from mypy.plugin import Plugin
def get_correct_mypy_version():
# there's probably a more elegant way to do this
match, = re.finditer(
r'mypy==(\d+(?:\.\d+)*)',
Path('.circleci/docker/requirements-ci.txt').read_text(),
)
version, = match.groups()
return version
def plugin(version: str):
correct_version = get_correct_mypy_version()
if version != correct_version:
print(f'''\
You are using mypy version {version}, which is not supported
in the PyTorch repo. Please switch to mypy version {correct_version}.
For example, if you installed mypy via pip, run this:
pip install mypy=={correct_version}
Or if you installed mypy via conda, run this:
conda install -c conda-forge mypy={correct_version}
''', file=sys.stderr)
return Plugin