Skip to content

PY-FUNC0001 · unjustified_positional_only_parameter_count

Count positional-only parameters without an observable structural reason.

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

Inspect module functions and direct methods that use /. Treat the marker as justified for a magic method, an explicit @override, a member of a class inheriting Protocol, a function that also accepts arbitrary keyword arguments, or a configured compatibility name. Report every other positional-only parameter except self and cls. The result is the number of reported parameters.

Each finding identifies the function and names its positional-only parameters. The rule uses syntax that is stable across runs and does not infer whether a name feels semantically useful. The value is the number of positional-only parameters with no structural reason.

Builtin or C API parity, a published compatibility contract, deliberately unnamed mathematical operands, and functions passed as callbacks are excluded. A member of a class inheriting Protocol states the structural contract an existing object already satisfies, so the marker it copies is the contract rather than a hidden name. Additional compatibility names can be added through allowed_names. Nested local functions are outside this public interface check.

Bad

`def load_document(path, /)` hides a meaningful public name without a collision or override.
Good

def lookup(name, /, **keywords) permits name to appear independently in keywords. def __eq__(self, other, /) follows a magic method contract. def read1(self, size=-1, /) on a class inheriting Protocol mirrors the reader it describes, so it stays quiet.