On 31/12/23 8:05 am, Chris Angelico wrote:
Ah, I think you've hit on the problem there. Consider this:
def add_item(stuff: dict[str: str | int]):
stuff["spam"] = "ham"
stuff["vooom"] = 1_000_000
Yep, that's it exactly. It's not the union itself that's the problem,
but the fact that
On Sun, 31 Dec 2023 at 03:38, Thomas Passin via Python-list
wrote:
> I am not very expert in Python type hints. In working up the example
> program I just posted, I got an error message from mypy that remarked
> that "list" is invariant, and to try Sequence which is "covariant". I
> don't know
On 12/30/2023 10:08 AM, Karsten Hilbert via Python-list wrote:
Dear Thomas,
thanks for taking the time to look into my issue.
Maybe it helps if I explain what I want (sorry that my web mailer does not
respect
indentation, I will insert dots).
I want a function to run SQL queries:
On 12/30/2023 10:08 AM, Karsten Hilbert via Python-list wrote:
Dear Thomas,
thanks for taking the time to look into my issue.
Maybe it helps if I explain what I want (sorry that my web mailer does not
respect
indentation, I will insert dots).
I want a function to run SQL queries:
Dear Thomas,
thanks for taking the time to look into my issue.
Maybe it helps if I explain what I want (sorry that my web mailer does not
respect
indentation, I will insert dots).
I want a function to run SQL queries:
run_queries(conn, queries):
...for q in queries:
..conn.execute(q)
I
Hi Greg,
> dict[str, str] is not a subtype of dict[str, str | something_else]
> because you can assign a value of type something_else to the latter
> but not the former.
I understand what you are saying but I do not yet understand why this
applies to my situation.
I don't have Python at hand