Skip to content
Advertisement

Pylint throws not-callable on decorator defined within class

Im trying to create a class that has a time remaining property and executing functions within it reduces this time. Here is the code

JavaScript

Then when i instantiaite the class and use do_something like so:

JavaScript

It works as expected. However when i run pylint on the code i get an error:

JavaScript

Is this a false positive or is there a better way to write this functionality?

Thanks

Advertisement

Answer

Thanks for the comments. Moving the method outside the class was what was required as self is bound depending on how a method is called, not where it is defined so the decorator doesn’t need to be defined within the class to have access to self:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement