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

change chained maps to MutableMapping; fix #6042 #6044

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

ramalho
Copy link
Contributor

@ramalho ramalho commented Sep 17, 2021

collections.ChainMap is annotated as a MutableMapping, therefore the mappings it holds must also be MutableMapping.

As it is, operations that update any of the chained mappings are flagged as errors.

This fixes issue #6042

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas.git)
+ pandas/compat/chainmap.py:21: error: Redundant cast to "MutableMapping[_KT, _VT]"  [redundant-cast]
+ pandas/compat/chainmap.py:25: error: Redundant cast to "MutableMapping[_KT, _VT]"  [redundant-cast]
+ pandas/compat/chainmap.py:35: error: Redundant cast to "MutableMapping[_KT, _VT]"  [redundant-cast]
+ pandas/core/computation/scope.py:241: error: unused "type: ignore" comment

python-chess (https://github.com/niklasf/python-chess.git)
+ chess/engine.py:1438: error: Argument 1 to "ChainMap" has incompatible type "Mapping[str, Union[str, int, bool, None]]"; expected "MutableMapping[str, Union[str, int, None]]"
+ chess/engine.py:1460: error: Argument 1 to "ChainMap" has incompatible type "Mapping[str, Union[str, int, bool, None]]"; expected "MutableMapping[str, Union[str, int, None]]"
+ chess/engine.py:2351: error: Argument 1 to "ChainMap" has incompatible type "Mapping[str, Union[str, int, bool, None]]"; expected "MutableMapping[str, Union[str, int, None]]"

edgedb (https://github.com/edgedb/edgedb.git)
+ edb/schema/delta.py:1157:38: error: Argument 1 to "ChainMap" has incompatible type "*List[Mapping[Optional[str], str]]"; expected "MutableMapping[Optional[str], str]"

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