Method parameter types using CLI #8938
-
Hello!
and the result after running
I would have expected PS: is there also any way for the CLI to output inferred types within method/function bodies? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, there's no option like that. Adding
Symbols defined within a function body (local variables) are never emitted within a stub. Symbols defined within a class body are emitted, but their inferred type is not generated by pyright. Inferred types can be inaccurate, so it's best to add those by hand so they match the real intent of the library author. |
Beta Was this translation helpful? Give feedback.
No, there's no option like that. Adding
Any
parameter annotations is not recommended in this case. It obscures the fact that the parameter is missing type information and leads to a false sense of type safety for users of the stub. It is recommended that stubs that are missing type information simply omit the corresponding annotation. When such a stub is used in pyright, these missing annotations will be translated to anUnknown
type rather thanAny
, and this will tell users that they are at risk because of missing type information.Symbols defined within a function body (local variables) are never …