Type annotation for dict[str, str]
#2613
-
Hello, I want to write in Hy the equivalent of the following Python snippet: type MyType = dict[str, str] I found I could achieve something very close with (deftype MyType1 (get list str)) type MyType1 = list[str] However, when I add a third argument to (deftype MyType2 (get dict str str)) type Type2 = dict[str][str] My current workaround is to use (deftype Marking (py "dict[str, str]")) but it would be so nice to avoid dropping through to Python for this apparently simple type. Is there a way to write a Hy snippet which would translate to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you write |
Beta Was this translation helpful? Give feedback.
If you write
dict[str, str]
with parentheses asdict[(str, str)]
, it's a little clearer that this is just a tuple subscript ofdict
, which in Hy is(get dict #(str str))
. See also Hyrule'sof
.