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

Type hint gateway #442

Merged
merged 12 commits into from
Mar 5, 2022
Merged

Type hint gateway #442

merged 12 commits into from
Mar 5, 2022

Conversation

ggravlingen
Copy link
Member

No description provided.

@ggravlingen
Copy link
Member Author

I believe this constant might need some consideration when we've sorted out type hints on the Gateway class:

TypeProcessResultCb = Optional[Callable[[Any], Optional[str]]]

@ggravlingen ggravlingen marked this pull request as ready for review March 4, 2022 20:04
pytradfri/gateway.py Outdated Show resolved Hide resolved
pytradfri/gateway.py Outdated Show resolved Hide resolved
@MartinHjelmare
Copy link
Contributor

I believe this constant might need some consideration when we've sorted out type hints on the Gateway class:

TypeProcessResultCb = Optional[Callable[[Any], Optional[str]]]

We can change it to return Optional[Any] for now. I have some ideas how we can improve that later but that's for when we want to improve typing in the command.py module.

ggravlingen and others added 3 commits March 5, 2022 09:00
@ggravlingen
Copy link
Member Author

ggravlingen commented Mar 5, 2022

I believe this constant might need some consideration when we've sorted out type hints on the Gateway class:

TypeProcessResultCb = Optional[Callable[[Any], Optional[str]]]

We can change it to return Optional[Any] for now. I have some ideas how we can improve that later but that's for when we want to improve typing in the command.py module.

I ended up doing the same with the data argument. as it either should be a dict[str, Any], str or None.

@ggravlingen
Copy link
Member Author

Would you oppose if we deprecated moods and smart tasks? I for one don't use them and don't really feel they're worth maintaining. For users who need those features, we could point to Home Assistant.

@MartinHjelmare
Copy link
Contributor

I think the library should represent the tradfri api as close as possible. I don't think we should remove it.

Copy link
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning to type the rest of the gateway module in this PR?

pytradfri/command.py Outdated Show resolved Hide resolved
@ggravlingen
Copy link
Member Author

Are you planning to type the rest of the gateway module in this PR?

No, the rest of the file will be a follow-up PR. Felt that was a bit easier to comprehend.

pytradfri/gateway.py Outdated Show resolved Hide resolved
pytradfri/gateway.py Outdated Show resolved Hide resolved
pytradfri/gateway.py Outdated Show resolved Hide resolved
ggravlingen and others added 3 commits March 5, 2022 09:26
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
@ggravlingen
Copy link
Member Author

I hadn't planned on touching command.py as it looks to be strictly typed already. Do you want to add your ideas to the file yourself?

@MartinHjelmare
Copy link
Contributor

Yeah, I'll look at that separately. 👍

Copy link
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@MartinHjelmare MartinHjelmare merged commit 305e443 into master Mar 5, 2022
@MartinHjelmare MartinHjelmare deleted the type-hint-gateway branch March 5, 2022 10:57
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