1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Update typing 16 (#48087)

This commit is contained in:
Marc Mueller
2021-03-18 22:58:19 +01:00
committed by GitHub
parent 0f5efca76b
commit 4cb7718192
59 changed files with 180 additions and 166 deletions

View File

@@ -1,8 +1,10 @@
"""Models for manifest validator."""
from __future__ import annotations
import importlib
import json
import pathlib
from typing import Any, Dict, List, Optional
from typing import Any
import attr
@@ -24,12 +26,12 @@ class Error:
class Config:
"""Config for the run."""
specific_integrations: Optional[pathlib.Path] = attr.ib()
specific_integrations: pathlib.Path | None = attr.ib()
root: pathlib.Path = attr.ib()
action: str = attr.ib()
requirements: bool = attr.ib()
errors: List[Error] = attr.ib(factory=list)
cache: Dict[str, Any] = attr.ib(factory=dict)
errors: list[Error] = attr.ib(factory=list)
cache: dict[str, Any] = attr.ib(factory=dict)
def add_error(self, *args, **kwargs):
"""Add an error."""
@@ -65,9 +67,9 @@ class Integration:
return integrations
path: pathlib.Path = attr.ib()
manifest: Optional[dict] = attr.ib(default=None)
errors: List[Error] = attr.ib(factory=list)
warnings: List[Error] = attr.ib(factory=list)
manifest: dict | None = attr.ib(default=None)
errors: list[Error] = attr.ib(factory=list)
warnings: list[Error] = attr.ib(factory=list)
@property
def domain(self) -> str:
@@ -80,17 +82,17 @@ class Integration:
return self.path.as_posix().startswith("homeassistant/components")
@property
def disabled(self) -> Optional[str]:
def disabled(self) -> str | None:
"""List of disabled."""
return self.manifest.get("disabled")
@property
def requirements(self) -> List[str]:
def requirements(self) -> list[str]:
"""List of requirements."""
return self.manifest.get("requirements", [])
@property
def dependencies(self) -> List[str]:
def dependencies(self) -> list[str]:
"""List of dependencies."""
return self.manifest.get("dependencies", [])