|
17 | 17 | PYTHON_VERSION = "3.9" |
18 | 18 | MYPY_VERSION = "1.14.1" |
19 | 19 |
|
| 20 | +ADDITIONAL_LOCKED_DEPENDENCIES = [ |
| 21 | + "types-chardet==5.0.4.6", |
| 22 | + "types-requests==2.31.0.6", |
| 23 | + "types-six==1.16.21.9", |
| 24 | + "types-redis==4.6.0.7", |
| 25 | + "PyGitHub>=1.59.0" |
| 26 | +] |
20 | 27 |
|
21 | 28 | class mypy(Check): |
22 | 29 | def __init__(self) -> None: |
@@ -45,17 +52,23 @@ def run(self, args: argparse.Namespace) -> int: |
45 | 52 | for parsed in targeted: |
46 | 53 | package_dir = parsed.folder |
47 | 54 | package_name = parsed.name |
| 55 | + dev_requirements = os.path.join(package_dir, "dev_requirements.txt") |
| 56 | + additional_requirements = ADDITIONAL_LOCKED_DEPENDENCIES |
48 | 57 |
|
49 | 58 | executable, staging_directory = self.get_executable(args.isolate, args.command, sys.executable, package_dir) |
50 | 59 | logger.info(f"Processing {package_name} for mypy check") |
51 | 60 |
|
| 61 | + # # need to install dev_requirements to ensure that type-hints properly resolve |
| 62 | + if os.path.exists(dev_requirements): |
| 63 | + additional_requirements += ["-r", dev_requirements] |
| 64 | + |
52 | 65 | # install mypy |
53 | 66 | try: |
54 | 67 | if args.next: |
55 | 68 | # use latest version of mypy |
56 | | - install_into_venv(executable, ["mypy"]) |
| 69 | + install_into_venv(executable, ["mypy"] + additional_requirements) |
57 | 70 | else: |
58 | | - install_into_venv(executable, [f"mypy=={MYPY_VERSION}"]) |
| 71 | + install_into_venv(executable, [f"mypy=={MYPY_VERSION}"] + additional_requirements) |
59 | 72 | except CalledProcessError as e: |
60 | 73 | logger.error("Failed to install mypy:", e) |
61 | 74 | return e.returncode |
|
0 commit comments