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

Add new method without_query_params to drop query keys #898

Merged
merged 40 commits into from
Sep 6, 2024

Conversation

hongquan
Copy link
Contributor

@hongquan hongquan commented Jun 23, 2023

What do these changes do?

Add a method, without_query_params to drop some keys from query part.
For example, dropping "b" in "a=1&b=2&c=3", we get "a=1&c=3".

Are there changes in behavior for the user?

No.

Related issue number

closes #774
closes #1010

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the PR
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: Fix issue with non-ascii contents in doctest text files.

@codecov
Copy link

codecov bot commented Jul 16, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.05%. Comparing base (d080a2e) to head (91a8f62).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #898      +/-   ##
==========================================
+ Coverage   95.02%   95.05%   +0.03%     
==========================================
  Files          30       30              
  Lines        4459     4490      +31     
  Branches      392      396       +4     
==========================================
+ Hits         4237     4268      +31     
  Misses        196      196              
  Partials       26       26              
Flag Coverage Δ
CI-GHA 95.01% <100.00%> (+0.03%) ⬆️
MyPy 40.33% <100.00%> (+0.44%) ⬆️
OS-Linux 99.35% <100.00%> (+<0.01%) ⬆️
OS-Windows 99.45% <100.00%> (+<0.01%) ⬆️
OS-macOS 99.04% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 98.93% <100.00%> (+<0.01%) ⬆️
Py-3.10.14 99.18% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 99.18% <100.00%> (+<0.01%) ⬆️
Py-3.12.5 99.18% <100.00%> (+<0.01%) ⬆️
Py-3.13.0-rc.1 99.18% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 98.87% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 99.13% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 98.87% <100.00%> (+<0.01%) ⬆️
Py-3.9.19 99.13% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.11 99.18% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 99.18% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.17 99.21% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 99.04% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 99.35% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 99.45% <100.00%> (+<0.01%) ⬆️
pytest 99.35% <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.

@mjpieters
Copy link
Contributor

I really do appreciate that you put in the work for a PR here, but I'd like to first see more discussion about what the API should look like. Can you please first propose this API change in the issue?

(I'm not 100% convinced that the name drop_query_keys() is right here; perhaps without_query_keys() is better as you are returning a new URL rather than mutating the existing URL in-place).

@hongquan
Copy link
Contributor Author

Thanks. I think without_query_keys is a better name.

@mjpieters mjpieters requested a review from asvetlov July 16, 2023 18:41
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Aug 30, 2023
docs/api.rst Outdated Show resolved Hide resolved
CHANGES/898.feature.rst Outdated Show resolved Hide resolved
tests/test_url_query.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
@webknjaz
Copy link
Member

@mjpieters @hongquan how would you feel about URL.without_query_params()? The RFCs usually use this term...

@webknjaz webknjaz linked an issue Nov 20, 2023 that may be closed by this pull request
1 task
@hongquan
Copy link
Contributor Author

Agree with without_query_params name.

CHANGES/898.feature.rst Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
yarl/_url.py Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
bdraco and others added 3 commits September 6, 2024 10:24
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
tests/test_url_query.py Outdated Show resolved Hide resolved
tests/test_url_query.py Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
@bdraco bdraco changed the title Method to drop query keys Add new method without_query_params to drop query keys Sep 6, 2024
@bdraco bdraco changed the title Add new method without_query_params to drop query keys Add new method without_query_params to drop query keys Sep 6, 2024
docs/api.rst Show resolved Hide resolved
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
docs/api.rst Show resolved Hide resolved
docs/api.rst Outdated Show resolved Hide resolved
yarl/_url.py Outdated Show resolved Hide resolved
CHANGES/898.feature.rst Outdated Show resolved Hide resolved
bdraco added a commit that referenced this pull request Sep 6, 2024
For new public feature #898
Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Thanks @hongquan

@bdraco bdraco merged commit 2c531c7 into aio-libs:master Sep 6, 2024
47 of 49 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.

Ability to remove a specific query parameter Ability to remove a query value while retaining others
5 participants