Removes deprecated cgi function and replaces with email.message.Message#1
Removes deprecated cgi function and replaces with email.message.Message#1amwell-engineering wants to merge 4 commits into
Conversation
| # Adapted from https://peps.python.org/pep-0594/#cgi | ||
| m = Message() | ||
| m['content-type'] = value | ||
| return dict(m.get_params()) |
There was a problem hiding this comment.
This doesn't seem quite right. It returns a single value, but the return type is expected to be two values. Also the get_params method is stated to be a legacy function. I think we should be using the EmailMessage replacement described here: https://docs.python.org/3.12/library/cgi.html#cgi.parse_header
def parse_separated_header(value: str):
msg = EmailMessage()
msg['content-type'] = 'application/json; charset="utf8"'
main, params = msg.get_content_type(), msg['content-type'].params
return main, params| if not content_type: | ||
| return default | ||
| content_type, params = parse_header(content_type) | ||
| content_type, params = parse_separated_header(content_type) |
There was a problem hiding this comment.
This documentation does not match the code. Is this auto-generated, or do we have to edit this by hand?
Should be:
content_type = Parse_separated_header(content_type)There was a problem hiding this comment.
There are other changes not present in this documentation file as well -- the parse_separated_header function, the imports... This should be generated by pdoc3, but I think the original author gitignored any files related to generating docs, so it's hard to know what their process was. If I just run pdoc on this project, I get slightly broken formatting, but it looks close to the original docs.
Replaces use of cgi