-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
Move remaining utility functions from _utils.py to _models.py #3387
Move remaining utility functions from _utils.py to _models.py #3387
Conversation
bd63ac9
to
faa69b5
Compare
The following functions are moved because they are only used in _models.py * is_known_encoding * parse_header_links * parse_content_type_charset * obfuscate_sensitive_headers Related tests are also moved accordingly.
`ruff <path>` has been removed. Use `ruff check <path>` instead.
faa69b5
to
81bb8d1
Compare
@tomchristie I first overlooked that I should also move some of the related tests. I did this now 🙂 |
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.
I'm note sure if test_encoded
, test_bad_utf_like_encoding
, and test_guess_by_bom
are related to the moved function is_known_encoding
and therefore should be moved into tests related to models?
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.
Thanks.
return links | ||
|
||
|
||
def _obfuscate_sensitive_headers( |
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.
Is now a good time to review this? Eg does flask provide similar behaviour onto its headers data structures? Does Django?
(Possibly too off topic??)
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 seems that flask does not obfuscate header values for repr
(see werkzeug)
>>> from werkzeug.datastructures import Headers
>>>
>>> head = Headers({"authorization": "s3kr3t"})
>>> head
Headers([('authorization', 's3kr3t')])
>>> repr(head)
"Headers([('authorization', 's3kr3t')])"
Same for Django (see HttpHeaders or ResponseHeaders)
>>> from django.http.response import ResponseHeaders
>>> head = ResponseHeaders({"Authorization": "s3kr3t"})
>>> repr(head)
"{'Authorization': 's3kr3t'}"
Summary
Related issue: #3381
This PR moves the following remaining utility functions from
_utils.py
to_models.py
that are only used in_models.py
(exceptto_bytes_or_str
):is_known_encoding
parse_header_links
parse_content_type_charset
obfuscate_sensitive_headers
Related tests are also moved accordingly, i.e. from
tests/test_utils.py
totests/models/test_headers.py
.Additionally, this PR fixes the script
scripts/lint
by usingruff check
due to the following error:Checklist