Skip to content

Commit

Permalink
Enhance mypy stubs (related to #650)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Mar 25, 2023
1 parent bc58884 commit 683fc6c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 56 deletions.
6 changes: 0 additions & 6 deletions api/python/lief/DEX.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ from typing import Any, ClassVar, Iterator, List, Tuple
from typing import overload
import lief # type: ignore
import lief.DEX # type: ignore
import lief.DEX.Class # type: ignore
import lief.DEX.File # type: ignore
import lief.DEX.MapItem # type: ignore
import lief.DEX.MapList # type: ignore
import lief.DEX.Prototype # type: ignore
import lief.DEX.Type # type: ignore

class ACCESS_FLAGS:
__members__: ClassVar[dict] = ... # read-only
Expand Down
15 changes: 3 additions & 12 deletions api/python/lief/ELF.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ from typing import Any, ClassVar, Dict, Iterable, Iterator, List, Set
from typing import overload
import lief # type: ignore
import lief.ELF # type: ignore
import lief.ELF.Binary # type: ignore
import lief.ELF.Builder # type: ignore
import lief.ELF.CoreAuxv # type: ignore
import lief.ELF.CoreFile # type: ignore
import lief.ELF.CorePrStatus # type: ignore
import lief.ELF.Section # type: ignore
import lief.ELF.Segment # type: ignore
import lief.ELF.SymbolVersionDefinition # type: ignore
import lief.ELF.SymbolVersionRequirement # type: ignore

class ARCH:
__members__: ClassVar[dict] = ... # read-only
Expand Down Expand Up @@ -2399,8 +2390,8 @@ class VERSION:
def value(self) -> int: ...

@overload
def parse(filename: str, dynsym_count_method: lief.ELF.DYNSYM_COUNT_METHODS = ...) -> lief.ELF.Binary: ...
def parse(filename: str, dynsym_count_method: lief.ELF.DYNSYM_COUNT_METHODS = ...) -> lief.ELF.Binary | None: ...
@overload
def parse(raw: List[int], name: str = ..., dynsym_count_method: lief.ELF.DYNSYM_COUNT_METHODS = ...) -> lief.ELF.Binary: ...
def parse(raw: List[int], name: str = ..., dynsym_count_method: lief.ELF.DYNSYM_COUNT_METHODS = ...) -> lief.ELF.Binary | None: ...
@overload
def parse(io: object, name: str = ..., dynsym_count_method: lief.ELF.DYNSYM_COUNT_METHODS = ...) -> object: ...
def parse(io: object, name: str = ..., dynsym_count_method: lief.ELF.DYNSYM_COUNT_METHODS = ...) -> lief.ELF.Binary | None: ...
14 changes: 3 additions & 11 deletions api/python/lief/MachO.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ from typing import Any, ClassVar, Iterator, List, Set, Tuple
from typing import overload
import lief # type: ignore
import lief.MachO # type: ignore
import lief.MachO.Binary # type: ignore
import lief.MachO.BuildToolVersion # type: ignore
import lief.MachO.BuildVersion # type: ignore
import lief.MachO.DataCodeEntry # type: ignore
import lief.MachO.DyldChainedFixups # type: ignore
import lief.MachO.DyldInfo # type: ignore
import lief.MachO.FatBinary # type: ignore
import lief.MachO.SegmentCommand # type: ignore

class ARM64_RELOCATION:
__members__: ClassVar[dict] = ... # read-only
Expand Down Expand Up @@ -1338,9 +1330,9 @@ def is_macho(filename: str) -> bool: ...
@overload
def is_macho(raw: List[int]) -> bool: ...
@overload
def parse(filename: str, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary: ...
def parse(filename: str, config: lief.MachO.ParserConfig = ...) -> lief.MachO.Binary | None: ...
@overload
def parse(raw: List[int], name: str = ..., config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary: ...
def parse(raw: List[int], name: str = ..., config: lief.MachO.ParserConfig = ...) -> lief.MachO.Binary | None: ...
@overload
def parse(io: object, name: str = ..., config: lief.MachO.ParserConfig = ...) -> object: ...
def parse(io: object, name: str = ..., config: lief.MachO.ParserConfig = ...) -> lief.MachO.Binary | None: ...
def parse_from_memory(address: int, config: lief.MachO.ParserConfig = ...) -> lief.MachO.FatBinary: ...
4 changes: 0 additions & 4 deletions api/python/lief/OAT.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import lief.Android # type: ignore
import lief.DEX # type: ignore
import lief.ELF # type: ignore
import lief.OAT # type: ignore
import lief.OAT.Binary # type: ignore
import lief.OAT.Class # type: ignore
import lief.OAT.Header # type: ignore
import lief.OAT.Header.it_key_values_t # type: ignore

class Binary(lief.ELF.Binary):
class it_classes:
Expand Down
24 changes: 5 additions & 19 deletions api/python/lief/PE.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@ from typing import Any, ClassVar, Iterable, Iterator, List, Set, Tuple
from typing import overload
import lief # type: ignore
import lief.PE # type: ignore
import lief.PE.Binary # type: ignore
import lief.PE.DelayImport # type: ignore
import lief.PE.Export # type: ignore
import lief.PE.ExportEntry # type: ignore
import lief.PE.Import # type: ignore
import lief.PE.Pogo # type: ignore
import lief.PE.Relocation # type: ignore
import lief.PE.ResourceDialog # type: ignore
import lief.PE.ResourceNode # type: ignore
import lief.PE.ResourcesManager # type: ignore
import lief.PE.RichHeader # type: ignore
import lief.PE.Signature # type: ignore
import lief.PE.SignerInfo # type: ignore
import lief.PE.x509 # type: ignore

class ACCELERATOR_FLAGS:
__members__: ClassVar[dict] = ... # read-only
Expand Down Expand Up @@ -2366,7 +2352,7 @@ class Signature(lief.Object):
def find_crt_subject(self, subject: str) -> lief.PE.x509: ...
@overload
def find_crt_subject(self, subject: str, serialno: List[int]) -> lief.PE.x509: ...
def parse(self, *args, **kwargs) -> Any: ...
def parse(self, *args, **kwargs) -> lief.PE.Binary | None: ...
@property
def certificates(self) -> lief.PE.Signature.it_const_crt: ...
@property
Expand Down Expand Up @@ -2571,7 +2557,7 @@ class x509(lief.Object):
def is_trusted_by(self, ca_list: List[lief.PE.x509]) -> lief.PE.x509.VERIFICATION_FLAGS: ...
@overload
def is_trusted_by(self, microsoft_ca_bundle) -> Any: ...
def parse(self, *args, **kwargs) -> Any: ...
def parse(self, *args, **kwargs) -> lief.PE.Binary | None: ...
@overload
def verify(self, ca: lief.PE.x509) -> lief.PE.x509.VERIFICATION_FLAGS: ...
@overload
Expand Down Expand Up @@ -2618,9 +2604,9 @@ def is_pe(file: str) -> bool: ...
def is_pe(raw: List[int]) -> bool: ...
def oid_to_string(arg0: str) -> str: ...
@overload
def parse(filename: str) -> lief.PE.Binary: ...
def parse(filename: str) -> lief.PE.Binary | None: ...
@overload
def parse(raw: List[int], name: str = ...) -> lief.PE.Binary: ...
def parse(raw: List[int], name: str = ...) -> lief.PE.Binary | None: ...
@overload
def parse(io: object, name: str = ...) -> object: ...
def parse(io: object, name: str = ...) -> lief.PE.Binary | None: ...
def resolve_ordinals(imp: lief.PE.Import, strict: bool = ..., use_std: bool = ...) -> object: ...
2 changes: 1 addition & 1 deletion api/python/lief/VDEX.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import List
from typing import overload
import lief # type: ignore
import lief.Android # type: ignore
import lief.OAT.Binary # type: ignore
import lief.OAT # type: ignore
import lief.VDEX # type: ignore

class File(lief.Object):
Expand Down
4 changes: 1 addition & 3 deletions api/python/lief/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import Any, ClassVar, Iterator, List, Set

from . import ART, Android, DEX, ELF, MachO, OAT, PE, VDEX, logging # type: ignore
from typing import overload
import lief # type: ignore
import lief.Binary # type: ignore
import lief.ELF # type: ignore
import lief.Function # type: ignore

class ARCHITECTURES:
__members__: ClassVar[dict] = ... # read-only
Expand Down

0 comments on commit 683fc6c

Please sign in to comment.