-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 Typing Stubs #2020
Comments
While definitely cool, this is (AFAIK) strictly infeasible, since type annotations are incompatible with python 2. And pwntools is still compatible with python 2, for reasons I myself do not like. One day, sure, but this is way beyond the horizon from the current perspective. |
It appears it is actually not infeasible to do it inline with 2.7 compatibility: https://peps.python.org/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code Stub files are also an option but can rapidly become out of date as they have to be maintained separately. There are a few key methods which would greatly benefit from type annotations: microsoft/python-type-stubs#203 Would there be an objection to an MR with (with at least some of) this compatible type hinting? |
Yes, the inline type annotation is not supported in python2.7, but you can add them in comments like this:
The type annotation in comments is in the PEP484, so you don't need to worry about the compatibility for type checker tools.
I think it's promising, but now we may decide which part of the codes should be type hinted first |
This actually causes some code to incorrectly be detected as unreachable in some environments, as mentioned here:
This is particularly annoying since it happens after the first |
That particular issue is already fixed in dev #2069 |
Nowadays many tools(like

mypy
orpyright
) start to provide type check. Would this project add typing stubs in the future?The text was updated successfully, but these errors were encountered: