-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add type stub for PySocks #14623
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
base: main
Are you sure you want to change the base?
Add type stub for PySocks #14623
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing! Looks good, just one nit with Any
:
Seems you used Any
for args
and kwargs
which can be defined since we know where to pass them (I've shown some cases below), otherwise I suggest using Incomplete
since such types can be improved in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I didn't add my suggestions to batch before submitting review and they didn't save :)
Seems pre-commit CI don't allow using |
This comment has been minimized.
This comment has been minimized.
It seems to me that to properly annotate If possible I would like to defer that work and submit the stubs in current state. For PySocks, |
This comment has been minimized.
This comment has been minimized.
Indeed, parameters are usually left unannotated in such cases because I don’t really mind leaving stubs in current state. Then I’ll try to replace args and kwargs myself soon. |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/contrib/socks.py:44: error: Unused "type: ignore" comment [unused-ignore]
+ src/urllib3/contrib/socks.py:114: error: Argument "proxy_port" to "create_connection" has incompatible type "str | None"; expected "int | None" [arg-type]
+ src/urllib3/contrib/socks.py:118: error: Argument "timeout" to "create_connection" has incompatible type "float | None"; expected "int | None" [arg-type]
+ test/contrib/test_socks.py:12: error: Unused "type: ignore" comment [unused-ignore]
+ test/contrib/test_socks.py:122: error: Module "socks" does not explicitly export attribute "socket" [attr-defined]
discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/hybrid.py:629: error: Overlap between argument names and ** TypedDict items: "name", "description" [misc]
+ discord/ext/commands/hybrid.py:629: error: Overlap between argument names and ** TypedDict items: "description", "name" [misc]
|
Upstream repository: https://github.com/Anorov/PySocks
Upstream PyPI: https://pypi.org/project/PySocks/