strip-none-return
FormattingRemoves a bare -> None return annotation, since an omitted one already reads as returning nothing.
signature-annotations reports a parameter that carries no type annotation, leaving a method's self, a classmethod's cls, and the *args and **kwargs variadics outside the rule. An unannotated parameter is a legibility gap, because the reader meets the function without knowing what it takes, whereas the annotated form lays out cleanly under the align-colons and align-equals columns.
The rule also reports a function whose body returns a value and carries no return annotation. A procedure that returns nothing stays silent, so in a clean file a signature without a return annotation reads as a function that returns nothing. The companion strip-none-return rule enforces the other side of that convention, removing an explicit -> None because the omission already says it.
Prose reads source without resolving types, so the rule never writes an annotation for the author. The report carries a suggestion the reader applies by hand when a confident local signal exists, a literal default (threshold=0.8 suggesting float) or in-module call sites passing only literals. A bare = None default contributes its | None arm only beside another signal, and conflicting or non-literal signals leave the report without a suggestion. The suggestion is recorded as a display-only fix, shown to the reader and never applied.
| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | bool | true | Turns the rule on or off. |
scale's only parameter, factor, defaults to the float literal 2.0 and has no annotation. The rule reports factor with the display-only suggestion factor: float, which it records but never applies, and reports separately that scale returns a value without a return annotation.
def scale(factor=2.0):
return factor * 2
connect's only parameter, host, defaults to None, which contributes no type on its own, and the call connect(host="localhost") passes a str literal by keyword. The rule combines the two into the display-only suggestion host: str | None, and reports separately that connect returns a value without a return annotation.
fetch returns store[key], a value, whereas persist only assigns store[key] = value and returns nothing. fetch draws a missing-return finding beside the findings on its unannotated store and key, and persist draws none, though its three unannotated parameters are still reported.
configured takes the annotated name: str beside the unannotated count and declares -> int. The rule reports count alone, leaving the annotated parameter and the annotated return without a finding.
render's only parameter, width, is passed the int literal 80 at one call and the str literal "full" at another. The rule reports width with no suggested type, because the two calls disagree, and reports separately that render returns a value without a return annotation.
total's only parameter, count, has no annotation, and both call sites, total(3) and total(7), pass an int literal by position. The rule reports count with the display-only suggestion count: int, which it never inserts, and reports separately that total returns a value without a return annotation.
Registry.register's self and Registry.empty's cls are each the first positional parameter of a method, and forward takes only *args and **kwargs. The rule reports register's name as the only parameter, exempting the receivers with or without the @classmethod decorator and skipping the variadics, whereas empty and forward each still draw the separate finding for a missing return type.
Removes a bare -> None return annotation, since an omitted one already reads as returning nothing.
Writes a function signature either on one line or one parameter per line, expanding it once it overflows code-line-length, passes max-params, or carries a parameter spanning rows.
Rewrites Optional[T], Union[X, Y], and the typing generics to the T | None, X | Y, and builtin forms the target runtime supports.
Reports the parenthesized type in a docstring entry that the signature or the class body already annotates.
For per-line opt-outs, the Suppression chapter covers the # prose: ignore[signature-annotations] directive.