Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P714
unbound type variables
Active
Public
Actions
Authored by
vlorentz
on Jul 3 2020, 4:14 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
KT
=
TypeVar
(
"KT"
)
VT
=
TypeVar
(
"VT"
)
def
freeze_optional_dict
(
d
:
Union
[
None
,
Dict
[
KT
,
VT
],
ImmutableDict
[
KT
,
VT
]]
# ^swh/model/model.py:49: error: Type variable "swh.model.model.KT" is unbound
# swh/model/model.py:49: note: (Hint: Use "Generic[KT]" or "Protocol[KT]" base class to bind "KT" inside a class)
# swh/model/model.py:49: note: (Hint: Use "KT" in function signature to bind "KT" inside a function)
# swh/model/model.py:49: error: Type variable "swh.model.model.VT" is unbound
# swh/model/model.py:49: note: (Hint: Use "Generic[VT]" or "Protocol[VT]" base class to bind "VT" inside a class)
# swh/model/model.py:49: note: (Hint: Use "VT" in function signature to bind "VT" inside a function)
)
->
Optional
[
ImmutableDict
[
KT
,
VT
]]:
if
isinstance
(
d
,
dict
):
return
ImmutableDict
(
d
)
else
:
return
d
Event Timeline
vlorentz
created this paste.
Jul 3 2020, 4:14 PM
2020-07-03 16:14:05 (UTC+2)
vlorentz
mentioned this in
T2473: unbound type variables
.
Jul 3 2020, 4:20 PM
2020-07-03 16:20:27 (UTC+2)
Log In to Comment