Hi Paul, all, Am 15.10.21 um 18:49 schrieb Paul Moore:
Mypy correctly rejects this: [...]
interesting. Thanks for trying.
If typeguard doesn't, maybe you need to raise that as a bug against that project?
This is kind of contradicting the design of typeguard. It works on a call level checking arguments and return values for the most part. Typeguard does not provide any form of type inference like mypy does. From this perspective, typeguard would need to guard `dict.__init__`, `dict.__setitem__`, `dict.update` and friends directly, essentially requiring a subclass of `dict` of some sort. However, typeguard does have a special function to perform type checks on objects, e.g. `check_type('variablename', [1234], List[int])` Ignoring typeguard, my suggestion still stands, although slightly changed: Annotating a dictionary as described earlier in such a way that type inference is not required OR in such a way that run-time checkers have a chance to work more easily - if this makes any sense at all? Best regards, Sebastian