stevewedig
stevewedig

Reputation: 294

Disabling Pycharm "Unresolved references" inspection for attribute names but not for variable names?

I would like to preserve the red underlines for unresolved variable names in scopes, which is an inspection that works well and brings up the option to import the name. However I want to disable the warnings for unresolved attributes (e.g. x.y), which is not a reliable inspection due to metaprogramming. These settings appear coupled, which seems rather unfortunate. Is there a workaround or am I missing something simple?

Upvotes: 0

Views: 1139

Answers (1)

Andrey Vlasovskikh
Andrey Vlasovskikh

Reputation: 16838

It's not possible for warnings about all attributes at the moment. You can send a feature request to the PyCharm's issue tracker.

You can disable the unresolved references for a particular class explicitly by decorating it with any custom decorator:

@any_decorator
class C:
    ...

or by putting @DynamicAttrs inside the docstring of the class:

class C:
    """...

    @DynamicAttrs
    """
    ...

or you can do it implicitly by using "Alt+Enter" on the problematic attribute and selecting "Mark all attributes of C as ignored".

Upvotes: 5

Related Questions