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

Raise RuntimeError with better error messages #15778

Merged
merged 1 commit into from
Jul 29, 2023
Merged

Conversation

sobolevn
Copy link
Member

While working on #15776 I've noticed that some RuntimeError do not have enough metadata to understand what is going on.
CI: https://github.com/python/mypy/actions/runs/5700479199/job/15450345887

This is the traceback I got:

 _______________________ testNamedTupleNestedClassRecheck _______________________
[gw1] linux -- Python 3.10.12 /home/runner/work/mypy/mypy/.tox/py/bin/python
data: /home/runner/work/mypy/mypy/test-data/unit/fine-grained.test:10213:
/home/runner/work/mypy/mypy/.tox/py/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/home/runner/work/mypy/mypy/.tox/py/lib/python3.10/site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/home/runner/work/mypy/mypy/.tox/py/lib/python3.10/site-packages/pluggy/_hooks.py:433: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/home/runner/work/mypy/mypy/.tox/py/lib/python3.10/site-packages/pluggy/_manager.py:112: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/home/runner/work/mypy/mypy/.tox/py/lib/python3.10/site-packages/_pytest/runner.py:177: in pytest_runtest_call
    raise e
/home/runner/work/mypy/mypy/.tox/py/lib/python3.10/site-packages/_pytest/runner.py:169: in pytest_runtest_call
    item.runtest()
/home/runner/work/mypy/mypy/mypy/test/data.py:320: in runtest
    suite.run_case(self)
/home/runner/work/mypy/mypy/mypy/test/testfinegrained.py:113: in run_case
    output, triggered = self.perform_step(
/home/runner/work/mypy/mypy/mypy/test/testfinegrained.py:217: in perform_step
    new_messages = self.run_check(server, sources)
/home/runner/work/mypy/mypy/mypy/test/testfinegrained.py:167: in run_check
    response = server.check(sources, export_types=True, is_tty=False, terminal_width=-1)
/home/runner/work/mypy/mypy/mypy/dmypy_server.py:416: in check
    messages = self.fine_grained_increment(sources)
/home/runner/work/mypy/mypy/mypy/dmypy_server.py:562: in fine_grained_increment
    messages = self.fine_grained_manager.update(changed, removed)
/home/runner/work/mypy/mypy/mypy/server/update.py:267: in update
    result = self.update_one(
/home/runner/work/mypy/mypy/mypy/server/update.py:369: in update_one
    result = self.update_module(next_id, next_path, next_id in removed_set, followed)
/home/runner/work/mypy/mypy/mypy/server/update.py:452: in update_module
    remaining += propagate_changes_using_dependencies(
/home/runner/work/mypy/mypy/mypy/server/update.py:881: in propagate_changes_using_dependencies
    triggered |= reprocess_nodes(manager, graph, id, nodes, deps, processed_targets)
/home/runner/work/mypy/mypy/mypy/server/update.py:1017: in reprocess_nodes
    merge_asts(file_node, old_symbols[name], file_node, new_symbols[name])
/home/runner/work/mypy/mypy/mypy/server/astmerge.py:139: in merge_asts
    node = replace_nodes_in_ast(new, replacement_map)
/home/runner/work/mypy/mypy/mypy/server/astmerge.py:191: in replace_nodes_in_ast
    node.accept(visitor)
/home/runner/work/mypy/mypy/mypy/nodes.py:377: in accept
    return visitor.visit_mypy_file(self)
/home/runner/work/mypy/mypy/mypy/server/astmerge.py:212: in visit_mypy_file
    super().visit_mypy_file(node)
/home/runner/work/mypy/mypy/mypy/traverser.py:114: in visit_mypy_file
    d.accept(self)
/home/runner/work/mypy/mypy/mypy/nodes.py:1141: in accept
    return visitor.visit_class_def(self)
/home/runner/work/mypy/mypy/mypy/server/astmerge.py:237: in visit_class_def
    self.process_synthetic_type_info(info)
/home/runner/work/mypy/mypy/mypy/server/astmerge.py:404: in process_synthetic_type_info
    node.node.accept(self)
/home/runner/work/mypy/mypy/mypy/nodes.py:206: in accept
    raise RuntimeError("Not implemented")
E   RuntimeError: Not implemented

This PR adds more context to error messages.

@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sobolevn
Copy link
Member Author

Going to merge, as this is quite minor.

@sobolevn sobolevn merged commit 8792ff1 into master Jul 29, 2023
17 checks passed
@sobolevn sobolevn deleted the better-error-messages branch July 29, 2023 19:33
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 this pull request may close these issues.

1 participant