mypy question

Karsten Hilbert Karsten.Hilbert at gmx.net
Fri Dec 29 07:33:45 EST 2023


Am Fri, Dec 29, 2023 at 01:15:29PM +0100 schrieb Karsten Hilbert via Python-list:

> I am not sure why mypy thinks this
>
> gmPG2.py:554: error: Argument "queries" to "run_rw_queries" has incompatible type "List[Dict[str, str]]"; expected
> "List[Dict[str, Union[str, List[Any], Dict[str, Any]]]]"  [arg-type]
>                     rows, idx = run_rw_queries(link_obj = conn, queries = queries, return_data = True)
>                                                                           ^~~~~~~
>
> should be flagged. The intent is for "queries" to be
>
> a list
> 	of dicts
> 		with keys of str
> 		and values of
> 			str OR
> 			list of anything OR
> 			dict with
> 				keys of str
> 				and values of anything
>
> I'd have thunk list[dict[str,str]] matches that ?
>
> This is on Python 3.11.2 with mypy 1.0.1 on Debian.

For completeness, this was the mypy call signature:

	mypy --pretty --allow-redefinition --no-strict-optional --ignore-missing-imports --follow-imports silent --show-error-codes --warn-unused-ignores gmPG2.py

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B


More information about the Python-list mailing list