Replies: 1 comment 5 replies
-
Yes, pyright doesn't support this form of class creation. It's typically used only for highly dynamic use cases where a static type checker isn't going to work anyway. If your use case doesn't involve dynamic class construction, then you should use the standard class TestCls:
foo = lambda: None
TestCls.foo |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When creating a new class using

type("MyCls", (), {})
, the output is recognized asType[MyCls]
, from the first string, however if the passed dict contains some actual parameters/functions, they will not be recognized as being a part of theMyCls
function created like this.Obviously, it's possible to obtain these parameters and their types from the passed dict, but I'm not too surprised it's not being done, since it's probably only categorized as a dict[str, Any] object, rather than a TypedDict, and that's probably not going to change. Although this is a fairly special case and parsing the dict is worth doing, so maybe it could get some sort of custom treatment?
I fully assume this will not be done, but it's an issue and I didn't find references to this being marked as wontfix anywhere (maybe I just haven't looked too hard though), so I'd like to know if there's any chance of it getting into pyright at some point, or if it's a lost cause.
Beta Was this translation helpful? Give feedback.
All reactions