Skip to content

INTERNAL ERROR: Parameters cannot be constrained to (1.5.1) / AssertionError (HEAD) #15948

Closed
@sliedes

Description

@sliedes

Bug Report

Type checking aiopath (fixed to have a py.typed marker) crashes mypy 1.5.1 and current HEAD, at least on Python 3.10.7. On mypy 1.5.1, the error is "RuntimeError: Parameters cannot be constrained to" (sic). On HEAD, it is an AssertionError (see below).

To Reproduce

$ pip install git+https://github.com/asvetlov/aiopath.git@fe33c2722bd46c4fe80055081bfdb10d959c091b
$ echo "import aiopath" >bug.py
$ mypy bug.py --show-traceback
/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/aiopath/flavours.py:11: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.6.0+dev.4077dc6c4b87b273bfd4552d75faaafa6c016c25
Traceback (most recent call last):
File "/home/sami/proj/chat/chat/.venv/bin/mypy", line 8, in
sys.exit(console_entry())
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/main.py", line 15, in console_entry
main()
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/main.py", line 99, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/main.py", line 178, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/build.py", line 189, in build
result = _build(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/build.py", line 262, in _build
graph = dispatch(sources, manager, stdout)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/build.py", line 2938, in dispatch
process_graph(graph, manager)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/build.py", line 3336, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/build.py", line 3437, in process_stale_scc
graph[id].type_check_first_pass()
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/build.py", line 2306, in type_check_first_pass
self.type_checker().check_first_pass()
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 475, in check_first_pass
self.accept(d)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 585, in accept
stmt.accept(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/nodes.py", line 1549, in accept
return visitor.visit_try_stmt(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 4497, in visit_try_stmt
self.visit_try_without_finally(s, try_frame=bool(s.finally_body))
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 4533, in visit_try_without_finally
self.accept(s.body)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 585, in accept
stmt.accept(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/nodes.py", line 1226, in accept
return visitor.visit_block(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 2754, in visit_block
self.accept(s)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 585, in accept
stmt.accept(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/nodes.py", line 1313, in accept
return visitor.visit_assignment_stmt(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 2802, in visit_assignment_stmt
self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 2978, in check_assignment
rvalue_type = self.check_simple_assignment(lvalue_type, rvalue, context=rvalue)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checker.py", line 4029, in check_simple_assignment
rvalue_type = self.expr_checker.accept(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 5340, in accept
typ = node.accept(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/nodes.py", line 1907, in accept
return visitor.visit_call_expr(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 452, in visit_call_expr
return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 581, in visit_call_expr_inner
ret_type = self.check_call_expr_with_callee_type(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 1420, in check_call_expr_with_callee_type
ret_type, callee_type = self.check_call(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 1514, in check_call
return self.check_callable_call(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 1677, in check_callable_call
callee = self.infer_function_type_arguments(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 2096, in infer_function_type_arguments
return self.apply_inferred_arguments(callee_type, inferred_args, context)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 2190, in apply_inferred_arguments
return self.apply_generic_arguments(callee_type, inferred_args, context)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/checkexpr.py", line 3091, in apply_generic_arguments
return applytype.apply_generic_arguments(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/applytype.py", line 145, in apply_generic_arguments
ret_type=expand_type(callable.ret_type, id_to_type),
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/expandtype.py", line 71, in expand_type
return typ.accept(ExpandTypeVisitor(env))
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/types.py", line 397, in accept
return visitor.visit_type_alias_type(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/expandtype.py", line 459, in visit_type_alias_type
args = self.expand_types_with_unpack(t.args)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/expandtype.py", line 402, in expand_types_with_unpack
items.append(item.accept(self))
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/types.py", line 1689, in accept
return visitor.visit_parameters(self)
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/expandtype.py", line 294, in visit_parameters
return t.copy_modified(arg_types=self.expand_types(t.arg_types))
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/types.py", line 1594, in copy_modified
return Parameters(
File "/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/mypy/types.py", line 1580, in init
assert not any(isinstance(t, Parameters) for t in arg_types)
AssertionError:
/home/sami/proj/chat/chat/.venv/lib/python3.10/site-packages/aiopath/flavours.py:11: : note: use --pdb to drop into pdb

  • Mypy version used: 1.5.1, mypy 1.6.0+dev.4077dc6c4b87b273bfd4552d75faaafa6c016c25 (compiled: no)
  • Mypy command-line flags: bug.py
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions