
On Fri, 18 Aug 2023 at 15:58, Zixuan James Li <zixuan.li@nyu.edu> wrote:
Oops, the PR link: https://github.com/python/typeshed/pull/2207
On Fri, Aug 18, 2023, 10:51 Zixuan James Li <zixuan.li@nyu.edu> wrote:
typeshed uses Any: https://github.com/python/typeshed/blob/main/stdlib/types.pyi#L329-335
As noted in the PR, SimpleNamespace appears to need a plugin to understand specific types of the arguments/keys. It would be a good chance to raise an issue for mypy.
I thought the OP's point was that it's not possible to define a type that allows the user to assign arbitrary attributes - or rather that type checkers can't handle such a type. Given that SimpleNamespace is *exactly* such a type, I'd have hoped that making pytest.Item a subclass of SimpleNamespace would work. If it doesn't, then I would view that as something that type checkers should address, rather than as something that user code should be expected to work around. Paul