Skip to content

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Oct 8, 2025

Summary

We have the following test in protocols.md:

class HasX(Protocol):
    x: int

# […]

class Foo:
    x: int

# […]

class FooBool(Foo):
    x: bool

static_assert(not is_subtype_of(FooBool, HasX))
static_assert(not is_assignable_to(FooBool, HasX))

If Foo was indeed intended to be a base class of FooBool, then x: bool should be reported as a Liskov violation. And then it's a matter of definition whether or not these assertions should hold true or not (should the incorrect override take precedence or not?). So it looks to me like this is just an oversight, probably a copy-paste error from another test right before it, where FooSub is indeed intended to be a subclass of Foo.

I am fixing this because this test started to fail on a branch of mine that changes how attribute lookup in inheritance chains works.

@sharkdp sharkdp added the testing Related to testing Ruff itself label Oct 8, 2025
@sharkdp sharkdp requested a review from dcreager as a code owner October 8, 2025 11:56
@sharkdp sharkdp added the ty Multi-file analysis & type inference label Oct 8, 2025
@sharkdp sharkdp merged commit 6b94e62 into main Oct 8, 2025
37 checks passed
@sharkdp sharkdp deleted the david/fix-another-protocol-test branch October 8, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants