Skip to content

AssertionError mypy/server/deps.py:495 #8682

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

Closed
ara4711 opened this issue Apr 16, 2020 · 4 comments · Fixed by #11574
Closed

AssertionError mypy/server/deps.py:495 #8682

ara4711 opened this issue Apr 16, 2020 · 4 comments · Fixed by #11574

Comments

@ara4711
Copy link

ara4711 commented Apr 16, 2020

I'm attempting to run mypy on an existning project, developed long before typing was a thing in python. Mypy (master) crashes with the below stack-trace. Shrinking the project is not doable,
but I can probably supply more info, if needed.

The assertion only fails when mypy.ini contains cache_fine_grained = True, but not otherwise.

triresolve/dw/models.py: 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.770+dev.b8bdc26127d7b7f3ac42b308350b0ec0fba01fcc
Traceback (most recent call last):
  File "/Users/andreasr/dev/triresolve/venv/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/main.py", line 89, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 181, in build
    sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 252, in _build
    graph = dispatch(sources, manager, stdout)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2620, in dispatch
    return dispatch(sources, manager, stdout)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2626, in dispatch
    process_graph(graph, manager)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2949, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 3058, in process_stale_scc
    graph[id].finish_passes()
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2152, in finish_passes
    free_tree(self.tree)
  File "/usr/local/Cellar/[email protected]/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 1919, in wrap_context
    yield
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2149, in finish_passes
    self.update_fine_grained_deps(self.manager.fg_deps)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2197, in update_fine_grained_deps
    merge_dependencies(self.compute_fine_grained_deps(), deps)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/build.py", line 2191, in compute_fine_grained_deps
    options=self.manager.options)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 114, in get_dependencies
    target.accept(visitor)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/nodes.py", line 294, in accept
    return visitor.visit_mypy_file(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 176, in visit_mypy_file
    super().visit_mypy_file(o)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/traverser.py", line 35, in visit_mypy_file
    d.accept(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/nodes.py", line 939, in accept
    return visitor.visit_class_def(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 239, in visit_class_def
    super().visit_class_def(o)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/traverser.py", line 71, in visit_class_def
    o.defs.accept(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/nodes.py", line 1004, in accept
    return visitor.visit_block(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 351, in visit_block
    super().visit_block(o)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/traverser.py", line 39, in visit_block
    s.accept(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/nodes.py", line 1062, in accept
    return visitor.visit_assignment_stmt(self)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 403, in visit_assignment_stmt
    self.process_lvalue(lvalue)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 443, in process_lvalue
    lvalue_type = self.get_non_partial_lvalue_type(lvalue)
  File "/Users/andreasr/dev/triresolve/venv/lib/python3.7/site-packages/mypy/server/deps.py", line 495, in get_non_partial_lvalue_type
    assert not lvalue.is_new_def
AssertionError: 
@ZephyrBlu
Copy link

Did you figure out a solution? I'm having the same issue.

@ara4711
Copy link
Author

ara4711 commented Jan 10, 2021 via email

@andriykohut
Copy link

Got the same error when switching a project to python 3.10 with this config, not using cache_fine_grained (unless i's now enabled by default?) here:

[mypy]
plugins = strawberry.ext.mypy_plugin

ignore_missing_imports = False
check_untyped_defs = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
warn_unused_ignores = True
warn_return_any = True
disallow_untyped_defs = True
scripts_are_modules = True

disallow_any_generics = False

# this is maximum hardcore
strict = False

Daemon crashed!
Traceback (most recent call last):
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/dmypy_server.py", line 229, in serve
    resp = self.run_command(command, data)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/dmypy_server.py", line 272, in run_command
    return method(self, **data)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/dmypy_server.py", line 331, in cmd_run
    return self.check(sources, is_tty, terminal_width)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/dmypy_server.py", line 388, in check
    res = self.initialize_fine_grained(sources, is_tty, terminal_width)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/dmypy_server.py", line 423, in initialize_fine_grained
    result = mypy.build.build(sources=sources,
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 179, in build
    result = _build(
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 254, in _build
    graph = dispatch(sources, manager, stdout)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 2697, in dispatch
    process_graph(graph, manager)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 3021, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 3130, in process_stale_scc
    graph[id].finish_passes()
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 2207, in finish_passes
    self.update_fine_grained_deps(self.manager.fg_deps)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 2257, in update_fine_grained_deps
    merge_dependencies(self.compute_fine_grained_deps(), deps)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/build.py", line 2248, in compute_fine_grained_deps
    return get_dependencies(target=self.tree,
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 115, in get_dependencies
    target.accept(visitor)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/nodes.py", line 305, in accept
    return visitor.visit_mypy_file(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 177, in visit_mypy_file
    super().visit_mypy_file(o)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/traverser.py", line 37, in visit_mypy_file
    d.accept(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/nodes.py", line 950, in accept
    return visitor.visit_class_def(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 240, in visit_class_def
    super().visit_class_def(o)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/traverser.py", line 73, in visit_class_def
    o.defs.accept(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1015, in accept
    return visitor.visit_block(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 352, in visit_block
    super().visit_block(o)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/traverser.py", line 41, in visit_block
    s.accept(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/nodes.py", line 687, in accept
    return visitor.visit_func_def(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 202, in visit_func_def
    super().visit_func_def(ex)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/traverser.py", line 56, in visit_func_def
    self.visit_func(o)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/traverser.py", line 53, in visit_func
    o.body.accept(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1015, in accept
    return visitor.visit_block(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 352, in visit_block
    super().visit_block(o)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/traverser.py", line 41, in visit_block
    s.accept(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1073, in accept
    return visitor.visit_assignment_stmt(self)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 404, in visit_assignment_stmt
    self.process_lvalue(lvalue)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 464, in process_lvalue
    lvalue_type = self.get_non_partial_lvalue_type(lvalue)
  File "/Users/andrii.kohut/.pyenv/versions/3.10.0/envs/conserve-3.10/lib/python3.10/site-packages/mypy/server/deps.py", line 496, in get_non_partial_lvalue_type
    assert not lvalue.is_new_def
AssertionError

@christianbundy
Copy link
Contributor

christianbundy commented Nov 16, 2021

Having the same problem with dmypy after an aiohttp update -- just got a minimal reproduction of the issue!

See-also: #11456

christianbundy added a commit to christianbundy/mypy that referenced this issue Nov 17, 2021
Problem: When using the fine-grained cache, we raise an assertion in
some situations when an attribute is defined as `None`.

Solution: Remove truthiness check to ensure that `None` is an allowed
type.

Fixes: python#8682
Fixes: python#11456
hauntsaninja pushed a commit that referenced this issue Dec 8, 2021
Problem: When using the fine-grained cache, we raise an assertion in
some situations when an attribute is defined as `None`.

Solution: Remove truthiness check to ensure that `None` is an allowed
type.

Fixes: #8682
Fixes: #11456
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
Problem: When using the fine-grained cache, we raise an assertion in
some situations when an attribute is defined as `None`.

Solution: Remove truthiness check to ensure that `None` is an allowed
type.

Fixes: python#8682
Fixes: python#11456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants