Skip to content

Allow replacing path without replacing query or fragment#1421

Merged
asvetlov merged 25 commits intoaio-libs:masterfrom
paul-nameless:with-path-keep-query
Nov 21, 2024
Merged

Allow replacing path without replacing query or fragment#1421
asvetlov merged 25 commits intoaio-libs:masterfrom
paul-nameless:with-path-keep-query

Conversation

@paul-nameless
Copy link
Copy Markdown
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
@codspeed-hq
Copy link
Copy Markdown

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

@codecov
Copy link
Copy Markdown

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 32 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.

Comment thread CHANGES/111.bugfix.rst Outdated
@webknjaz webknjaz requested a review from bdraco November 18, 2024 16:18
Comment thread yarl/_url.py Outdated
Comment thread yarl/_url.py Outdated
Comment thread tests/test_url.py Outdated
Comment thread tests/test_url.py Outdated
Comment thread tests/test_url.py Outdated
Comment thread tests/test_url.py
@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
Comment thread CHANGES/111.bugfix.rst Outdated
bdraco
bdraco previously approved these changes Nov 18, 2024
@bdraco
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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]>
Comment thread docs/api.rst
@bdraco
Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread tests/test_url.py Outdated
Comment thread tests/test_url.py Outdated
Comment thread tests/test_url.py
Comment thread yarl/_url.py
Comment thread yarl/_url.py
Copy link
Copy Markdown
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.

Comment thread CHANGES/1421.feature.rst Outdated
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Copy link
Copy Markdown
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.

Comment thread docs/api.rst Outdated
Comment thread docs/api.rst Outdated
Comment thread docs/api.rst Outdated
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
Copy Markdown
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
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