typeshed
typeshed copied to clipboard
Add third-party lief stubs
Add the initial stubs for lief, generated by python3 scripts/create_baseline_stubs.py lief
Fix https://github.com/lief-project/LIEF/issues/650
These errors should be fixed before PR get merged.
Running black: black stubs/lief
error: cannot format stubs/lief/lief/MachO.pyi: Cannot parse: 40:6: 32BIT_BRANCH: ClassVar[ARM_RELOCATION] = ...
error: cannot format stubs/lief/lief/OAT.pyi: Cannot parse: 172:29: def magic(self) -> Magic number: ...
error: cannot format stubs/lief/lief/__init__.pyi: Cannot parse: 215:15: class ItemsView[DictStringVersion]:
error: cannot format stubs/lief/lief/DEX.pyi: Cannot parse: 394:10: class lief.DEX.MapList.it_items_t:
error: cannot format stubs/lief/lief/ELF/__init__.pyi: Cannot parse: 455:35: def eof_offset(self) -> Return the last offset used by the ELF binary according to both: ...
error: cannot format stubs/lief/lief/PE.pyi: Cannot parse: 1339:17: machine: The target machine architecture
- [ ]
32BIT_BRANCHstarts with number, so it is not a valid identifier - [ ]
Magic numbercontains space, not valid - [ ]
class ItemsView[DictStringVersion]use[]when declaring custom class, not valid - [ ]
class lief.DEX.MapList.it_items_tcontains dots (.), not valid - [ ]
eof_offsethas wrong return type, which is more like comments - [ ]
machineinPE.pyihas wrong type annotation, which contains space
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
@srittau Thanks for your help! These errors have shown some common patterns so I am trying to fix them in a reasonable way.
One thing that might help: Just send a PR with just the result of scripts/create_baseline_stubs.py and maybe a bit of import cleanup. We can then build on that.
The first commit https://github.com/python/typeshed/pull/8417/commits/f14343ea24968047c74f0e0e67774fa8d6727f5e is generated by scripts/create_baseline_stubs.py and it has many errors so I try to make a commit for each file to fix them. So you mean I just need the first commit and you can build on that without error automatically?
Ah I see. The original commit indeed has lots of problems. Normally that script generates acceptable stubs, but not in this case, unfortunately. So please ignore my comment above.
But maybe the easiest solution in case of errors would be to just remove the problematic type annotation for now, if it is not an easy fix. This makes it easier for you to finish the stubs and for us to review the first version.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
For now, most of my change is to convert C++ enum to Python enum since the auto script cannot express it using Python Enum class. I think this conversion should be achieved automatically in the future (will it be difficult?) since we cannot just rely on manual efforts to keep up with the latest change.
Unfortunately there are many CI checks failing here, and I don't think any of us currently have the bandwidth to help this PR pass all of our CI :(
I'm going to close this PR for now due to lack of recent activity, and to keep our list of open PRs at a manageable level. But I'm happy to reopen it if you're still interested in working on it :)