| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Interesting, that this has not caused issues earlier... Thanks for the PR @GhostCoder6969, I added a small nit on how I would personally make the check to keep it simpler. Take a look and let me know what you think!
Sorry, something went wrong.
| device_type = IotDevice._get_device_type_from_sys_info(sysinfo) | ||
| try: | ||
| return TYPE_TO_CLASS[device_type] | ||
| except KeyError as ex: |
There was a problem hiding this comment.
Instead of try-catching, you could do something like:
if (cls := TYPE_TO_CLASS.get(device_type) is None:
# raise exception
return cls
Sorry, something went wrong.
There was a problem hiding this comment.
Good call, much cleaner. I switched it to the get with None check and the tests still pass. Thanks for looking at it.
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## master #1781 +/- ##
==========================================
+ Coverage 93.42% 93.43% +0.01%
==========================================
Files 159 159
Lines 10113 10116 +3
Branches 1043 1044 +1
==========================================
+ Hits 9448 9452 +4
+ Misses 472 471 -1
Partials 193 193 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
|
Switched to the get with None check like you suggested, tests still green on my end. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM, great to see changes making the discovery path more robust, thanks @GhostCoder6969!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I hit the same KeyError on my network, my EC60 shows up as IOT.IPCAMERA and the whole discovery run dies.
I changed get_device_class_from_sys_info so an unknown type raises UnsupportedDeviceError, which discovery already catches and reports as unsupported. I added a regression test for the legacy camera sysinfo and it realy fails without the fix.
Tests, uv run pytest tests/test_device_factory.py tests/test_discovery.py, 3568 passed. ruff check and ruff format clean. Fixes #1753