You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we check foo.py that imports a function from bar.py, then check bar.py and finally foo.py again, dmypy will crash with KeyError: 'types'
Traceback
❯ dmypy --status-file dmypy.json start
Daemon started
❯ dmypy --status-file dmypy.json stop
Daemon stopped
❯ dmypy --status-file dmypy.json start -- --verbose
Daemon started
❯ dmypy --status-file dmypy.json check foo.py
LOG: Could not load plugins snapshot: @plugins_snapshot.json
LOG: Mypy Version: 1.11.2
LOG: Config File: Default
LOG: Configured Executable: /home/jenia90/mypy-test/venv/bin/python3
LOG: Current Executable: /home/jenia90/mypy-test/venv/bin/python3
LOG: Cache Dir: /dev/null
LOG: Compiled: True
LOG: Exclude: []
LOG: Found source: BuildSource(path='foo.py', module='foo', has_text=False, base_dir='/home/jenia90/mypy-test', followed=False)
LOG: Metadata not found for foo
LOG: Parsing foo.py (foo)
LOG: Metadata not found for bar
LOG: Parsing /home/jenia90/mypy-test/bar.py (bar)
LOG: Metadata not found for builtins
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/builtins.pyi (builtins)
LOG: Metadata not found for collections.abc
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/collections/abc.pyi (collections.abc)
LOG: Metadata not found for _ast
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_ast.pyi (_ast)
LOG: Metadata not found for _typeshed
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_typeshed/__init__.pyi (_typeshed)
LOG: Metadata not found for sys
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/sys/__init__.pyi (sys)
LOG: Metadata not found for types
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/types.pyi (types)
LOG: Metadata not found for _collections_abc
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_collections_abc.pyi (_collections_abc)
LOG: Metadata not found for io
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/io.pyi (io)
LOG: Metadata not found for typing
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/typing.pyi (typing)
LOG: Metadata not found for typing_extensions
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/typing_extensions.pyi (typing_extensions)
LOG: Metadata not found for collections
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/collections/__init__.pyi (collections)
LOG: Metadata not found for dataclasses
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/dataclasses.pyi (dataclasses)
LOG: Metadata not found for os
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/os/__init__.pyi (os)
LOG: Metadata not found for enum
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/enum.pyi (enum)
LOG: Metadata not found for _typeshed.importlib
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_typeshed/importlib.pyi (_typeshed.importlib)
LOG: Metadata not found for importlib.machinery
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/importlib/machinery.pyi (importlib.machinery)
LOG: Metadata not found for abc
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/abc.pyi (abc)
LOG: Metadata not found for codecs
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/codecs.pyi (codecs)
LOG: Metadata not found for re
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/re.pyi (re)
LOG: Metadata not found for contextlib
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/contextlib.pyi (contextlib)
LOG: Metadata not found for os.path
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/os/path.pyi (os.path)
LOG: Metadata not found for subprocess
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/subprocess.pyi (subprocess)
LOG: Metadata not found for resource
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/resource.pyi (resource)
LOG: Metadata not found for importlib
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/importlib/__init__.pyi (importlib)
LOG: Metadata not found for importlib.abc
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/importlib/abc.pyi (importlib.abc)
LOG: Metadata not found for importlib.metadata
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi (importlib.metadata)
LOG: Metadata not found for _codecs
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_codecs.pyi (_codecs)
LOG: Metadata not found for sre_compile
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/sre_compile.pyi (sre_compile)
LOG: Metadata not found for sre_constants
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/sre_constants.pyi (sre_constants)
LOG: Metadata not found for posixpath
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/posixpath.pyi (posixpath)
LOG: Metadata not found for importlib._abc
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/importlib/_abc.pyi (importlib._abc)
LOG: Metadata not found for importlib.metadata._meta
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/importlib/metadata/_meta.pyi (importlib.metadata._meta)
LOG: Metadata not found for email.message
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/message.pyi (email.message)
LOG: Metadata not found for pathlib
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/pathlib.pyi (pathlib)
LOG: Metadata not found for sre_parse
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/sre_parse.pyi (sre_parse)
LOG: Metadata not found for genericpath
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/genericpath.pyi (genericpath)
LOG: Metadata not found for email
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/__init__.pyi (email)
LOG: Metadata not found for email.charset
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/charset.pyi (email.charset)
LOG: Metadata not found for email.contentmanager
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/contentmanager.pyi (email.contentmanager)
LOG: Metadata not found for email.errors
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/errors.pyi (email.errors)
LOG: Metadata not found for email.policy
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/policy.pyi (email.policy)
LOG: Metadata not found for email._policybase
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/_policybase.pyi (email._policybase)
LOG: Metadata not found for email.header
LOG: Parsing /home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/email/header.pyi (email.header)
LOG: Loaded graph with 45 nodes (0.285 sec)
LOG: Found 3 SCCs; largest has 43 nodes
LOG: Processing SCC of size 43 (typing_extensions typing types sys subprocess sre_parse sre_constants sre_compile resource re posixpath pathlib os.path os io importlib.metadata._meta importlib.metadata importlib.machinery importlib.abc importlib._abc importlib genericpath enum email.policy email.message email.header email.errors email.contentmanager email.charset email._policybase email dataclasses contextlib collections.abc collections codecs abc _typeshed.importlib _typeshed _collections_abc _codecs _ast builtins) as inherently stale
LOG: Processing SCC singleton (bar) as inherently stale
LOG: Processing SCC singleton (foo) as inherently stale
LOG: No fresh SCCs left in queue
LOG: Build finished in 1.324 seconds with 45 modules, and 2 errors
foo.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
Found 1 error in 1 file (checked 1 source file)
❯ dmypy --status-file dmypy.json check foo.py
LOG: fine-grained increment: find_changed: 0.000s
LOG: fine-grained increment: update: 0.001s
foo.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
Found 1 error in 1 file (checked 1 source file)
❯ dmypy --status-file dmypy.json check bar.py
LOG: fine-grained increment: find_changed: 0.000s
LOG: fine-grained: ==== update 'bar' ====
LOG: fine-grained: previous targets with errors: ['foo']
LOG: fine-grained: --- update single 'bar' ---
LOG: Metadata not found for bar
LOG: Parsing bar.py (bar)
LOG: fine-grained: triggered: []
LOG: fine-grained: update once: bar in 0.003s - 0 left
LOG: fine-grained: process target with error: foo
LOG: fine-grained: triggered: []
LOG: fine-grained: ==== update 'foo' ====
LOG: fine-grained: previous targets with errors: ['foo']
LOG: fine-grained: --- update single 'foo' ---
LOG: fine-grained: delete module 'foo'
LOG: fine-grained: triggered: ['<foo.add>', '<foo.x>', '<foo.x_error>', '<foo>', '<foo[wildcard]>']
LOG: fine-grained: triggered: []
LOG: fine-grained: update once: foo in 0.000s - 0 left
LOG: fine-grained: triggered: []
LOG: fine-grained increment: update: 0.007s
Success: no issues found in 1 source file
❯ dmypy --status-file dmypy.json check bar.py
LOG: fine-grained increment: find_changed: 0.000s
LOG: fine-grained increment: update: 0.001s
Success: no issues found in 1 source file
❯ dmypy --status-file dmypy.json check foo.py
...
LOG: fine-grained: process: os._ScandirIterator
LOG: fine-grained: process: contextlib.suppress
LOG: fine-grained: process: contextlib.closing
LOG: fine-grained: process: contextlib.AbstractAsyncContextManager
LOG: fine-grained: process: contextlib.AbstractContextManager
LOG: fine-grained: process: contextlib.nullcontext
LOG: fine-grained: process: contextlib.AsyncExitStack.enter_async_context
/home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_codecs.pyi:12: 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.11.2
/home/jenia90/mypy-test/venv/lib/python3.10/site-packages/mypy/typeshed/stdlib/_codecs.pyi:12: 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.11.2
Daemon crashed!
Traceback (most recent call last):
File "mypy/dmypy_server.py", line 236, in serve
File "mypy/dmypy_server.py", line 285, in run_command
File "mypy/dmypy_server.py", line 363, in cmd_check
File "mypy/dmypy_server.py", line 432, in check
File "mypy/dmypy_server.py", line 698, in fine_grained_increment_follow_imports
File "mypy/server/update.py", line 267, in update
File "mypy/server/update.py", line 369, in update_one
File "mypy/server/update.py", line 452, in update_module
File "mypy/server/update.py", line 881, in propagate_changes_using_dependencies
File "mypy/server/update.py", line 1025, in reprocess_nodes
File "mypy/checker.py", line 535, in check_second_pass
File "mypy/checker.py", line 540, in check_partial
File "mypy/checker.py", line 554, in check_top_level
File "mypy/nodes.py", line 1351, in accept
File "mypy/checker.py", line 2934, in visit_assignment_stmt
File "mypy/checker.py", line 2974, in check_type_alias_rvalue
File "mypy/checkexpr.py", line 5832, in accept
File "mypy/errors.py", line 1269, in report_internal_error
File "mypy/checkexpr.py", line 5830, in accept
File "mypy/nodes.py", line 2112, in accept
File "mypy/checkexpr.py", line 3379, in visit_op_expr
File "mypy/checkexpr.py", line 5832, in accept
File "mypy/errors.py", line 1269, in report_internal_error
File "mypy/checkexpr.py", line 5830, in accept
File "mypy/nodes.py", line 2714, in accept
File "mypy/checkexpr.py", line 4730, in visit_type_alias_expr
File "mypy/checkexpr.py", line 4794, in alias_type_in_runtime_context
File "mypy/checker.py", line 6939, in named_generic_type
File "mypy/checker.py", line 6946, in lookup_typeinfo
File "mypy/checker.py", line 7024, in lookup_qualified
KeyError: 'types'
To Reproduce
Consider the following scripts:
foo.py:
from bar import add
x: str = add("a", "b")
x_error: int = add("a", "b")
bar.py:
def add(a, b) -> str:
return a + b
Execute the following:
dmypy --status-file dmypy.json start
dmypy --status-file dmypy.json check foo.py
# This should output assignment error
dmypy --status-file dmypy.json check bar.py
# This should not output any error
dmypy --status-file dmypy.json check foo.py
# This will take way longer time than first run and eventually either crash with the KeyError or output no errors at all. In case it doesn't crash re-running check on bar.py will end up without errors (even if we take a scenario where bar.py was changed to have some error).
(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)
Your Environment
Mypy version used: 1.11.2 and older versions
Mypy command-line flags: Tried without any flags or configs. Output above with --verbose flag
Mypy configuration options from mypy.ini (and other config files): No config file used
Python version used: 3.8 and 3.10
Operating system and version: Windows Server 2016, Windows 11 and Ubuntu 22.04.5 LTS running on WSL under Windows 11
The text was updated successfully, but these errors were encountered:
jenia90
changed the title
dmypy crashes on module check after checking one of it's imports
dmypy crashes on module check after checking one of its imports
Sep 16, 2024
Crash Report
If we check
foo.py
that imports a function frombar.py
, then checkbar.py
and finallyfoo.py
again, dmypy will crash withKeyError: 'types'
Traceback
To Reproduce
Consider the following scripts:
foo.py:
bar.py:
Execute the following:
(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)
Your Environment
--verbose
flagmypy.ini
(and other config files): No config file usedThe text was updated successfully, but these errors were encountered: