Hello StackOverflow Community,
Pycharm was giving me a suggestion to make a method static. I know that I don't want to do this.
My code was something along the lines of...
def myClassMethod(self) -> None:
"""
PyCharm wants this function to be static, but I don't.
"""
myOtherMethod('A string')
myOtherMethod('A string')
def myOtherMethod(self, a_str: str) -> None:
"""
This method takes in a string and prints it.
"""
print(a_str)
I don't want the error in PyCharm (cause I am sort of a perfectionist, also because I don't want this false-positive) so can I legally change myClassMethod to something like:
def myClassMethod(self) -> None:
"""
PyCharm wants this function to be static, but I don't.
"""
myOtherMethod(self, 'A string')
myOtherMethod(self, 'A string')
so that PyCharm sees that I've used self in the body of the method? Does calling self explicitly like this effect readability or make it less pythonic?
I have seen another suggestion to place a do_nothing function in the class that simply passes, but this seems like it pollutes the class namespace with a useless function just to get rid of a minor suggestion. Not worth it.