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

CIMultiDict has incompatible type Dict[istr, str] #644

Closed
rugleb opened this issue Nov 8, 2021 · 4 comments · Fixed by #677
Closed

CIMultiDict has incompatible type Dict[istr, str] #644

rugleb opened this issue Nov 8, 2021 · 4 comments · Fixed by #677

Comments

@rugleb
Copy link

rugleb commented Nov 8, 2021

Long story short

The mypy checks fail if the dictionary keys passed to the constructor are of the istr type.

Expected behaviour

The mypy checks have passed.

Actual behaviour

Error from mypy:

headers.py:5: error: Argument 1 to "CIMultiDict" has incompatible type "Dict[istr, str]"; expected "Union[Mapping[Union[str, istr], Any], Dict[Union[str, istr], Any], MultiMapping[Any], Iterable[Tuple[Union[str, istr], Any]]]"

Steps to reproduce

Run mypy on this script:

from aiohttp import hdrs
from multidict import CIMultiDict, CIMultiDictProxy

headers = CIMultiDictProxy(
    CIMultiDict({
        hdrs.CONTENT_LENGTH: "40",
        hdrs.CONTENT_TYPE: "text/xml",
    })
)

Your environment

Python v3.9.4
aiohttp v3.7.4.post0
multidict v5.1.0
mypy v0.910

@asvetlov
Copy link
Member

asvetlov commented Nov 9, 2021

Would you make a Pull Request with fix?

@rugleb
Copy link
Author

rugleb commented Nov 9, 2021

Yes!

@rugleb
Copy link
Author

rugleb commented Nov 9, 2021

I don't quite understand how to fix it.
I thought that i should fix the _Arg type, but it already support Mapping[_S, _T] where _S = Union[str, istr]. So, I'm confused.

q0w added a commit to q0w/multidict that referenced this issue Jan 19, 2022
q0w added a commit to q0w/multidict that referenced this issue Jan 19, 2022
asvetlov pushed a commit that referenced this issue Jan 22, 2022
* Fix #644

* Add changelog

* Get path obj from stem

* Fix changelog
@asvetlov
Copy link
Member

The PR breaks aiohttp and almost every project that depends on multidict.
Should revert it, sorry.

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 a pull request may close this issue.

2 participants