-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Rework of the URL subtraction feature #1392
base: master
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #1392 will not alter performanceComparing Summary
Benchmarks breakdown
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❌ Your project check has failed because the head coverage (98.84%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1392 +/- ##
==========================================
- Coverage 98.93% 98.84% -0.10%
==========================================
Files 32 25 -7
Lines 6091 5007 -1084
Branches 365 347 -18
==========================================
- Hits 6026 4949 -1077
+ Misses 62 56 -6
+ Partials 3 2 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I'm going to do a 1.17.0 release so we can start preparing aiohttp 3.11.x and I want do to some more downstream cleanups. We can do a 1.18.0 for this once its ready |
Some conflicts happened. I think I've resolved them correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I support the intention I propose more conservative approach.
Let's provide a method, name it, instead of __sub__
operator overloading.
Add tests, doc, etc.
Publish new yarl
release, wait for feedback.
Tune and polish.
After some time we can return to adding __sub__
.
I disagree with some of the unit tests, as I expect the returned relative path to add up to the complete path when concatenated as a relative path. def test_relative_to(target: str, base: str, expected: str):
expected_url = URL(expected)
target_url = URL(target)
base_url = URL(base)
result_url = target_url.relative_to(base_url)
assert result_url == expected_url
combined = base_url / expected
assert target_url == combined Please include this in the unit tests, it'll help to align those with the idea of a relative path and harden the semantics on this operation wrt. to trailing / in base and result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, avoid touching anything in the packaging/
directory.
Ok, but this was an auto-fix from pre-commit hooks. The bot added it after I had already pushed the changes 🤷♂️ |
Oh, that's weird. I wonder if the pre-commit.ci cache got invalidated randomly and it pulled in some newer transitive deps... |
@commonism this condition will only be true if we first normalize the URLs before comparing, so I've modified this code a bit: combined_url = base_url / expected
combined_path = normalized_path(combined_url.path)
target_path = normalized_path(target_url.path)
assert combined_path == target_path If we don't normalize them, the following can happen: target_url = URL("/path/to")
base_url = URL("/spam")
relative_url = target_url.relative_to(base_url)
print(relative_url) # URL("../path/to")
combined_url = base_url / relative_url
print(combined_url) # URL("/spam/../path/to") => combined_url != target_url But now everything seems to be working properly. |
What do these changes do?
Rework of the URL subtraction feature (added in #1340; removed in #1391)
Are there changes in behavior for the user?
Being able to calculate the relative path between two URLs:
Related issue number
Resolves #1183
Checklist
Known issues