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

Allow replacing path without replacing query or fragment #1421

Merged
merged 25 commits into from
Nov 21, 2024

Conversation

paul-nameless
Copy link
Contributor

@paul-nameless paul-nameless commented Nov 18, 2024

What do these changes do?

Add keep_query and keep_fragment arguments to with_path function to allow replacing path without replacing query or fragment

Are there changes in behavior for the user?

Yes, users can now replace the path in a URL without unintentionally modifying the query string or fragment by using the new arguments. Existing behavior remains unchanged unless the new arguments are explicitly used.

Related issue number

closes #111

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Nov 18, 2024
Copy link

codspeed-hq bot commented Nov 18, 2024

CodSpeed Performance Report

Merging #1421 will not alter performance

Comparing paul-nameless:with-path-keep-query (41ecc98) with master (2b94725)

Summary

✅ 85 untouched benchmarks

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.11%. Comparing base (2b94725) to head (41ecc98).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1421      +/-   ##
==========================================
+ Coverage   96.04%   96.11%   +0.06%     
==========================================
  Files          31       31              
  Lines        5770     5871     +101     
  Branches      348      348              
==========================================
+ Hits         5542     5643     +101     
  Misses        202      202              
  Partials       26       26              
Flag Coverage Δ
CI-GHA 96.11% <100.00%> (+0.06%) ⬆️
MyPy 49.35% <88.88%> (+0.71%) ⬆️
OS-Linux 99.55% <100.00%> (+<0.01%) ⬆️
OS-Windows 99.62% <100.00%> (+<0.01%) ⬆️
OS-macOS 99.30% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 99.28% <100.00%> (+<0.01%) ⬆️
Py-3.10.15 99.51% <100.00%> (+<0.01%) ⬆️
Py-3.11.10 99.51% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 99.28% <100.00%> (+<0.01%) ⬆️
Py-3.12.7 99.51% <100.00%> (+<0.01%) ⬆️
Py-3.13.0 99.51% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 99.24% <100.00%> (+<0.01%) ⬆️
Py-3.9.20 99.47% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 99.53% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.17 99.55% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 99.30% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 99.55% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 99.62% <100.00%> (+<0.01%) ⬆️
pytest 99.55% <100.00%> (+<0.01%) ⬆️

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.


🚨 Try these New Features:

CHANGES/111.bugfix.rst Outdated Show resolved Hide resolved
@webknjaz webknjaz requested a review from bdraco November 18, 2024 16:18
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
tests/test_url.py Outdated Show resolved Hide resolved
tests/test_url.py Outdated Show resolved Hide resolved
tests/test_url.py Outdated Show resolved Hide resolved
@bdraco bdraco changed the title Fix #111: Allow replacing path without replacing query or fragment Allow replacing path without replacing query or fragment Nov 18, 2024
CHANGES/111.bugfix.rst Outdated Show resolved Hide resolved
bdraco
bdraco previously approved these changes Nov 18, 2024
@bdraco
Copy link
Member

bdraco commented Nov 18, 2024

reframed this as a new feature since the current behavior doesn't change and its by design. All the functionality here is new.

@bdraco
Copy link
Member

bdraco commented Nov 18, 2024

Screenshot 2024-11-18 at 12 36 02 PM

@bdraco bdraco dismissed their stale review November 18, 2024 18:36

We also need to update the docs for with_path

@bdraco
Copy link
Member

bdraco commented Nov 18, 2024

One last thing, we also need to update the docs for with_path with the new params

https://yarl--1421.org.readthedocs.build/en/1421/api/#yarl.URL.with_path

@asvetlov
Copy link
Member

We also have .with_name() and .with_suffix().
Maybe these methods need proposed skip options as well?

Co-authored-by: Andrew Svetlov <[email protected]>
docs/api.rst Show resolved Hide resolved
@bdraco
Copy link
Member

bdraco commented Nov 19, 2024

We will also need to bump the version to 1.18.0.dev0 after merging this PR

@asvetlov
Copy link
Member

We will also need to bump the version to 1.18.0.dev0 after merging this PR

Technically, we can do it right now.

@bdraco bdraco mentioned this pull request Nov 19, 2024
tests/test_url.py Outdated Show resolved Hide resolved
tests/test_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

Please update affected method signatures in docs to reflect added parameters.

CHANGES/1421.feature.rst Outdated Show resolved Hide resolved
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

A few neats.

docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
paul-nameless and others added 3 commits November 21, 2024 08:27
Co-authored-by: Andrew Svetlov <[email protected]>
Co-authored-by: Andrew Svetlov <[email protected]>
Co-authored-by: Andrew Svetlov <[email protected]>
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@asvetlov asvetlov merged commit fc08cb8 into aio-libs:master Nov 21, 2024
45 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to replace path without replacing query
4 participants