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

Add overloads for dumps and write for BC (v4) #54

Merged
merged 3 commits into from
Jan 8, 2024
Merged

Conversation

Schamper
Copy link
Member

This adds overloads for the .dumps() and .write() methods on types for backwards compatibility with the old API.

For example, this enables the following syntax:

cs.uint32(2).dumps() == b"\x02\x00\x00\x00"
cs.uint32.dumps(2) == b"\x02\x00\x00\x00"

Similarly with the .write() function.

It's open for discussion whether we should merge this in, or just face the changed API. I was mostly curious if it was possible at all.

Copy link

codecov bot commented Nov 26, 2023

Codecov Report

Attention: 61 lines in your changes are missing coverage. Please review.

Comparison is base (6ac2073) 90.49% compared to head (c9b1dae) 90.97%.
Report is 40 commits behind head on refactor-v4.

❗ Current head c9b1dae differs from pull request most recent head d81e686. Consider uploading reports for the commit d81e686 to get more accurate results

Files Patch % Lines
dissect/cstruct/types/enum.py 87.25% 13 Missing ⚠️
dissect/cstruct/parser.py 84.50% 11 Missing ⚠️
dissect/cstruct/types/structure.py 96.82% 10 Missing ⚠️
dissect/cstruct/cstruct.py 90.32% 6 Missing ⚠️
dissect/cstruct/compiler.py 97.89% 5 Missing ⚠️
dissect/cstruct/types/flag.py 79.16% 5 Missing ⚠️
dissect/cstruct/types/base.py 95.78% 4 Missing ⚠️
dissect/cstruct/expression.py 98.27% 3 Missing ⚠️
dissect/cstruct/types/char.py 95.65% 2 Missing ⚠️
dissect/cstruct/bitbuffer.py 75.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@               Coverage Diff               @@
##           refactor-v4      #54      +/-   ##
===============================================
+ Coverage        90.49%   90.97%   +0.47%     
===============================================
  Files               19       19              
  Lines             1694     2050     +356     
===============================================
+ Hits              1533     1865     +332     
- Misses             161      185      +24     
Flag Coverage Δ
unittests 90.97% <95.41%> (+0.47%) ⬆️

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 changed the title Add overloads for dumps and write for BC Add overloads for dumps and write for BC (v4) Nov 26, 2023
@Schamper Schamper merged commit 678edef into refactor-v4 Jan 8, 2024
24 checks passed
@Schamper Schamper deleted the api-overload branch January 8, 2024 16:37
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.

1 participant