Skip to content

Commit

Permalink
Add type hints to smart_task.py (#456)
Browse files Browse the repository at this point in the history
* Add type hints StartActionItemController

* Fix typo

* Add type hints

* Convert to int

* Add type hints

* FIx test

* Make transition time optional

* Implement calibration method

* Improve setter

* Remove setter

* Refactor

* Update pytradfri/smart_task.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Remove type annotation

* Fix?

* Remove type hints

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
  • Loading branch information
ggravlingen and MartinHjelmare authored Mar 15, 2022
1 parent 6a5070c commit 38c36fa
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 106 deletions.
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

0 comments on commit 38c36fa

Please sign in to comment.