Skip to content

Commit

Permalink
Avoid fabricating classes with invalid MRO
Browse files Browse the repository at this point in the history
Reviewed By: alexkassil

Differential Revision: D48134506

fbshipit-source-id: 23e8e3e5ac7efd67e3c838638203a40686d325b7
  • Loading branch information
grievejia authored and facebook-github-bot committed Aug 8, 2023
1 parent d96a057 commit a0eac1f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions source/analysis/classHierarchyEnvironment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ let get_parents alias_environment name ~dependency =
| _ -> None
in
let bases ({ Node.value = { ClassSummary.bases = { base_classes; _ }; _ }; _ } as definition) =
let inferred_base = AnnotatedBases.inferred_generic_base definition ~parse_annotation in
inferred_base @ base_classes
let inferred_generic_base = AnnotatedBases.inferred_generic_base definition ~parse_annotation in
base_classes @ inferred_generic_base
in
let add_special_parents parents =
let simples = List.map ~f:(fun parent -> parent, []) in
Expand Down
2 changes: 1 addition & 1 deletion source/analysis/missingFromStubs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ let missing_builtin_classes =
make
~bases:
[
Type.Primitive "typing.Callable";
Type.parametric
"typing.Generic"
[Single (Type.variable "typing._T"); Single (Type.variable "typing._S")];
Type.Primitive "typing.Callable";
]
"BoundMethod";
]
Expand Down
6 changes: 3 additions & 3 deletions source/analysis/test/classHierarchyEnvironmentTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ let test_inferred_generic_base context =
pass
|}
"test.C"
(Some ["typing.Generic", [Type.variable "test._T"]; "test.List", [Type.variable "test._T"]]);
(Some ["test.List", [Type.variable "test._T"]; "typing.Generic", [Type.variable "test._T"]]);
assert_registers
{|
_T = typing.TypeVar("_T")
Expand All @@ -183,8 +183,8 @@ let test_inferred_generic_base context =
"test.Foo"
(Some
[
"typing.Generic", [Type.variable "test._T1"; Type.variable "test._T2"];
"test.Dict", [Type.variable "test._T1"; Type.variable "test._T2"];
"typing.Generic", [Type.variable "test._T1"; Type.variable "test._T2"];
]);
assert_registers
{|
Expand All @@ -197,8 +197,8 @@ let test_inferred_generic_base context =
"test.Foo"
(Some
[
"typing.Generic", [Type.variable "test._T1"];
"test.Dict", [Type.variable "test._T1"; Type.variable "test._T1"];
"typing.Generic", [Type.variable "test._T1"];
]);
()

Expand Down
2 changes: 1 addition & 1 deletion source/test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ let typeshed_stubs ?(include_helper_builtins = true) () =
def __len__(self) -> int: ...
class Sequence(_Collection[_T_co], Generic[_T_co]): pass
class Generator(Generic[_T_co, _T_contra, _V_co], Iterator[_T_co]):
class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
pass
class AbstractSet(_Collection[_T_co], Generic[_T_co]):
Expand Down

0 comments on commit a0eac1f

Please sign in to comment.