-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Closed
Copy link
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
This came up in ManimCommunity/manim#4398 (comment).
I believe the class definition class B(A): ... should not be allowed by pyright (especially in strict mode), because it can lead to unsoundness, as demostrated in the example below. In fact, mypy currently rejects this (mypy playground)
Describe the bug
A clear and concise description of the behavior you are seeing and the expected behavior along with steps to reproduce it.
Code or Screenshots
Code sample in pyright playground
class A:
def foo(self, /, **kwargs: object) -> None: ...
class B(A):
def foo(self, /, *, x: int = 3, **kwargs: object) -> None:
assert isinstance(x, int) # of course, right?
def use_a(a: A):
a.foo(x="hello") # ok because "hello": str <: object
use_a(A()) # all fine
use_a(B()) # woops, AssertionError!VS Code extension or command-line
Observed in the Pyright playground (online) and verified its run-time behaviour with Python 3.12.11 (macOS arm64)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working