Skip to content

PY-NAMI0001 · boolean_predicate_name

Require Boolean symbols to read as predicates.

This is a deterministic rule for python. Read its implementation.

Require attributes, properties, functions, and methods proven to return Boolean values to begin with a configured question prefix after removing any visibility prefix. The default prefixes are is_, has_, can_, should_, and supports_.

Each finding names the symbol, the exact place it is declared, and how many references a rename would have to move with it, which is what says whether the repair is safe. The rename itself arrives from the fix this rule already declares rather than from a second statement of the same edit. A symbol whose references are incomplete is reported and left unrepaired.

Exclude local variables, Python special methods, required overrides, and names imposed by an external framework or protocol.

ready: bool fails while is_ready: bool passes. A required __contains__ method is excluded even though it returns bool.

  • Adapts Pylint C0103 invalid-name
  • Cites “PEP 8, Style Guide for Python Code”, naming conventions
  • Cites “The Python Standard Library”, predicate naming conventions
  • Cites “Clean Code”, meaningful names