-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lot of changes to the types in the recent lief. * removed name from Binary * no name for section/symbol of type str (lief-project/LIEF#965) * created a proxy class Binary * added pyright to check tests folder
- Loading branch information
Showing
11 changed files
with
100 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# pyright: strict | ||
from typing import TYPE_CHECKING, Any | ||
|
||
import lief | ||
|
||
# Let's make sure type checking works for this proxy class | ||
# https://stackoverflow.com/questions/71365594/how-to-make-a-proxy-object-with-typing-as-underlying-object-in-python | ||
if TYPE_CHECKING: | ||
base = lief.ELF.Binary | ||
else: | ||
base = object | ||
|
||
|
||
class Binary(base): | ||
"""Proxy the lief.Binary object to add a path attribute. | ||
As of https://github.com/lief-project/LIEF/issues/839 the name | ||
attribute in lief.Binary was removed. Rather than passing around | ||
a tuple let's create a nice proxy class. | ||
""" | ||
|
||
def __init__(self, path: str): | ||
self.path = path | ||
self.__binary = lief.parse(path) | ||
|
||
if not TYPE_CHECKING: | ||
|
||
def __getattr__(self, attr: str) -> Any: | ||
return getattr(self.__binary, attr) | ||
|
||
@staticmethod | ||
def is_elf(path: str): | ||
return lief.is_elf(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters