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

typing: MultiDict.update accepts Iterable Mapping values. #2142

Merged
merged 1 commit into from Jun 2, 2021

Conversation

MaicoTimmerman
Copy link
Contributor

MultiDict.__init__ correctly represents it, however the update was missing the iterable variant.

Also, flipped the order of Iterable[V] and V fixes PyCharm's naive matching for generics. Mypy would accept both versions, however PyCharm would only try to infer Mapping's V as the List. By listing it second it will first try to map to the Iterable[V].

  • fixes #

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@pgjones
Copy link
Member

pgjones commented Jun 1, 2021

Are you also able to report the ordering to PyCharm as a bug?

I've changed the target to 2.0.x.

@pgjones pgjones changed the base branch from main to 2.0.x June 1, 2021 16:00
@pgjones
Copy link
Member

pgjones commented Jun 1, 2021

Could you add a changelog entry to note you've fixed the update method typing?

MultiDict.__init__ correctly represents it, however the update was
missing the iterable variant.

Also, flipped the order of Iterable[V] and V fixes PyCharm's naive
matching for generics. Mypy would accept both versions, however PyCharm
would only try to infer Mapping V as the List. By listing it second it
will first try to map to the Iterable[V].
@MaicoTimmerman
Copy link
Contributor Author

@pgjones I've added a changelog entry.

I'll try and make time to create a minimal-reproducable example to submit to PyCharm.

@pgjones pgjones added the typing label Jun 2, 2021
@pgjones pgjones added this to the 2.0.2 milestone Jun 2, 2021
@pgjones pgjones merged commit f61d9a3 into pallets:2.0.x Jun 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants