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

mbeliaev/resp types #535

Merged
merged 1 commit into from Apr 11, 2022
Merged

Conversation

beliaev-maksim
Copy link
Collaborator

add type annotations to Response objects.

until do a full type migration we have to keep redundant definition in stub file

@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #535 (3565faa) into master (bf30737) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 3565faa differs from pull request most recent head cf4404e. Consider uploading reports for the commit cf4404e to get more accurate results

@@            Coverage Diff            @@
##            master      #535   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines         2378      2382    +4     
=========================================
+ Hits          2378      2382    +4     
Impacted Files Coverage Δ
responses/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf30737...cf4404e. Read the comment docs.

stream = False
passthrough: bool = False
content_type: Optional[str] = None
headers: Optional[Mapping[str, str]] = None
Copy link
Member

Choose a reason for hiding this comment

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

Could this also be the list of tuples? Or has that been normalized by this point.

headers=(('X-CSRF', 'random-string'), ('Content-Length', 4),)

is the format I'm thinking of.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@markstory
thing becomes a bit more complecated since we use HTTPHeaderDict

it has type:
class HTTPHeaderDict(MutableMapping[str, str]):, see
https://github.com/urllib3/urllib3/blob/e16beb210c03c6f5ce4e0908bddb6556442b6a37/src/urllib3/_collections.py#L211

then in our implementatino here, we extend it:

headers.extend(self.headers)

and extend takes either HTTPHeaderDict, Mapping or Iterable:
https://github.com/urllib3/urllib3/blob/e16beb210c03c6f5ce4e0908bddb6556442b6a37/src/urllib3/_collections.py#L334

so, generally list of tuples should be supportes and standard dict as well

@markstory markstory merged commit df920c0 into getsentry:master Apr 11, 2022
@beliaev-maksim beliaev-maksim deleted the mbeliaev/resp_types branch April 11, 2022 13:44
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.

None yet

2 participants