[Feature Request]Allow specifically turning off diagnosis Type of parameter "self" must be a supertype of its class
#10946
Replies: 1 comment
-
|
This would be very much appreciated. I am working with an API of a closed-source software package that requires the user to define decorated "action classes" whose contents are essentially treated like static methods: @ctx.action_class("user")
class UserActions:
def code_insert_function(text: str, selection: str):
<implementation irrelevant>Thus, this leads to a false positive whenever the first argument of such a function has a type annotation. Further, functions inside these classes tend to be numerous and short, meaning that annotating them individually with Of course, it would be even better if one could inform pyright that these annotations mean that everything in the class is treated as a static method, but this sounds like a much bigger change. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to find a way to silence reports of
Type of parameter "self" must be a supertype of its classwithout turning offreportGeneralTypeIssues.There are many times that I need to restrict the type of
selfinto a smaller subset, mostly with mixins and metaclasses. For mixins, it can be resolved by conforming totyping.Protocol. But for metaclasses, same actions cannot be done because there are conflicts betweentypeandtyping.Protocol.Sample --
See line 14. The
# pyright: ignore[reportGeneralTypeIssues]comment is working, but I feel a bit nervous using it as it sometimes can shadow other real problems.I have an alternative solution like --
, but the usage of
overloadis not intuitive and deviates from its original purpose.Beta Was this translation helpful? Give feedback.
All reactions