mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Fix _typing.override
This commit is contained in:
6
Lib/test/test_typing.py
vendored
6
Lib/test/test_typing.py
vendored
@@ -3351,8 +3351,6 @@ class ProtocolTests(BaseTestCase):
|
||||
self.assertNotIsSubclass(C, Protocol)
|
||||
self.assertNotIsInstance(C(), Protocol)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_protocols_issubclass_non_callable(self):
|
||||
class C:
|
||||
x = 1
|
||||
@@ -3412,8 +3410,6 @@ class ProtocolTests(BaseTestCase):
|
||||
):
|
||||
issubclass(Eggs, Spam)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_no_weird_caching_with_issubclass_after_isinstance_2(self):
|
||||
@runtime_checkable
|
||||
class Spam(Protocol):
|
||||
@@ -3434,8 +3430,6 @@ class ProtocolTests(BaseTestCase):
|
||||
):
|
||||
issubclass(Eggs, Spam)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_no_weird_caching_with_issubclass_after_isinstance_3(self):
|
||||
@runtime_checkable
|
||||
class Spam(Protocol):
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user