Skip to content

Fails mypy --strict because of reexports #3868

Closed
@AMDmi3

Description

@AMDmi3

Long story short

With python 3.7, fresh mypy 0.711:

import aiohttp
aiohttp.ClientSession
% mypy --strict test.py
test.py:3: error: Module has no attribute "ClientSession"

This happens because mypy --strict expects imported stuff reexported as in

from .client import BaseConnector as BaseConnector

while aiohttp/__init.py__ just imports stuff:

from .client import (BaseConnector, ...)

Related: python/mypy#7067

Expected behaviour

Clean mypy --strict, as these errors break checking code which uses aiohttp

Activity

webknjaz

webknjaz commented on Jun 25, 2019

@webknjaz
Member

Feel free to send a PR :)

AMDmi3

AMDmi3 commented on Jun 26, 2019

@AMDmi3
ContributorAuthor

Would it be OK stylewise to just convert to a bunch of from .foo import bar as bar lines?

webknjaz

webknjaz commented on Jun 26, 2019

@webknjaz
Member

That's a question to @asvetlov. I don't mind personally.

asvetlov

asvetlov commented on Jun 26, 2019

@asvetlov
Member

Would it be OK stylewise to just convert to a bunch of from .foo import bar as bar lines?

Yes. Whatever works for you and isort tool :)

Please make sure that both __init__.py and web.py are processed.
[mypy] section from setup.cfg worth to be upgraded to support the most strict mode.
The problem is that mypy doesn't support strict=true in config files but requires decomposition of this mode into a bunch of separate flags. mypy is expanding, new options are added to the tool but we didn't change our config file yet.

30 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Fails `mypy --strict` because of reexports · Issue #3868 · aio-libs/aiohttp