-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial basic type checking * Fix untyped calls and defs * Add mypy to CI * Add py.typed marker for PEP 561 compat * Fix flake8 spacing in setup.py * pylint didn't like some line lengths * Ignore TYPE_CHECKING blocks from code coverage
- Loading branch information
Showing
84 changed files
with
921 additions
and
613 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ omit = | |
|
||
|
||
[report] | ||
exclude_lines = | ||
if TYPE_CHECKING: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[mypy] | ||
show_error_codes = True | ||
warn_unused_ignores = True | ||
disallow_untyped_defs = True | ||
disallow_untyped_calls = True | ||
check_untyped_defs = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
"""Module for handling the FactoryDefault to API.""" | ||
from typing import TYPE_CHECKING | ||
|
||
from pyvlx.log import PYVLXLOG | ||
|
||
from .api_event import ApiEvent | ||
from .frames import ( | ||
FrameGatewayFactoryDefaultConfirmation, FrameGatewayFactoryDefaultRequest) | ||
FrameBase, FrameGatewayFactoryDefaultConfirmation, | ||
FrameGatewayFactoryDefaultRequest) | ||
|
||
if TYPE_CHECKING: | ||
from pyvlx import PyVLX | ||
|
||
|
||
class FactoryDefault(ApiEvent): | ||
"""Class for handling Factory reset API.""" | ||
|
||
def __init__(self, pyvlx): | ||
def __init__(self, pyvlx: "PyVLX"): | ||
"""Initialize facotry default class.""" | ||
super().__init__(pyvlx=pyvlx) | ||
self.pyvlx = pyvlx | ||
self.success = False | ||
|
||
async def handle_frame(self, frame): | ||
async def handle_frame(self, frame: FrameBase) -> bool: | ||
"""Handle incoming API frame, return True if this was the expected frame.""" | ||
if isinstance(frame, FrameGatewayFactoryDefaultConfirmation): | ||
PYVLXLOG.warning("KLF200 is factory resetting") | ||
self.success = True | ||
return True | ||
return False | ||
|
||
def request_frame(self): | ||
def request_frame(self) -> FrameGatewayFactoryDefaultRequest: | ||
"""Construct initiating frame.""" | ||
return FrameGatewayFactoryDefaultRequest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.