Skip to content

duplicate-class-field-definition (PIE794)

Added in v0.0.208 · Related issues · View source

Derived from the flake8-pie linter.

Fix is always available.

What it does

Checks for duplicate field definitions in classes.

Why is this bad?

Defining a field multiple times in a class body is redundant and likely a mistake.

Example

class Person:
    name = Tom
    ...
    name = Ben

Use instead:

class Person:
    name = Tom
    ...

Fix safety

This fix is always marked as unsafe since we cannot know for certain which assignment was intended.