Validate if modules in mypy config exist (#49810)
This commit is contained in:
parent
1c0fd61075
commit
a0bf95d4b5
1 changed files with 18 additions and 0 deletions
|
@ -3,6 +3,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
import io
|
import io
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from .model import Config, Integration
|
from .model import Config, Integration
|
||||||
|
@ -321,6 +323,22 @@ def generate_and_validate(config: Config) -> str:
|
||||||
if module in ignored_modules_set:
|
if module in ignored_modules_set:
|
||||||
config.add_error("mypy_config", f"Module '{module}' is in ignored list")
|
config.add_error("mypy_config", f"Module '{module}' is in ignored list")
|
||||||
|
|
||||||
|
# Validate that all modules exist.
|
||||||
|
all_modules = strict_modules + IGNORED_MODULES
|
||||||
|
for module in all_modules:
|
||||||
|
if module.endswith(".*"):
|
||||||
|
module_path = Path(module[:-2].replace(".", os.path.sep))
|
||||||
|
if not module_path.is_dir():
|
||||||
|
config.add_error("mypy_config", f"Module '{module} is not a folder")
|
||||||
|
else:
|
||||||
|
module = module.replace(".", os.path.sep)
|
||||||
|
module_path = Path(f"{module}.py")
|
||||||
|
if module_path.is_file():
|
||||||
|
continue
|
||||||
|
module_path = Path(module) / "__init__.py"
|
||||||
|
if not module_path.is_file():
|
||||||
|
config.add_error("mypy_config", f"Module '{module} doesn't exist")
|
||||||
|
|
||||||
mypy_config = configparser.ConfigParser()
|
mypy_config = configparser.ConfigParser()
|
||||||
|
|
||||||
general_section = "mypy"
|
general_section = "mypy"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue