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

Add paho-mqtt stubs #8853

Merged
merged 3 commits into from
Oct 6, 2022
Merged

Add paho-mqtt stubs #8853

merged 3 commits into from
Oct 6, 2022

Conversation

JonathanPlasse
Copy link
Contributor

Hi!
This PR adds stubs for paho-mqtt.

Should I use the optional packages ( PySocks and ssl) for paho-mqtt to type a socket type?
I currently use socket: socket.socket | Any | None which should be socket.socket | ssl.SslSocket | socks.socksocket | WebsocketWrapper.
Would they be installed when installing the stubs?

@github-actions

This comment has been minimized.

@JonathanPlasse
Copy link
Contributor Author

Should I make a pull request to homeassistant to fix their type hints?

@github-actions

This comment has been minimized.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thank you! I did not compare the types in-depth against the implementation, but this all looks plausible to me. A few remarks below, though.

stubs/paho-mqtt/paho/mqtt/client.pyi Outdated Show resolved Hide resolved
stubs/paho-mqtt/paho/mqtt/client.pyi Show resolved Hide resolved
stubs/paho-mqtt/paho/mqtt/client.pyi Outdated Show resolved Hide resolved
stubs/paho-mqtt/paho/mqtt/client.pyi Outdated Show resolved Hide resolved
stubs/paho-mqtt/paho/mqtt/client.pyi Outdated Show resolved Hide resolved
stubs/paho-mqtt/paho/mqtt/client.pyi Outdated Show resolved Hide resolved
stubs/paho-mqtt/paho/mqtt/client.pyi Outdated Show resolved Hide resolved
@srittau
Copy link
Collaborator

srittau commented Oct 6, 2022

Should I make a pull request to homeassistant to fix their type hints?

You are not required to do that, although I'm sure the homeassistant project would appreciate it.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

Diff from mypy_primer, showing the effect of this PR on open source code:

core (https://github.com/home-assistant/core)
+ homeassistant/components/mqtt/client.py:340: error: Incompatible types in assignment (expression has type "None", variable has type "Client")  [assignment]
+ homeassistant/components/mqtt/client.py:375: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, Any, int], None]", variable has type "Optional[_OnConnect]")  [assignment]
+ homeassistant/components/mqtt/client.py:376: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, int], None]", variable has type "_OnDisconnect")  [assignment]
+ homeassistant/components/mqtt/client.py:379: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, Any, Any], None]", variable has type "Optional[_OnSubscribe]")  [assignment]
+ homeassistant/components/mqtt/client.py:380: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, Any, Any], None]", variable has type "Optional[_OnUnsubscribe]")  [assignment]
+ homeassistant/components/mqtt/client.py:733: error: Argument 1 to "error_string" has incompatible type "Optional[int]"; expected "int"  [arg-type]
+ homeassistant/components/mqtt/config_flow.py:370: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, Any, Any], Any]", variable has type "Optional[_OnConnect]")  [assignment]

apprise (https://github.com/caronc/apprise)
- apprise/plugins/NotifyMQTT.py:56: error: Cannot find implementation or library stub for module named "paho.mqtt.client"
- apprise/plugins/NotifyMQTT.py:56: error: Cannot find implementation or library stub for module named "paho.mqtt"
- apprise/plugins/NotifyMQTT.py:56: error: Cannot find implementation or library stub for module named "paho"

@JonathanPlasse
Copy link
Contributor Author

Why does apprise check result in this error?

- apprise/plugins/NotifyMQTT.py:56: error: Cannot find implementation or library stub for module named "paho.mqtt.client"
- apprise/plugins/NotifyMQTT.py:56: error: Cannot find implementation or library stub for module named "paho.mqtt"
- apprise/plugins/NotifyMQTT.py:56: error: Cannot find implementation or library stub for module named "paho"

@srittau
Copy link
Collaborator

srittau commented Oct 6, 2022

It's a bit confusing. The - actually means that this error is now fixed, but GitHub colors it in red, making it seems like an error. Red is usually good in primer output, green is bad.

@srittau srittau merged commit fa82452 into python:master Oct 6, 2022
@JonathanPlasse
Copy link
Contributor Author

Thank you for your help.

@JonathanPlasse JonathanPlasse deleted the paho_mqtt branch October 6, 2022 15:28
hauntsaninja pushed a commit to python/mypy that referenced this pull request Dec 20, 2022
Removals from `stubinfo.py`:
- `atomicwrites` is archived and deprecated at runtime; stubs were
removed from typeshed in python/typeshed#8925
- `attrs` has had inline types for a very long time now
- `chardet` recently cut a release with inline types; typeshed's stubs
were marked obsolete in python/typeshed#9318
- `cryptography` has had inline types for a very long time now; the only
reason why it's still in typeshed is because other typeshed packages
need `types-cryptography` as a dependency, and our testing
infrastructure therefore can't currently cope with it being removed from
typeshed.
- `emoji` recently cut a release bundling stubs with the runtime
package; typeshed's stubs were marked obsolete in
python/typeshed#9051
- `termcolor` recently cut a release with inline types; typeshed's stubs
were marked obsolete in python/typeshed#8746
- `prettytable` recently cut a release with inline types; typeshed's
stubs were marked obsolete in
python/typeshed#9023

Additions:
- Stubs for `Xlib` were added in
python/typeshed#9279
- Stubs for `consolemenu` were added in
python/typeshed#8820
- Stubs for `dockerfile_parse` were added in
python/typeshed#9305
- Stubs for `flask_migrate` were added in
python/typeshed#8967
- Stubs for `paho.mqtt` were added in
python/typeshed#8853
- Stubs for `pycocotools` were added in
python/typeshed#9086
- Stubs for many `pywin32` modules were added in
python/typeshed#8825, and multiple follow-up PRs
- Stubs for `pyscreeze` were added in
python/typeshed#8823
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.

3 participants