ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[`pylint`] Implement `class-variable-slots-conflict` (`PLE0242`)

Open chanman3388 opened this issue 1 year ago • 5 comments

Summary

Add the pylint rule class-variable-slots-conflict.

Test Plan

New test fixtures added

Part of #970

chanman3388 avatar Mar 09 '24 18:03 chanman3388

This case:

items = ["a"]  # TODO


class NotOk:
    __slots__ = items
    a = None

pylint does catch, is this something we can handle by using the deferred scopes?

chanman3388 avatar Mar 09 '24 18:03 chanman3388

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

github-actions[bot] avatar Mar 09 '24 18:03 github-actions[bot]

Thank's for implementing the new rule. I'm trying to understand the rule, but I couldn't find any useful explanation. Would you mind outlining why this specific pattern is bad or linking to some resources? The wording doesn't need to be final, but it would help me understand and triage the rule.

Hi Michael, thanks for taking a look, yes of course sorry about that. I'll add it when I next get some time.

chanman3388 avatar Mar 28 '24 17:03 chanman3388

Thank's for implementing the new rule. I'm trying to understand the rule, but I couldn't find any useful explanation. Would you mind outlining why this specific pattern is bad or linking to some resources? The wording doesn't need to be final, but it would help me understand and triage the rule.

Not that this excuses me missing it out in the docstring but I did link to this page here. I have since found a page which explains the feature more fully so I'll link that and add a summary at the top level.

chanman3388 avatar Mar 28 '24 19:03 chanman3388

This case:

items = ["a"]  # TODO


class NotOk:
    __slots__ = items
    a = None

pylint does catch, is this something we can handle by using the deferred scopes?

I realised that this could well be handled by performing the lint at the module level instead, would this be sensible?

chanman3388 avatar Apr 25 '24 13:04 chanman3388