Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor type hint fixes #452

Merged
merged 1 commit into from
Mar 8, 2022
Merged

Minor type hint fixes #452

merged 1 commit into from
Mar 8, 2022

Conversation

ggravlingen
Copy link
Member

Fixes:

pytradfri/device/__init__.py:29: error: Module "pytradfri.device.air_purifier_control" does not explicitly export attribute "AirPurifierResponse"; implicit reexport disabled  [attr-defined]
pytradfri/device/__init__.py:30: error: Module "pytradfri.device.blind_control" does not explicitly export attribute "BlindResponse"; implicit reexport disabled  [attr-defined]

@ggravlingen
Copy link
Member Author

I ran mypy with the --strict option and saw those. We also have this:

pytradfri/command.py:35: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/command.py:35: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
pytradfri/command.py:60: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/command.py:60: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
pytradfri/command.py:84: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/command.py:84: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
pytradfri/command.py:122: error: Missing type parameters for generic type "Command"  [type-arg]
pytradfri/command.py:130: error: Missing type parameters for generic type "Command"  [type-arg]
pytradfri/util.py:15: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/util.py:15: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
pytradfri/util.py:35: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/util.py:35: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
pytradfri/api/libcoap_api.py:114: error: Missing type parameters for generic type "Command"  [type-arg]
pytradfri/api/aiocoap_api.py:56: error: Missing type parameters for generic type "Task"  [type-arg]
pytradfri/api/aiocoap_api.py:225: error: Missing type parameters for generic type "Command"  [type-arg]
pytradfri/api/aiocoap_api.py:301: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/api/aiocoap_api.py:301: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]
pytradfri/api/aiocoap_api.py:323: error: Implicit generic "Any". Use "typing.List" and specify generic parameters  [type-arg]
pytradfri/api/aiocoap_api.py:323: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters  [type-arg]

These will not be relevant when we remove the two Command-methods __add__ and combine:

pytradfri/command.py:122: error: Missing type parameters for generic type "Command"  [type-arg]
pytradfri/command.py:130: error: Missing type parameters for generic type "Command"  [type-arg]

But what about these, can they be fixed by adding [T] to the type hint?

pytradfri/api/libcoap_api.py:114: error: Missing type parameters for generic type "Command"  [type-arg]
pytradfri/api/aiocoap_api.py:56: error: Missing type parameters for generic type "Task"  [type-arg]
pytradfri/api/aiocoap_api.py:225: error: Missing type parameters for generic type "Command"  [type-arg]

@MartinHjelmare
Copy link
Contributor

Yes, the Command cases in the api module should use T. The Task should be typed with its result value.

The list and dict cases should just add explicit Any where needed instead of implicit.

@ggravlingen
Copy link
Member Author

Yes, the Command cases in the api module should use T. The Task should be typed with its result value.

The list and dict cases should just add explicit Any where needed instead of implicit.

Thanks, I've stored your remarks and will look into them later.

@ggravlingen ggravlingen merged commit bd6c39b into master Mar 8, 2022
@ggravlingen ggravlingen deleted the small-type-hint-fixes branch March 8, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants