Skip to content

mbeliaev/resp types#535

Merged
markstory merged 1 commit intogetsentry:masterfrom
beliaev-maksim:mbeliaev/resp_types
Apr 11, 2022
Merged

mbeliaev/resp types#535
markstory merged 1 commit intogetsentry:masterfrom
beliaev-maksim:mbeliaev/resp_types

Conversation

@beliaev-maksim
Copy link
Copy Markdown
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
Copy Markdown

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.

Comment thread responses/__init__.py
stream = False
passthrough: bool = False
content_type: Optional[str] = None
headers: Optional[Mapping[str, str]] = None
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

@beliaev-maksim beliaev-maksim Apr 5, 2022

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.

2 participants