Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy plugin error: 'tuple' object does not support item assignment #62

Closed
hugosenari opened this issue Oct 22, 2020 · 2 comments · Fixed by #63
Closed

mypy plugin error: 'tuple' object does not support item assignment #62

hugosenari opened this issue Oct 22, 2020 · 2 comments · Fixed by #63
Labels
bug Something isn't working

Comments

@hugosenari
Copy link
Contributor

hugosenari commented Oct 22, 2020

Probably something I'm doing wrong (ie not informing types arguments of Either), but...

mypy MethodContext.default_return_type.args may return a tuple instead of a list.

Raising ''TypeError: 'tuple' object does not support item assignment" for code above

return_type = context.default_return_type
return_type_args: return_type.args
...
return_type_args[0]: _combine_environments(r1, r2)

We could expect that if isn't a list dev made something wrong - like I did - but this and similar assignments may cause unintended side effects 🤔

@hugosenari hugosenari changed the title mypy plugin error: TypeError: 'tuple' object does not support item assignment mypy plugin error: 'tuple' object does not support item assignment Oct 22, 2020
hugosenari added a commit to hugosenari/pfun that referenced this issue Oct 29, 2020
fix suned#62: 
/pfun/mypy_plugin.py", line 396, in _combine_hook
    ret_type_args[1] = combined_error_type
TypeError: 'tuple' object does not support item assignment
@suned
Copy link
Owner

suned commented Feb 2, 2021

Did you ever find the reproducing example? I tried e: Either but did not resolve in the described error. It would be great to have a test case before this is merged.

suned pushed a commit to hugosenari/pfun that referenced this issue Feb 2, 2021
suned pushed a commit to hugosenari/pfun that referenced this issue Feb 2, 2021
@hugosenari
Copy link
Contributor Author

Can you try this please, is the minimal example I could found.

from pfun.either import catch

@catch
def hello_world() -> str:
    return 'Hello World'

At least here it returns:

/home/hugosenari/.local/share/virtualenvs/my_test-tjBmjRl0/lib/python3.8/site-packages/pfun/effect.py:458: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.800
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 3898, in accept
  File "mypy/nodes.py", line 1555, in accept
  File "mypy/checkexpr.py", line 270, in visit_call_expr
  File "mypy/checkexpr.py", line 347, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 852, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 911, in check_call
  File "mypy/checkexpr.py", line 1023, in check_callable_call
  File "mypy/checkexpr.py", line 732, in apply_function_plugin
  File "/home/hugosenari/.local/share/virtualenvs/my_test-tjBmjRl0/lib/python3.8/site-packages/pfun/mypy_plugin.py", line 433, in _effect_recover_hook
    return_type_args[0] = _combine_environments(r1, r2)
TypeError: 'tuple' object does not support item assignment
/home/hugosenari/.local/share/virtualenvs/my_test-tjBmjRl0/lib/python3.8/site-packages/pfun/effect.py:458: : note: use --pdb to drop into pdb

@suned suned closed this as completed in #63 Feb 3, 2021
@suned suned added the bug Something isn't working label Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants