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

Improve typings for multipart #3905

Merged
merged 3 commits into from
Jul 19, 2019
Merged

Improve typings for multipart #3905

merged 3 commits into from
Jul 19, 2019

Conversation

kornicameister
Copy link
Contributor

What do these changes do?

Removes usage of Any type from multipart.py and wherever those changes introduced mypy errors.

Are there changes in behavior for the user?

No, there should not be any changes for use.

Related issue number

#3621

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (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."

Copy link
Contributor Author

@kornicameister kornicameister left a comment

Choose a reason for hiding this comment

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

@asvetlov I tried my best to make it small but changes required in web_request did what they did to diff.
I left some comments though proposing further changes if you wish to.

Also...I can't tell if CI passes this time because locally:

  • mypy passed (and I hope it will here as well)
  • flake behaves strangely for me in a way that it constantly fails...don't know why exactly is that but it shows a lot of issues with the codebase while where checking other builds I see it passing)

@@ -195,21 +194,26 @@ def content_disposition_filename(params: Mapping[str, str],


class MultipartResponseWrapper:
"""Wrapper around the MultipartBodyReader.
"""Wrapper around the MultipartReader.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no such of thing as MultipartBodyReader so decided to go with MultipartReader as the only thing that matched the interface. I will give it another look, but for now that was the thing that matched.

if field_ct is None or \
field_ct.startswith('text/'):
charset = field.get_charset(default='utf-8')
out.add(field.name, value.decode(charset))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

that accounts for producing str from post

charset = field.get_charset(default='utf-8')
out.add(field.name, value.decode(charset))
else:
out.add(field.name, value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is for bytes

max_size=max_size,
actual_size=size
)
raise ValueError(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given the documentation, I assume that behavior here is correct and decoding nested multipart is a custom job.

@asvetlov asvetlov closed this Jul 19, 2019
@asvetlov asvetlov reopened this Jul 19, 2019
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

lgtm

@kornicameister
Copy link
Contributor Author

@asvetlov if that's approved and by default will be merged soon, may I ask if you would prefer another issue for async for first, or make next PR for the same issue?

@asvetlov
Copy link
Member

async for requires a separate PR

@asvetlov
Copy link
Member

@webknjaz I see the yellow status for Timeline protection checker.
I understand it as the checker was not stated (or crashed after start maybe).
Please take a look when you have free time.
For now I'm merging the PR regardless of this status.

@asvetlov asvetlov merged commit d7b08ad into aio-libs:master Jul 19, 2019
asvetlov pushed a commit that referenced this pull request Jul 19, 2019
(cherry picked from commit d7b08ad)

Co-authored-by: Tomasz Trębski <tomasz.trebski@ts.fujitsu.com>
@webknjaz
Copy link
Member

@asvetlov thanks for the hint. It's probably better to create issues @ https://github.com/sanitizers/chronographer-github-app/issues/new for better visibility. I've almost missed this one :)

asvetlov added a commit that referenced this pull request Jul 19, 2019
(cherry picked from commit d7b08ad)

Co-authored-by: Tomasz Trębski <tomasz.trebski@ts.fujitsu.com>
@kornicameister kornicameister deleted the multipart_improve branch July 19, 2019 17:59
@webknjaz
Copy link
Member

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

Successfully merging this pull request may close these issues.

3 participants