-
Notifications
You must be signed in to change notification settings - Fork 516
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 static typing #514
Comments
I think this is a duplicate of #371. |
Yes ,#371 is a duplicate. Can you please close one in the favor of the other? I'm asking because I stumbled over missing type annotation for pyelftools myself and would like to add it to pyelftools – I did similar work for other projects in the past. Before I start working on this I have one question: What is the oldest Python version you're willing to support? Over time may things changed, most importantly if you do |
@pmhahn I would recommend getting confirmation your PR would be accepted before doing any work here. I have made the mistake of contributing type annotations to Python projects before and then discovering that the authors didn't really get it. Python 3.9 seems like a reasonable minimum bar to me. |
I've closed #371 3.9 sounds good I'm ok with accepting types, but it would be great if this could be done gradually |
This is primarily for the public facing API, right? |
Theoretically, wherever it'd be helpful, I suppose. But the public facing API would be a priority, of course. |
Yes, public API is my preferred thing, but elftools uses construct and things from there become public (by accident). I just pushed my WIP branch to main...pmhahn:pyelftools:typing – feel free to take a look: the first 9 commits are not related strictly to adding type annotations, but either fix things |
How do you want me to handle 🐛 like this in def describe_attr_tag_arm(…):
d_entry = …
if d_entry is None:
…
return … + d_entry[val]
Such things are found by
|
By the way I would really recommend using Pyright over Mypy. It is far better. In my experience it's best not to try and fix bugs that static types find while you're adding them. I usually add a |
Sending PRs to fix these would be great, as well as cleaning up old Python 2 code. Overall your branch looks OK to me, but I'd really prefer separate PRs for things (not necessarily each bug, but at least related units) to make reviewing easier |
As far as I can tell this is missing static types or type stubs.
The best way to do it is to add type hints into the code, then you have to add an empty
py.typed
file in your package (next to__init__.py
).I would recommend using Pyright over Mypy. It's much better. The easiest way to run/enforce it is using the Pyright pre-commit hook.
The text was updated successfully, but these errors were encountered: