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

Specify type of stream_reader_factory #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hf-kklein
Copy link
Contributor

Fixes mypy warning

aioresponses\compat.py:31: error: All conditional function variants must have identical signatures [misc]

Fixes:
aioresponses\compat.py:31: error: All conditional function variants must have identical signatures  [misc]
@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2022

Codecov Report

Merging #208 (b0786c4) into master (b8393e7) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #208      +/-   ##
==========================================
+ Coverage   95.75%   95.77%   +0.01%     
==========================================
  Files           3        3              
  Lines         283      284       +1     
==========================================
+ Hits          271      272       +1     
  Misses         12       12              
Impacted Files Coverage Δ
aioresponses/compat.py 75.60% <100.00%> (+0.60%) ⬆️

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 b8393e7...b0786c4. Read the comment docs.

Comment on lines 18 to 22

stream_reader_factory: Callable[
[Optional[asyncio.AbstractEventLoop]], StreamReader
]
if AIOHTTP_VERSION >= parse_version('3.0.0'):
Copy link
Contributor

Choose a reason for hiding this comment

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

If mypy reports that error: All conditional function variants must have identical signatures [misc], wouldn't it be better to just add correct type annotations to both variants of stream_reader_factory?

if AIOHTTP_VERSION >= parse_version('3.0.0'):
    from aiohttp.client_proto import ResponseHandler

    def stream_reader_factory(
        loop: Optional[asyncio.AbstractEventLoop] = None
    ) -> StreamReader:
        protocol = ResponseHandler(loop=loop)
        return StreamReader(protocol, limit=2 ** 16, loop=loop)

else:

    def stream_reader_factory(
        loop: Optional[asyncio.AbstractEventLoop] = None
    ) -> StreamReader:
        return StreamReader()

@marcinsulikowski
Copy link
Contributor

Actually, this whole if statement and two versions of stream_reader_factory are not needed, see #223

@hf-kklein
Copy link
Contributor Author

You're right. Merging #224 would make this PR obsolete :)

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