-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Refactor helpers.py to Move Hard-Coded List to globals.py #5555
Conversation
…sible strings. new var name: _false_attributes
for more information, see https://pre-commit.ci
src/flask/globals.py
Outdated
@@ -49,3 +49,5 @@ | |||
session: SessionMixin = LocalProxy( # type: ignore[assignment] | |||
_cv_request, "session", unbound_message=_no_req_msg | |||
) | |||
|
|||
_false_attributes: t.List[str] = ["0", "false", "no", "null", "none"] |
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.
null
and none
do not make sense here, it's not something people would pass for a boolean option.
Also, this does not belong in this file. helpers.py
is already he most suitable path.
But considering that it's already in two very simple utility functions, I'm not sure if it even makes much sense to extract this into a separate list (which, by the way, should be a set and not a list)
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.
it makes better practice. its not hard coded and better to maintaine.
in addition, i aggree that none and null shouldnt be passed as boolean but you can use None as False in python (in a condition. " if None" is will evaluate to False.
@@ -49,3 +49,5 @@ | |||
session: SessionMixin = LocalProxy( # type: ignore[assignment] | |||
_cv_request, "session", unbound_message=_no_req_msg | |||
) | |||
|
|||
_false_attributes: list[str] = ["0", "false", "no", "null", "none"] |
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.
This is a unmarked behavior change, this list is more exhaustive,
This might create trouble for slightly sarcastic deployments
I don't think this change is needed. In general, we do not accept style or refactoring PRs. |
This pull request refactors the
helpers.py
file by moving a hard-coded list of false attributes to theglobals.py
file. The list, previously hard-coded in multiple locations, is now centralized inglobals.py
as a new global constant named_false_attributes
.Changes Made:
Benefits:
Testing: