Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classmethod decorators may not be standalone #119

Open
jace opened this issue Jul 10, 2019 · 3 comments
Open

Classmethod decorators may not be standalone #119

jace opened this issue Jul 10, 2019 · 3 comments

Comments

@jace
Copy link

jace commented Jul 10, 2019

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.

@jace jace changed the title Classmethod decorators as properties of other attributes Classmethod decorators may not be standalone Jul 10, 2019
@jparise
Copy link
Member

jparise commented Jan 2, 2020

This is similar to #82, which proposes something similar (glob support) to ignore-names.

@ThiefMaster
Copy link

ThiefMaster commented Mar 29, 2023

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?

@ThiefMaster
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants