-
Notifications
You must be signed in to change notification settings - Fork 511
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 py.typed to elftools #507
Conversation
What's the deal with double quotes? |
ugh -- i hit save in my vscode and it just applied black formatting. Let me revert and just apply the line. |
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.
It's not clear to me what the point of this PR is. It needs additional justification.
It seems like every few months a new configuration file is added -- we already have two setup
files and a pyproject
file. What additional capability does py.typed
provide?
# All packages and sub-packages must be listed here | ||
packages=[ | ||
"elftools", |
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.
Not sure what all these changes have to do with your proposed addition, can you elaborate?
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.
Are you looking at an older commit?
I had some formatting done which I have removed in the latest commit.
@eliben the linked issue has a link to the PEP https://peps.python.org/pep-0561/ |
@fzakaria yes I have seen the PEP. What concrete benefit does this provide for elftools at this time? What will you be able to do with elftools once this file is in the tree that you could not have done before? |
Mypy or pyright (static type checkers) fail to infer the types of pyelftools because the file is not present. It will let me use my static type checker with this library. |
I think this PR misses the forest (PEP 561) for the trees. See #533. As noted there, the purpose of the Philosophically speaking, if the mere act of adding ExampleLet's consider the following consumer code: 1 from elftools.elf.elffile import ELFFile
2
3 def foo() -> None:
4 elf = ELFFile()
5 reveal_type(elf)
6
7 for sec in elf.iter_sections():
8 reveal_type(sec)
9
10 elf.nonexistent_method() Before this PR, when running $ mypy foo.py
foo.py:1: error: Skipping analyzing "elftools.elf.elffile": module is installed, but missing library stubs or py.typed marker [import-untyped]
foo.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
foo.py:5: note: Revealed type is "Any"
foo.py:8: note: Revealed type is "Any"
Found 1 error in 1 file (checked 1 source file) After this PR, one does not encounter that error, but rather some actual errors with the consumer code (lines 4, 10): $ mypy foo.py
foo.py:4: error: Missing positional argument "stream" in call to "ELFFile" [call-arg]
foo.py:5: note: Revealed type is "elftools.elf.elffile.ELFFile"
foo.py:8: note: Revealed type is "Any"
foo.py:10: error: "ELFFile" has no attribute "nonexistent_method" [attr-defined]
Found 2 errors in 1 file (checked 1 source file) So I will admit that this PR does add some basic benefit: However, the usefulness stops at the first layer. On line 8, |
That what I was thinking... seemed like a net-win. I found pyright to be a lot better at infering the types although I ran both on my codebase. Having read the PEP and that static checkers try to infer types; it felt like it only accomplishes good.... Maybe the proper fix is in mypy/pyright... |
fixes #506