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 TargetPath and add support for Python 3.12 #494

Merged
merged 3 commits into from
Jan 5, 2024

Conversation

Schamper
Copy link
Member

@Schamper Schamper commented Jan 3, 2024

This refactors TargetPath into a structure that's hopefully a little easier to maintain for future Python versions. TargetPath implementations are now split into different files, one for each Python version. Each file has specific changes needed to make it work. Each new release of Python still requires a new patch though.

I've also fixed some small filesystem and other test related bugs I ran into to get this all working.

As I'm writing this, I'm also starting to wonder at what point it might be a better idea to just... subclass pathlib.Path but literally override everything. I'm sure that has it's own set of challenges though.

Depends on fox-it/flow.record#91

@Schamper Schamper requested a review from pyrco January 3, 2024 22:44
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

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

Comparison is base (011323d) 74.18% compared to head (93d456e) 74.76%.

Files Patch % Lines
dissect/target/helpers/compat/path_39.py 88.38% 36 Missing ⚠️
dissect/target/helpers/compat/path_310.py 89.28% 30 Missing ⚠️
dissect/target/helpers/compat/path_311.py 88.41% 30 Missing ⚠️
dissect/target/helpers/compat/path_common.py 81.06% 25 Missing ⚠️
dissect/target/helpers/compat/path_312.py 89.75% 21 Missing ⚠️
dissect/target/filesystem.py 73.33% 4 Missing ⚠️
dissect/target/helpers/fsutil.py 92.85% 1 Missing ⚠️
dissect/target/helpers/polypath.py 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #494      +/-   ##
==========================================
+ Coverage   74.18%   74.76%   +0.58%     
==========================================
  Files         263      269       +6     
  Lines       21222    22064     +842     
==========================================
+ Hits        15744    16497     +753     
- Misses       5478     5567      +89     
Flag Coverage Δ
unittests 74.76% <88.16%> (+0.58%) ⬆️

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.

Copy link
Contributor

@pyrco pyrco left a comment

Choose a reason for hiding this comment

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

I noticed the 3.12 implementation still uses a "flavour" class insteasd of a module for TargetPath._flavour. I guess that is the easiest solution for now given dynamic separators?

I guess we should also tag&release flow.record and bump the dependency here to have the tests work.

@Schamper
Copy link
Member Author

Schamper commented Jan 4, 2024

I noticed the 3.12 implementation still uses a "flavour" class insteasd of a module for TargetPath._flavour. I guess that is the easiest solution for now given dynamic separators?

Yeah, unfortunately because we use dynamic separators we need some degree of a "flavour" class. I was thinking about a different approach with static pre-created flavours/PurePath classes for each combination (similar to how there's a PosixPurePath and WindowsPurePath. That would also allow us to use __slots__ again. I'll give that a try later to see how well that works.

I guess we should also tag&release flow.record and bump the dependency here to have the tests work.

Yes, I'll bump the version in this PR already while we do that.

@Schamper Schamper force-pushed the targetpath-refactor branch from 1c136b3 to 41f134d Compare January 4, 2024 16:03
@Schamper Schamper force-pushed the targetpath-refactor branch from 41f134d to 61f718a Compare January 5, 2024 10:59
@Schamper Schamper requested a review from pyrco January 5, 2024 11:24
@Schamper Schamper force-pushed the targetpath-refactor branch from 3cb4494 to 93d456e Compare January 5, 2024 17:24
@Schamper Schamper merged commit dd8ab8a into main Jan 5, 2024
@Schamper Schamper deleted the targetpath-refactor branch January 5, 2024 17:55
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