Skip to content

AssertionError: All arguments must be fully typed #6809

Closed

Description

@ezyang
  • Are you reporting a bug, or opening a feature request? bug
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
from dataclasses import dataclass

@dataclass(frozen=True)
class Modifiers:
    pass

@dataclass(frozen=True)
class Buff:
    modifiers: Modifiers

@dataclass(frozen=True)
class HB(Buff):
    modifiers = Modifiers()
  • What is the actual behavior/output?
bug.py:11: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.701
Traceback (most recent call last):
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/main.py", line 84, in main
    res = build.build(sources, options, None, flush_errors, fscache)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/build.py", line 163, in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/build.py", line 218, in _build
    graph = dispatch(sources, manager)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/build.py", line 2461, in dispatch
    process_graph(graph, manager)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/build.py", line 2761, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/build.py", line 2862, in process_stale_scc
    graph[id].semantic_analysis()
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/build.py", line 1997, in semantic_analysis
    self.manager.semantic_analyzer.visit_file(self.tree, self.xpath, self.options, patches)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/semanal.py", line 309, in visit_file
    self.accept(d)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/semanal.py", line 3791, in accept
    node.accept(self)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/nodes.py", line 896, in accept
    return visitor.visit_class_def(self)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/semanal.py", line 807, in visit_class_def
    self.analyze_class(defn)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/semanal.py", line 825, in analyze_class
    self.analyze_class_body_common(defn)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/semanal.py", line 833, in analyze_class_body_common
    self.apply_class_plugin_hooks(defn)
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/semanal.py", line 895, in apply_class_plugin_hooks
    hook(ClassDefContext(defn, decorator, self))
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/plugins/dataclasses.py", line 330, in dataclass_class_maker_callback
    transformer.transform()
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/plugins/dataclasses.py", line 100, in transform
    return_type=NoneTyp(),
  File "/Users/ezyang/Dev/oss/dl-hmc-calc-env/lib/python3.7/site-packages/mypy/plugins/common.py", line 97, in add_method
    assert arg.type_annotation, 'All arguments must be fully typed.'
AssertionError: All arguments must be fully typed.
bug.py:11: : note: use --pdb to drop into pdb
  • What is the behavior/output you expect?

No crash

  • What are the versions of mypy and Python you are using?
(/Users/ezyang/Dev/oss/dl-hmc-calc-env) MacBook-Pro-116:dl-hmc-calc ezyang$ python --version
Python 3.7.3
(/Users/ezyang/Dev/oss/dl-hmc-calc-env) MacBook-Pro-116:dl-hmc-calc ezyang$ mypy --version
mypy 0.701
  • Do you see the same issue after installing mypy from Git master?

I didn't try.

  • What are the mypy flags you are using? (For example --strict-optional)

None

Activity

  1. changed the title [-]dataclass without types gets AssertionError: All arguments must be fully typed.[/-] [+]AssertionError: All arguments must be fully typed.[/+] on May 9, 2019
  2. ilevkivskyi commented on May 10, 2019

    @ilevkivskyi
    Member

    Thanks for reporting! This is quite bad crash, also it is interesting that it also crashes with a different traceback if one uses --new-semantic-analyzer:

    Traceback (most recent call last):
      File "/home/ivan/mypy_dev/bin/mypy", line 11, in <module>
        load_entry_point('mypy==0.710+dev.9c74efd4e04b0485444eed6a9d61c86046b8195f', 'console_scripts', 'mypy')()
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
        main(None)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/main.py", line 85, in main
        res = build.build(sources, options, None, flush_errors, fscache)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/build.py", line 164, in build
        result = _build(sources, options, alt_lib_path, flush_errors, fscache)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/build.py", line 220, in _build
        graph = dispatch(sources, manager)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/build.py", line 2490, in dispatch
        process_graph(graph, manager)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/build.py", line 2802, in process_graph
        process_stale_scc(graph, scc, manager)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/build.py", line 2900, in process_stale_scc
        semantic_analysis_for_scc(graph, scc, manager.errors)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/newsemanal/semanal_main.py", line 73, in semantic_analysis_for_scc
        process_top_levels(graph, scc, patches)
      File "/home/ivan/mypy_dev/lib/python3.6/site-packages/mypy/newsemanal/semanal_main.py", line 172, in process_top_levels
        assert not all_deferred, 'Must not defer during final iteration'
    AssertionError: Must not defer during final iteration
  3. kbakk commented on Jan 6, 2020

    @kbakk

    Hi,

    I'm able to reproduce this with master branch (300c846), the output is a bit different from the previously posted (same example code as @ezyang):

    $ mypy --show-traceback repro.py                         
    repro.py:12: 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.300c846a244a99e0c9cd9ade6b0400c4142a0f77
    Traceback (most recent call last):
      File "/Users/kristofferb/Library/Caches/pypoetry/virtualenvs/mypy-dataclass-pUk8QsQY-py3.7/bin/mypy", line 11, in <module>
        load_entry_point('mypy', 'console_scripts', 'mypy')()
      File "/Users/kristofferb/Code/rand/mypy/mypy/__main__.py", line 8, in console_entry
        main(None, sys.stdout, sys.stderr)
      File "/Users/kristofferb/Code/rand/mypy/mypy/main.py", line 89, in main
        res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
      File "/Users/kristofferb/Code/rand/mypy/mypy/build.py", line 167, in build
        sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
      File "/Users/kristofferb/Code/rand/mypy/mypy/build.py", line 235, in _build
        graph = dispatch(sources, manager, stdout)
      File "/Users/kristofferb/Code/rand/mypy/mypy/build.py", line 2611, in dispatch
        process_graph(graph, manager)
      File "/Users/kristofferb/Code/rand/mypy/mypy/build.py", line 2918, in process_graph
        process_stale_scc(graph, scc, manager)
      File "/Users/kristofferb/Code/rand/mypy/mypy/build.py", line 3011, in process_stale_scc
        mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal_main.py", line 77, in semantic_analysis_for_scc
        process_top_levels(graph, scc, patches)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal_main.py", line 202, in process_top_levels
        patches)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal_main.py", line 330, in semantic_analyze_target
        active_type=active_type)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 378, in refresh_partial
        self.refresh_top_level(node)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 389, in refresh_top_level
        self.accept(d)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 4695, in accept
        node.accept(self)
      File "/Users/kristofferb/Code/rand/mypy/mypy/nodes.py", line 939, in accept
        return visitor.visit_class_def(self)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 1029, in visit_class_def
        self.analyze_class(defn)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 1106, in analyze_class
        self.analyze_class_body_common(defn)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 1115, in analyze_class_body_common
        self.apply_class_plugin_hooks(defn)
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 1161, in apply_class_plugin_hooks
        hook(ClassDefContext(defn, decorator, self))
      File "/Users/kristofferb/Code/rand/mypy/mypy/plugins/dataclasses.py", line 383, in dataclass_class_maker_callback
        transformer.transform()
      File "/Users/kristofferb/Code/rand/mypy/mypy/plugins/dataclasses.py", line 90, in transform
        ctx.api.defer()
      File "/Users/kristofferb/Code/rand/mypy/mypy/semanal.py", line 4429, in defer
        assert not self.final_iteration, 'Must not defer during final iteration'
    AssertionError: Must not defer during final iteration
    repro.py:12: : note: use --pdb to drop into pdb
    
  4. changed the title [-]AssertionError: All arguments must be fully typed.[/-] [+]AssertionError: All arguments must be fully typed[/+] on Jan 7, 2020
  5. msullivan commented on Jan 8, 2020

    @msullivan
    Collaborator

    Probably we want to produce an error here, since the assignment HB doesn't accomplish anything?

  6. self-assigned this
    on Jan 8, 2020
  7. added 3 commits that reference this issue on Jan 10, 2020
    fcb012b
    6ebed7b
    dde1280
  8. added a commit that references this issue on Jan 16, 2020
    07a20a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions