Home > OS >  Make IDEA detect unresolved attributes in a decorated class
Make IDEA detect unresolved attributes in a decorated class

Time:02-18

I've got a decorator which returns its argument unchanged, that is Deco(cls) == cls. IDEA (most recent version) fails to report unresolved attributes on a decorated class.

I guess I have to provide some clever type hinting for Deco. How would that look exactly?

class A:
    def foo(self):
        print(self)


A().foo()
A().no_such_thing()  # red line, correct


class Deco:
    def __call__(self, cls):
        return cls


@Deco()
class B:
    def foo(self):
        print(self)


B().foo()
B().no_such_thing()  # no red line, WRONG

enter image description here

CodePudding user response:

This is a known issue https://youtrack.jetbrains.com/issue/PY-30190, feel free to vote for it and leave comments.

  • Related