jaraco / jaraco.abode

MIT License
11 stars 9 forks source link

Emergent mypy issue #25

Closed jaraco closed 6 months ago

jaraco commented 6 months ago

Since the last successful test run, the mypy tests started failing:

___________________________________________________________ jaraco/abode/automation.py ___________________________________________________________
32: error: Value of type "Any | None" is not indexable  [index]
jaraco commented 6 months ago

The issue appears to be in this code:

https://github.com/jaraco/jaraco.abode/blob/499008eeaa8675c5c7bf4bdce3cfffef3c2f9e49/jaraco/abode/automation.py#L29-L32

Presumably, response.json() returns a sequence of state dicts. Aah, and single will defer to whatever more_itertools.only returns, which could be None depending on the parameters.

https://github.com/jaraco/jaraco.abode/blob/499008eeaa8675c5c7bf4bdce3cfffef3c2f9e49/jaraco/abode/_itertools.py#L7-L12

But since single does not specify a default, it can't return None, so its type declaration should indicate as much.

jaraco commented 6 months ago

Turns out mypy caught a legitimate error, and that error is fixed in db296b9.