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

Path support #787

Merged
merged 8 commits into from
Nov 15, 2024
Merged

Path support #787

merged 8 commits into from
Nov 15, 2024

Conversation

erooke
Copy link
Contributor

@erooke erooke commented Nov 14, 2024

For all import / export methods make the path a Union[Pathlike, str, bytes] argument to follow python conventions as outlined in pep 519.

closes: #685
closes: #774

I got carried away big time and this PR is probably unreasonably large. To test the new functionality I changed all the tests to feed in pathlib.Paths. In addition any tests which wrote to disk were rewritten to use the pytest tmp_path fixture. Which then caused me to rewrite the tests in the pytest style...

I can revert the test changes and be less invasive with my changes if desired.

Edit: I decided to roll those back. I think they're good changes in the long run but they get in the way of reviewing the pr at hand.

Open questions:

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.10%. Comparing base (af60811) to head (80fc373).
Report is 10 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #787      +/-   ##
==========================================
+ Coverage   96.09%   96.10%   +0.01%     
==========================================
  Files          25       25              
  Lines        8472     8481       +9     
==========================================
+ Hits         8141     8151      +10     
+ Misses        331      330       -1     

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

Copy link
Owner

@gumyr gumyr left a comment

Choose a reason for hiding this comment

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

For my education, what does the input type bytes actually do here? Why would a user pass bytes - is it for unicode file names?

src/build123d/exporters.py Outdated Show resolved Hide resolved
src/build123d/exporters3d.py Show resolved Hide resolved
src/build123d/exporters3d.py Show resolved Hide resolved
@gumyr
Copy link
Owner

gumyr commented Nov 15, 2024

There is no need to refactor the deprecated export methods.

@erooke
Copy link
Contributor Author

erooke commented Nov 15, 2024

For my education, what does the input type bytes actually do here? Why would a user pass bytes - is it for unicode file names?

I am not 100% sure. It seems to be a leftover from the fact that the c standard library used raw byte strings to represent paths. There is some discussion in pep 519 here. I included it in the signature because all of the underlying Pathlike functions support it and they claim:

In the end, it was decided that using bytes to represent paths is simply not going to go away and thus they should be supported to some degree. The hope is that people will gravitate towards path objects like pathlib and that will move people away from operating directly with bytes.

@gumyr gumyr merged commit e1da165 into gumyr:dev Nov 15, 2024
13 checks passed
@gumyr
Copy link
Owner

gumyr commented Nov 15, 2024

Thank you! Another nice improvement.

@DeflateAwning
Copy link

Thank you! I've been looking forward to this very small quality-of-life improvement :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants