FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Simplify device __repr__ by rytilahti · Pull Request #805 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 1 addition & 5 deletions kasa/device.py
This file contains hidden or 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
Expand Up @@ -366,8 +366,4 @@ async def set_alias(self, alias: str):
def __repr__(self):
if self._last_update is None:
return f"<{self.device_type} at {self.host} - update() needed>"
return (
f"<{self.device_type} model {self.model} at {self.host}"
f" ({self.alias}), is_on: {self.is_on}"
f" - dev specific: {self.state_information}>"
)
return f"<{self.device_type} at {self.host} - {self.alias} ({self.model})>"
2 changes: 1 addition & 1 deletion kasa/smart/smartchilddevice.py
This file contains hidden or 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
Expand Up @@ -56,4 +56,4 @@ def device_type(self) -> DeviceType:
return dev_type

def __repr__(self):
return f"<ChildDevice {self.alias} of {self._parent}>"
return f"<{self.device_type} {self.alias} ({self.model}) of {self._parent}>"
2 changes: 1 addition & 1 deletion kasa/tests/test_smartdevice.py
This file contains hidden or 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
Expand Up @@ -198,7 +198,7 @@ async def test_mac(dev):
async def test_representation(dev):
import re

pattern = re.compile("<.* model .* at .* (.*), is_on: .* - dev specific: .*>")
pattern = re.compile("<DeviceType\..+ at .+? - .*? \(.+?\)>")
assert pattern.match(str(dev))


Expand Down

Back | FazBrowse Home | New Git URL