1

I'm attempting to fix typing errors in my program with pyre. I have the following snippet, that works when it is run.

my_dict = dict(my_list=[], notes='')
my_dict["notes"] = "pyre"
print(my_dict["notes"])

That makes the error:

test.py:2:19 Incompatible parameter type [6]: Expected `typing.Union[typing_extensions.Literal[''], typing.List[typing.Any]]` for 2nd positional only parameter to call `dict.__setitem__` but got `typing_extensions.Literal['pyre']`.

I am unsure how to fix this typing issue.

user69953
  • 13
  • 3
  • 1
    What happens if you change the left-hand side of the first line to `my_dict: dict[str, Union[list, str]] = . . . `? I have no experience with pyre, but that might help give a better error. – Carcigenicate Jul 30 '21 at 00:11
  • 1
    Why is Pyre inferring a literal type here? – juanpa.arrivillaga Jul 30 '21 at 00:12
  • 1
    @Carcigenicate Thanks, I changed the declaration to `my_dict: Dict[Any, Any] = dict(my_list=[], notes='')` and it resolved all type issues :|. Even though I thought that was already obvious. – user69953 Jul 30 '21 at 00:59

0 Answers0