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

Create a tool for stubs in cstruct v4 #72

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

Create a tool for stubs in cstruct v4 #72

wants to merge 33 commits into from

Conversation

Miauwkeru
Copy link
Contributor

@Miauwkeru Miauwkeru commented Feb 27, 2024

The only thing that does not work as intended yet is the dereference of pointer. As in, it doesn't return the desired type information but just T

@Miauwkeru Miauwkeru changed the base branch from main to refactor-v4 February 27, 2024 10:13
Copy link

codecov bot commented Feb 27, 2024

Codecov Report

Attention: Patch coverage is 74.47917% with 49 lines in your changes missing coverage. Please review.

Project coverage is 90.83%. Comparing base (a315c88) to head (590fc56).

Files with missing lines Patch % Lines
dissect/cstruct/tools/stubify.py 64.22% 44 Missing ⚠️
dissect/cstruct/types/base.py 80.95% 4 Missing ⚠️
dissect/cstruct/types/structure.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
- Coverage   92.33%   90.83%   -1.51%     
==========================================
  Files          20       21       +1     
  Lines        2180     2357     +177     
==========================================
+ Hits         2013     2141     +128     
- Misses        167      216      +49     
Flag Coverage Δ
unittests 90.83% <74.47%> (-1.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Schamper Schamper self-requested a review March 4, 2024 00:38
@Miauwkeru Miauwkeru marked this pull request as ready for review March 11, 2024 12:50
@Miauwkeru Miauwkeru marked this pull request as draft March 11, 2024 12:50
Base automatically changed from refactor-v4 to main May 17, 2024 13:15
@Miauwkeru Miauwkeru marked this pull request as ready for review August 9, 2024 14:56
def _type_stub(cls, name: str = "") -> str:
return f"{name}: {cls.__name__}"

def to_stub(cls, name: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe name this differently? Also I think this might as well be a private method. Maybe _to_type_stub? to_stub might be confusing because it also makes me think of the compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i renamed it to to_type_stub as it is a function that gets called externally.

Copy link
Member

Choose a reason for hiding this comment

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

I don't agree on the "externally" part, I'd classify this usage as internal and would never expect anyone to ever call this externally. This is not part of any expected usage API.

@Miauwkeru Miauwkeru requested a review from Schamper August 12, 2024 10:26
@Miauwkeru
Copy link
Contributor Author

I added some more tests, and noticed there was still some issues with import stuff from a file. As all signatures/names dissapear once the stub file is there. I attempted to fix this by adding more checks in stubify_file. This seems good enough for now, but I think it might be better to use ast in the future. And maybe look if we can use mypy to generate the stubs with hooks.

@Miauwkeru Miauwkeru requested a review from Schamper February 17, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants