Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 0 additions & 33 deletions conformance/third_party/conformance.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions conformance/third_party/conformance.result
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
4 changes: 2 additions & 2 deletions conformance/third_party/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"pass": 106,
"fail": 32,
"pass_rate": 0.77,
"differences": 136,
"differences": 133,
"passing": [
"aliases_explicit.py",
"aliases_newtype.py",
Expand Down Expand Up @@ -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"
}
15 changes: 14 additions & 1 deletion pyrefly/lib/alt/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
10 changes: 10 additions & 0 deletions pyrefly/lib/test/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down