pep8-naming
pep8-naming copied to clipboard
Classmethod decorators may not be standalone
I have a related problem to #38: SQLAlchemy has a hybrid_property
module that allows declaring a property distinctly for the instance and the class:
class MyClass(...):
@hybrid_property
def my_property(self):
...
@my_property.setter
def my_property(self, value):
...
@my_property.expression
def my_property(cls): # NOQA: N805
...
@my_property.comparator
def my_property(cls): # NOQA: N805
...
Since expression
and comparator
are contained within the property, I can't simply use --classmethod-decorators=expression,comparator
to turn off warnings for them. I need to explicitly use NOQA: N805
each time.
It'll be nice if classmethod-decorators
accepted a pattern instead of a symbol name.
This is similar to #82, which proposes something similar (glob support) to ignore-names
.
This would be really useful to have. Right now I have no choice but disabling N805
because honestly, adding noqa for almost 50 sqlalchemy hybrid property expression functions would be way too much noise...
How quickly would this make it into a release if I were to submit a PR for it?
So while looking into how to implement this I realized that only the last segment in case of dotted decorator name is used. So this works fine in an application that uses SQLAlchemy hybrids:
classmethod_decorators =
classmethod
declared_attr
expression
comparator