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

AssertionError assert file not in self.flushed_files on master and release-1.15 #18730

Open
clambert-jt opened this issue Feb 24, 2025 · 0 comments
Labels

Comments

@clambert-jt
Copy link

clambert-jt commented Feb 24, 2025

Crash Report

Using dmpy on mypy release 1.15 and on master, adjusting a specific line that changes the return type to not match the annotated one results in an internal error. This is not an issue on mypy 1.10.

Traceback

<file>:<line1>: 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.16.0+dev.66dde1497fae172988d577ef1a41ee0d89a47b56.dirty
<file>:<line2>: 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.16.0+dev.66dde1497fae172988d577ef1a41ee0d89a47b56.dirty
<file>:<line3>: 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.16.0+dev.66dde1497fae172988d577ef1a41ee0d89a47b56.dirty
Daemon crashed!
Traceback (most recent call last):
  File ".../mypy/dmypy_server.py", line 237, in serve
    resp = self.run_command(command, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/dmypy_server.py", line 286, in run_command
    ret = method(self, **data)
          ^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/dmypy_server.py", line 354, in cmd_run
    return self.check(sources, export_types, is_tty, terminal_width)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/dmypy_server.py", line 433, in check
    messages = self.fine_grained_increment_follow_imports(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/dmypy_server.py", line 701, in fine_grained_increment_follow_imports
    messages = fine_grained_manager.update([], to_delete)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/server/update.py", line 286, in update
    changed_modules = propagate_changes_using_dependencies(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/server/update.py", line 882, in propagate_changes_using_dependencies
    triggered |= reprocess_nodes(manager, graph, id, nodes, deps, processed_targets)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/server/update.py", line 1026, in reprocess_nodes
    more = checker.check_second_pass(nodes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/checker.py", line 522, in check_second_pass
    self.check_partial(node)
  File ".../mypy/checker.py", line 531, in check_partial
    self.accept(node)
  File ".../mypy/checker.py", line 578, in accept
    report_internal_error(err, self.errors.file, stmt.line, self.errors, self.options)
  File ".../mypy/errors.py", line 1276, in report_internal_error
    raise err
  File ".../mypy/checker.py", line 576, in accept
    stmt.accept(self)
  File ".../mypy/nodes.py", line 813, in accept
    return visitor.visit_func_def(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/checker.py", line 1079, in visit_func_def
    self._visit_func_def(defn)
  File ".../mypy/checker.py", line 1083, in _visit_func_def
    self.check_func_item(defn, name=defn.name)
  File ".../mypy/checker.py", line 1117, in check_func_item
    self.check_func_def(defn, typ, name, allow_empty)
  File ".../mypy/checker.py", line 1393, in check_func_def
    self.accept(item.body)
  File ".../mypy/checker.py", line 578, in accept
    report_internal_error(err, self.errors.file, stmt.line, self.errors, self.options)
  File ".../mypy/errors.py", line 1276, in report_internal_error
    raise err
  File ".../mypy/checker.py", line 576, in accept
    stmt.accept(self)
  File ".../mypy/nodes.py", line 1280, in accept
    return visitor.visit_block(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/checker.py", line 3062, in visit_block
    self.accept(s)
  File ".../mypy/checker.py", line 578, in accept
    report_internal_error(err, self.errors.file, stmt.line, self.errors, self.options)
  File ".../mypy/errors.py", line 1276, in report_internal_error
    raise err
  File ".../mypy/checker.py", line 576, in accept
    stmt.accept(self)
  File ".../mypy/nodes.py", line 1476, in accept
    return visitor.visit_return_stmt(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../mypy/checker.py", line 4770, in visit_return_stmt
    self.check_return_stmt(s)
  File ".../mypy/checker.py", line 4851, in check_return_stmt
    self.check_subtype(
  File ".../mypy/checker.py", line 7196, in check_subtype
    self.fail(msg, context)
  File ".../mypy/checker.py", line 7539, in fail
    self.msg.fail(msg.value, context, code=msg.code)
  File ".../mypy/messages.py", line 295, in fail
    self.report(
  File ".../mypy/messages.py", line 270, in report
    self.errors.report(
  File ".../mypy/errors.py", line 466, in report
    self.add_error_info(info)
  File ".../mypy/errors.py", line 532, in add_error_info
    self._add_error_info(file, info)
  File ".../mypy/errors.py", line 469, in _add_error_info
    assert file not in self.flushed_files
AssertionError

To Reproduce

I was unable to reproduce this error in an isolated environment after trying, though I could try more with multi-file setups if needed. For context, the section of code that when modified causes this crash looks like.

class Foo:
    ...
    class Bar(enum.Enum):
        A = 0
        B = 1
    ...
    bar: Bar
    @classmethod
    def baz(cls, old: Foo, new: Foo) -> Mapping[str, str]:
        ret = {
            "a": some_str_function(),
            "b": str(new.bar.value), # <<< modify this removing and adding the str call
            "c": f'[{some_str_function2()}]',
        }
	...
        return ret

Your Environment

  • Mypy version used: master 66dde14
  • Mypy command-line flags: dmypy run -- <directory> -v
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
warn_unused_configs = True
show_error_code_links = True
warn_redundant_casts = True

[mypy-<module>.*]
disallow_untyped_defs = True
disallow_any_generics = True
strict_equality = True
no_implicit_reexport = True
local_partial_types = True
warn_unused_ignores = True
enable_error_code = possibly-undefined, truthy-iterable, truthy-bool
  • Python version used: 3.12.2
  • Operating system and version: Linux AMD64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant