Skip to content

Commit

Permalink
add bug testcase for generic typeddict
Browse files Browse the repository at this point in the history
Summary:
generic typed dicts still get turned into Type::ClassType

i'll sort that out later

Reviewed By: ndmitchell

Differential Revision: D68329669

fbshipit-source-id: 0c6c3b4a3107e090fbfef3cdff9a68c6a6a37979
  • Loading branch information
yangdanny97 authored and facebook-github-bot committed Jan 17, 2025
1 parent f7044fd commit 540c3e8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pyre2/pyre2/bin/test/typed_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use crate::testcase;
use crate::testcase_with_bug;

testcase!(
test_typed_dict,
Expand All @@ -30,6 +31,20 @@ class Coord(TypedDict, metaclass=EnumMeta): # E: Typed dictionary definitions m
"#,
);

testcase_with_bug!(
"Generic typed dicts are not supported yet",
test_typed_dict_generic,
r#"
from typing import TypedDict
class Coord[T](TypedDict):
x: T
y: T
def foo(c: Coord[int]):
x: int = c["x"] # E: `Coord[int]` has no attribute `__getitem__`
y: str = c["y"] # E: `Coord[int]` has no attribute `__getitem__`
"#,
);

testcase!(
test_typed_dict_initialized_field,
r#"
Expand Down

0 comments on commit 540c3e8

Please sign in to comment.