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

Simplify (request.cookies.)getlist function #2838

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Tronic
Copy link
Member

@Tronic Tronic commented Oct 14, 2023

Removes a default value in case no matches were found, in which case it previously defaulted to None. Instead, return an empty list which is more sensible in this case as the return value will then always be a list.

Presumably practically no-one uses this functionality, and Pythonic tests if None and if [] are equal. In case you do need a default value, there is an easy and a more efficient alternative because the fallback value after or is only constructed if needed and not in any case:

list_of_foo = request.cookies.getlist("foo") or ["my", "default", "value"]

… none are found. Previously it defaulted to returning `None`. Instead return an empty list which is sensible and avoids ambiguity with return types.
@Tronic Tronic requested a review from a team as a code owner October 14, 2023 19:30
@codecov
Copy link

codecov bot commented Oct 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a5a9658) 88.387% compared to head (b692309) 88.429%.
Report is 17 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2838       +/-   ##
=============================================
+ Coverage   88.387%   88.429%   +0.041%     
=============================================
  Files           92        92               
  Lines         7156      7156               
  Branches      1228      1228               
=============================================
+ Hits          6325      6328        +3     
+ Misses         575       574        -1     
+ Partials       256       254        -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants