Skip to content

Switch from PurePath#as_uri to PurePath#joinpath for our test that PurePath methods get inherited #3249

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

Merged
merged 2 commits into from
Apr 14, 2025

Conversation

A5rocks
Copy link
Contributor

@A5rocks A5rocks commented Apr 11, 2025

as_uri is deprecated in PurePath. This commit also introduces a test to ensure users have a workaround that is not deprecated.

Failing test run: https://github.com/python-trio/trio/actions/runs/14393482504/job/40364976912

`as_uri` is deprecated in `PurePath`. This commit also introduces a test
to ensure users have a workaround that is not deprecated.
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00000%. Comparing base (5848b41) to head (b7177b0).
Report is 12 commits behind head on main.

Additional details and impacted files
@@               Coverage Diff                @@
##                 main        #3249    +/-   ##
================================================
  Coverage   100.00000%   100.00000%            
================================================
  Files             122          124     +2     
  Lines           18757        19005   +248     
  Branches         1269         1295    +26     
================================================
+ Hits            18757        19005   +248     
Files with missing lines Coverage Δ
src/trio/_path.py 100.00000% <100.00000%> (ø)
src/trio/_tests/test_path.py 100.00000% <100.00000%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@A5rocks A5rocks marked this pull request as ready for review April 11, 2025 01:35
@Zac-HD
Copy link
Member

Zac-HD commented Apr 14, 2025

IMO we should define a sync trio.Path.as_uri() method; it's not a pure function, but os.fsencode() doesn't do IO that I'd want to make async.

and then I think the test change is just to find a different PurePath method for test_forward_methods_without_rewrap.

@Zac-HD Zac-HD mentioned this pull request Apr 14, 2025
@A5rocks
Copy link
Contributor Author

A5rocks commented Apr 14, 2025

I wasn't too sure about doing that because there's no fundamental reason that has to be on trio.Path other than historical, and I wasn't sure if there's other sync methods on pathlib.Path that are not on pathlib.PurePath yet still don't do anything bad. (so should we just support all of them? We should have a consistent recommendation that applies for this new as_uri as well.)

And users can do pathlib.Path.as_uri(some_trio_path) to work around the deprecation warning, because trio.Path supports everything as_uri needs.

@Zac-HD
Copy link
Member

Zac-HD commented Apr 14, 2025

IMO "maintaining 1:1 compatibility with existing code" is enough reason in this case, and right now unblocking CI feels more urgent than answering those other API design questions 😅

(but for completeness: I'd like trio.Path to support every method on pathlib.Path, async if they do IO and sync if they just depend on OS state as in this case - I think the latter is rare though)

@A5rocks A5rocks added the skip newsfragment Newsfragment is not required label Apr 14, 2025
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Looks great - thanks for jumping on this @A5rocks!

@Zac-HD Zac-HD merged commit 737d96a into python-trio:main Apr 14, 2025
43 of 44 checks passed
@A5rocks A5rocks deleted the fix-3.14-deprecation branch April 14, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip newsfragment Newsfragment is not required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants