typeddicts - update conformance tests according to the spec by Andrej730 · Pull Request #1978 · python/typing (original) (raw)
The spec doesn't provide any specific guidance for how type checkers should synthesize methods on TypedDicts (get
, pop
, etc.). Unless you think there's value in standardizing this behavior, we should leave the spec and the conformance tests as is. If you think there's value in standardizing the behavior here (I'm somewhat skeptical that it's worth the effort), then we should amend the spec and update the conformance tests accordingly.
get
should never be rejected because it's safe to call (i.e. doesn't raise an exception) for a not-present key. It even has a form that accepts a default value that is returned when the key isn't present.
The in
operator should also never be rejected because it never raises an exception.
My preference is to leave the conformance test as it is currently and abandon this PR. I think the current test reflects what is in the spec.