mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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}"
|
"mypy_config", f"Only components should be added: {module}"
|
||||||
)
|
)
|
||||||
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 in mypy_config.py"
|
||||||
|
)
|
||||||
|
|
||||||
# Validate that all modules exist.
|
# Validate that all modules exist.
|
||||||
all_modules = strict_modules + IGNORED_MODULES
|
all_modules = strict_modules + IGNORED_MODULES
|
||||||
@ -326,6 +328,10 @@ def generate_and_validate(config: Config) -> str:
|
|||||||
if not module_path.is_file():
|
if not module_path.is_file():
|
||||||
config.add_error("mypy_config", f"Module '{module} doesn't exist")
|
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()
|
mypy_config = configparser.ConfigParser()
|
||||||
|
|
||||||
general_section = "mypy"
|
general_section = "mypy"
|
||||||
@ -369,6 +375,9 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
|
|||||||
config_path = config.root / "mypy.ini"
|
config_path = config.root / "mypy.ini"
|
||||||
config.cache["mypy_config"] = content = generate_and_validate(config)
|
config.cache["mypy_config"] = content = generate_and_validate(config)
|
||||||
|
|
||||||
|
if config.errors:
|
||||||
|
return
|
||||||
|
|
||||||
with open(str(config_path)) as fp:
|
with open(str(config_path)) as fp:
|
||||||
if fp.read().strip() != content:
|
if fp.read().strip() != content:
|
||||||
config.add_error(
|
config.add_error(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user