Skip to content

new rule - detect when decorators are in the wrong order #6697

@DetachHead

Description

@DetachHead

some examples:

from collections.abc import Iterator
from contextlib import contextmanager


class Foo:
    @contextmanager
    @staticmethod
    def foo() -> Iterator[None]:
        yield None

    def bar(self):
        with self.foo():
            ...


Foo().bar() # TypeError: Foo.foo() takes 0 positional arguments but 1 was given
from abc import abstractmethod

class Foo:
    @abstractmethod # AttributeError: attribute '__isabstractmethod__' of 'property' objects is not writable
    @property
    def foo(self) -> int:
        ...

both of these errors are fixed by swapping the order of the decorators

Metadata

Metadata

Labels

acceptedReady for implementationruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions