Skip to content
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

refactor: add missing py3.6 type hints #797

Merged
merged 8 commits into from Jan 20, 2022
Merged

Conversation

theguy147
Copy link
Collaborator

@theguy147 theguy147 commented Jan 18, 2022

Add missing type hints (py3.6)

Description/Motivation/Screenshots

This PR adds still missing type hints to gef.py (Issue #787).

Also a few very minor type hint related issues have been fixed (e.g. removing return <expression> where expression always evaluates to None)

EDIT:
The PR also removes a few unnecessary function/method arguments

How Has This Been Tested?

Architecture Yes/No Comments
x86-32 ✔️
x86-64 ✔️
ARM ✖️
AARCH64 ✖️
MIPS ✖️
POWERPC ✖️
SPARC ✖️
RISC-V ✖️
make test ✔️

Checklist

  • My PR was done against the dev branch, not master.
  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • My change adds tests as appropriate.
  • I have read and agree to the CONTRIBUTING document.

@theguy147 theguy147 added this to the Release: next milestone Jan 18, 2022
@theguy147 theguy147 self-assigned this Jan 18, 2022
@theguy147 theguy147 linked an issue Jan 18, 2022 that may be closed by this pull request
Copy link
Owner

@hugsy hugsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except just a few points to address

Cheers

gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed to line 5000

gef.py Outdated
try:
arena = gdb.parse_and_eval(addr)
malloc_state_t = cached_lookup_type("struct malloc_state")
self.__arena = arena.cast(malloc_state_t)
self.__arena = arena.cast(malloc_state_t) # "gdb.Value"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do self.__arena : "gdb.Value" = ...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually that is a comment for understanding the code better. I put it there to emphasize it for the reader because actually what we do is highly problematic (to sometimes have the arena be a gdb.Value and sometimes a MallocStateStruct with different ways of handling them)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its actually not a type hint. the type hint is a few lines above that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Let's reword it with basically what you just said?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this better now? please resolve if you agree

gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
@Grazfather Grazfather merged commit c6909e1 into hugsy:dev Jan 20, 2022
@theguy147 theguy147 deleted the type_hints_v2 branch January 20, 2022 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: complete type hints for py3.6 before release
3 participants