diff --git a/conformance/third_party/conformance.exp b/conformance/third_party/conformance.exp index a585dfd1ad..2e31af72fc 100644 --- a/conformance/third_party/conformance.exp +++ b/conformance/third_party/conformance.exp @@ -9895,39 +9895,6 @@ "stop_column": 26, "stop_line": 100 }, - { - "code": -2, - "column": 16, - "concise_description": "assert_type(Any, tuple[type, ...]) failed", - "description": "assert_type(Any, tuple[type, ...]) failed", - "line": 102, - "name": "assert-type", - "severity": "error", - "stop_column": 45, - "stop_line": 102 - }, - { - "code": -2, - "column": 16, - "concise_description": "assert_type(Any, tuple[type, ...]) failed", - "description": "assert_type(Any, tuple[type, ...]) failed", - "line": 106, - "name": "assert-type", - "severity": "error", - "stop_column": 45, - "stop_line": 106 - }, - { - "code": -2, - "column": 16, - "concise_description": "assert_type(Any, tuple[type, ...]) failed", - "description": "assert_type(Any, tuple[type, ...]) failed", - "line": 110, - "name": "assert-type", - "severity": "error", - "stop_column": 45, - "stop_line": 110 - }, { "code": -2, "column": 5, diff --git a/conformance/third_party/conformance.result b/conformance/third_party/conformance.result index 96f9db31e2..e4683f7ddb 100644 --- a/conformance/third_party/conformance.result +++ b/conformance/third_party/conformance.result @@ -284,9 +284,6 @@ "Line 84: Unexpected errors ['assert_type(type, type[Any]) failed']", "Line 99: Unexpected errors ['Object of class `type` has no attribute `unknown`']", "Line 100: Unexpected errors ['Object of class `type` has no attribute `unknown`']", - "Line 102: Unexpected errors ['assert_type(Any, tuple[type, ...]) failed']", - "Line 106: Unexpected errors ['assert_type(Any, tuple[type, ...]) failed']", - "Line 110: Unexpected errors ['assert_type(Any, tuple[type, ...]) failed']", "Line 139: Unexpected errors ['assert_type(type, type[Any]) failed']" ], "tuples_type_compat.py": [], diff --git a/conformance/third_party/results.json b/conformance/third_party/results.json index 6af4695703..0e32cf245c 100644 --- a/conformance/third_party/results.json +++ b/conformance/third_party/results.json @@ -3,7 +3,7 @@ "pass": 106, "fail": 32, "pass_rate": 0.77, - "differences": 136, + "differences": 133, "passing": [ "aliases_explicit.py", "aliases_newtype.py", @@ -144,7 +144,7 @@ "qualifiers_annotated.py": 6, "qualifiers_final_annotation.py": 7, "specialtypes_never.py": 1, - "specialtypes_type.py": 8 + "specialtypes_type.py": 5 }, "comment": "@generated" } \ No newline at end of file diff --git a/pyrefly/lib/alt/attr.rs b/pyrefly/lib/alt/attr.rs index 5b253e1324..1c32196fd0 100644 --- a/pyrefly/lib/alt/attr.rs +++ b/pyrefly/lib/alt/attr.rs @@ -1220,7 +1220,20 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> { ) -> Type { let builtins_type_classtype = self.stdlib.builtins_type(); self.get_instance_attribute(builtins_type_classtype, attr_name) - .and_then(|attr| attr.as_instance_method()) + .and_then(|attr| match attr { + ClassAttribute::Property(getter, _, _) => { + let error_swallower = self.error_swallower(); + let fake_range = TextRange::default(); + let ty = self.call_property_getter(getter, fake_range, &error_swallower, None); + if error_swallower.is_empty() { + Some(ty) + } else { + // Should not happen here, but just in case + None + } + } + _ => attr.as_instance_method(), + }) .unwrap_or_else(fallback) } diff --git a/pyrefly/lib/test/simple.rs b/pyrefly/lib/test/simple.rs index 23d3ceeb53..a0ea13377f 100644 --- a/pyrefly/lib/test/simple.rs +++ b/pyrefly/lib/test/simple.rs @@ -1411,6 +1411,16 @@ g(42) # E: not assignable to parameter `x` with type `type` "#, ); +testcase!( + test_typing_type_properties, + r#" +from typing import Type, assert_type, reveal_type +def f(x: Type) -> None: + assert_type(x.__mro__, tuple[type, ...]) + assert_type(x.__base__, type | None) +"#, +); + testcase!( test_round, r#"