Allow positional-only params with defaults in method overrides by carljm · Pull Request #23037 · astral-sh/ruff (original) (raw)

@carljm added the ty

Multi-file analysis & type inference

label

Feb 2, 2026

@claude

… defaults

When a subclass method has a positional-only parameter with a default value and the base class overload has only keyword parameters (**kwargs), the override should be valid because callers don't need to provide the positional argument.

Previously, the signature comparison logic at signatures.rs:1618-1624 would unconditionally reject any unmatched positional-only parameter when comparing against a base signature that only had keyword parameters. This fix adds a check for whether the positional-only parameter has a default value, and only rejects it if it doesn't.

Fixes astral-sh/ty#2693

https://claude.ai/code/session_011QG3kSTsewc8vNsUTtVL9G

@carljm carljm marked this pull request as ready for review

February 2, 2026 16:52

dhruvmanila

@carljm

carljm

@carljm carljm deleted the claude/liskov-substitution-analysis-Glysa branch

February 3, 2026 15:58

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})