Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints to smart_task.py #456

Merged
merged 15 commits into from
Mar 15, 2022
11 changes: 11 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,14 @@ disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true

[mypy-pytradfri.smart_task]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
4 changes: 2 additions & 2 deletions pytradfri/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaseResponse(BaseModel):
class ApiResourceResponse(BaseResponse):
"""Represent a resource response."""

name: str = Field(alias=ATTR_NAME)
name: Optional[str] = Field(alias=ATTR_NAME)
created_at: Optional[int] = Field(alias=ATTR_CREATED_AT)
ota_update_state: Optional[int] = Field(alias=ATTR_OTA_UPDATE_STATE)

Expand Down Expand Up @@ -51,7 +51,7 @@ def id(self) -> int:
return resource_id

@property
def name(self) -> str:
def name(self) -> str | None:
"""Name."""
if self._model_class:
name = self.raw.name # type: ignore[union-attr]
Expand Down
Loading