pyre-check
pyre-check copied to clipboard
Missing argument false positive
the example py:
class classonlymethod(classmethod):
def __get__(self, instance, cls=None):
if instance is not None:
raise AttributeError("This method is available only on the class, not on instances.")
return super(classonlymethod, self).__get__(instance, cls)
class Test:
@classonlymethod
def say(cls):
print('hello')
Test.say()
the classonlymethod
decorator copy from from django.utils.decorators import classonlymethod
the ouput:
No watchman binary found.
To enable pyre incremental, you can install watchman: https://facebook.github.io/watchman/docs/install.html
Defaulting to non-incremental check.
ƛ Found 1 type error!
classonly.py:12:0 Missing argument [20]: Call `classonly.Test.say` expects argument `cls`.
@lovemyliwu it should work if you use the @classmethod
decorator. Is there a specific reason you wanted to use the classonlymethod
decorator instead?
I've got the same problem, I use the @classonlymethod
annotation to make sure that callers have to use the full class name instead of self
. It helps reason about what the method might do.
If I could get some pointers on how to make the change I'd be happy to submit a PR? From my naive perspective it seems like it's just a matter of adding @classonlymethod
to definition for @classmethod
and adding a restriction that it can only be used on the class, not an instance.
Im currently working on supporting class-based decorators like classonlymethod, this hopefully should be in the next release
On Thu, May 28, 2020 at 8:34 PM Jon Janzen [email protected] wrote:
I've got the same problem, I use the @classonlymethod annotation to make sure that callers have to use the full class name instead of self. It helps reason about what the method might do.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/facebook/pyre-check/issues/195#issuecomment-635737937, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCXRUAU2FR6PXZLQKXQK6DRT4ULZANCNFSM4IKF3ENA .
-- -Mark A. Mendoza