Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix _typing.override
  • Loading branch information
youknowone committed Jun 30, 2025
commit 3f5566da53a35592a1006c0c01075edc956787bd
6 changes: 0 additions & 6 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3351,8 +3351,6 @@ def x(self): ...
self.assertNotIsSubclass(C, Protocol)
self.assertNotIsInstance(C(), Protocol)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_protocols_issubclass_non_callable(self):
class C:
x = 1
Expand Down Expand Up @@ -3412,8 +3410,6 @@ def __init__(self) -> None:
):
issubclass(Eggs, Spam)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_no_weird_caching_with_issubclass_after_isinstance_2(self):
@runtime_checkable
class Spam(Protocol):
Expand All @@ -3434,8 +3430,6 @@ class Eggs: ...
):
issubclass(Eggs, Spam)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_no_weird_caching_with_issubclass_after_isinstance_3(self):
@runtime_checkable
class Spam(Protocol):
Expand Down
5 changes: 4 additions & 1 deletion vm/src/stdlib/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ pub(crate) mod decl {
#[pyfunction(name = "override")]
pub(crate) fn r#override(func: PyObjectRef, vm: &VirtualMachine) -> PyResult {
// Set __override__ attribute to True
func.set_attr("__override__", vm.ctx.true_value.clone(), vm)?;
// Skip the attribute silently if it is not writable.
// AttributeError happens if the object has __slots__ or a
// read-only property, TypeError if it's a builtin class.
let _ = func.set_attr("__override__", vm.ctx.true_value.clone(), vm);
Ok(func)
}

Expand Down
Loading