mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Don't generate mypy.ini if errors are found (#50456)
This commit is contained in:
parent
236f138ab7
commit
1538271555
@ -308,7 +308,9 @@ def generate_and_validate(config: Config) -> str:
|
||||
"mypy_config", f"Only components should be added: {module}"
|
||||
)
|
||||
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 in mypy_config.py"
|
||||
)
|
||||
|
||||
# Validate that all modules exist.
|
||||
all_modules = strict_modules + IGNORED_MODULES
|
||||
@ -326,6 +328,10 @@ def generate_and_validate(config: Config) -> str:
|
||||
if not module_path.is_file():
|
||||
config.add_error("mypy_config", f"Module '{module} doesn't exist")
|
||||
|
||||
# Don't generate mypy.ini if there're errors found because it will likely crash.
|
||||
if config.errors:
|
||||
return ""
|
||||
|
||||
mypy_config = configparser.ConfigParser()
|
||||
|
||||
general_section = "mypy"
|
||||
@ -369,6 +375,9 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
|
||||
config_path = config.root / "mypy.ini"
|
||||
config.cache["mypy_config"] = content = generate_and_validate(config)
|
||||
|
||||
if config.errors:
|
||||
return
|
||||
|
||||
with open(str(config_path)) as fp:
|
||||
if fp.read().strip() != content:
|
||||
config.add_error(
|
||||
|
Loading…
x
Reference in New Issue
Block a user