Skip to content

AssertionError in untyped function definition #8587

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
dfarley1 opened this issue Mar 25, 2020 · 1 comment
Closed

AssertionError in untyped function definition #8587

dfarley1 opened this issue Mar 25, 2020 · 1 comment

Comments

@dfarley1
Copy link

Offending code:

protocol_page_translate.py
46:  
47:  
48:  def select_fields_to_translate(json_obj, translation):
49:      """Select Fields in Dashboard JSON to translate S --> C"""
50:      json_obj[".meta"] = translate_json(json_obj[".meta"], translation)

Calling code:

def select_fields_to_translate_file(filename, translation):
    with open(filename, "r") as f:
        try:
            bundle = json.load(f)
        except ValueError as error:
            print("{}: {}".format(filename, error), file=sys.stderr)
            return
    if not bundle:
        return
    bundle = select_fields_to_translate(bundle, translation).   <--- Here

Stacktrace:

protocol_page_translate.py:48: 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.760
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib64/python3.6/site-packages/mypy/__main__.py", line 12, in <module>
    main(None, sys.stdout, sys.stderr)
  File "/usr/lib64/python3.6/site-packages/mypy/main.py", line 89, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/usr/lib64/python3.6/site-packages/mypy/build.py", line 167, in build
    sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
  File "/usr/lib64/python3.6/site-packages/mypy/build.py", line 235, in _build
    graph = dispatch(sources, manager, stdout)
  File "/usr/lib64/python3.6/site-packages/mypy/build.py", line 2611, in dispatch
    process_graph(graph, manager)
  File "/usr/lib64/python3.6/site-packages/mypy/build.py", line 2918, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/usr/lib64/python3.6/site-packages/mypy/build.py", line 3017, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/usr/lib64/python3.6/site-packages/mypy/build.py", line 2110, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 292, in check_first_pass
    self.accept(d)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 399, in accept
    stmt.accept(self)
  File "/usr/lib64/python3.6/site-packages/mypy/nodes.py", line 676, in accept
    return visitor.visit_func_def(self)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 724, in visit_func_def
    self._visit_func_def(defn)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 728, in _visit_func_def
    self.check_func_item(defn, name=defn.name)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 790, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 833, in check_func_def
    self.check_for_missing_annotations(fdef)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 1059, in check_for_missing_annotations
    code=codes.NO_UNTYPED_DEF)
  File "/usr/lib64/python3.6/site-packages/mypy/checker.py", line 4363, in fail
    self.msg.fail(msg, context, code=code)
  File "/usr/lib64/python3.6/site-packages/mypy/messages.py", line 148, in fail
    self.report(msg, context, 'error', code=code, file=file, origin=origin)
  File "/usr/lib64/python3.6/site-packages/mypy/messages.py", line 138, in report
    code=code)
  File "/usr/lib64/python3.6/site-packages/mypy/errors.py", line 319, in report
    self.add_error_info(info)
  File "/usr/lib64/python3.6/site-packages/mypy/errors.py", line 350, in add_error_info
    self._add_error_info(file, info)
  File "/usr/lib64/python3.6/site-packages/mypy/errors.py", line 322, in _add_error_info
    assert file not in self.flushed_files
AssertionError: 
protocol_page_translate.py:48: : note: use --pdb to drop into pdb
  • What are the versions of mypy and Python you are using?
    Python 3.6, Mypy 0.760
  • Do you see the same issue after installing mypy from Git master?
    Haven't tested yet
  • What are the mypy flags you are using? (For example --strict-optional)
    --strict and a mypy.ini with a bunch of ignore_missing_imports for 3rd party libraries.
@ilevkivskyi
Copy link
Member

I don't think this is caused by the actual code, but most likely is a duplicate of either #7510 or #4881

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

No branches or pull requests

2 participants