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
I have a library, littlefs-python. Using it crashes mypy. A simple example with mypy-1.9.0 and littlefs-python-0.10.0:
#!/usr/bin/python
import littlefs
This seems to the offending definition:
class LFSStat(NamedTuple):
type: int
size: int
name: str
# Constants
TYPE_REG: int = LFS_TYPE_REG
TYPE_DIR: int = LFS_TYPE_DIR
And changing LFS_TYPE_REG & LFS_TYPE_DIR to an integer constant fixes the issue. It likely is a problem of the stub and I will report a separate bug to littlefs-python upstream, however, IMHO mypy should report this as a problem, not crash.
Traceback
Traceback (most recent call last):
File "/usr/bin/mypy", line 8, in <module>
sys.exit(console_entry())
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/usr/lib/python3.11/site-packages/mypy/main.py", line 100, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/main.py", line 182, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 192, in build
result = _build(
^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 266, in _build
graph = dispatch(sources, manager, stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 2942, in dispatch
process_graph(graph, manager)
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 3340, in process_graph
process_stale_scc(graph, scc, manager)
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 3467, in process_stale_scc
graph[id].write_cache()
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 2503, in write_cache
new_interface_hash, self.meta = write_cache(
^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/build.py", line 1564, in write_cache
data = tree.serialize()
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/nodes.py", line 387, in serialize
"names": self.names.serialize(self._fullname),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/nodes.py", line 3933, in serialize
data[key] = value.serialize(fullname, key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/nodes.py", line 3870, in serialize
data["node"] = self.node.serialize()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/nodes.py", line 3278, in serialize
"names": self.names.serialize(self.fullname),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/nodes.py", line 3933, in serialize
data[key] = value.serialize(fullname, key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/mypy/nodes.py", line 3865, in serialize
assert not isinstance(
AssertionError: Definition of littlefs.lfs.LFSStat.TYPE_REG is unexpectedly incomplete
To Reproduce
See snippet above.
Your Environment
Mypy version used: 1.9.0 (from system Arch Linux)
Mypy command-line flags: none (mypy foo.py)
Mypy configuration options from mypy.ini (and other config files): no config present
Python version used: 3.11.8
Operating system and version: Arch Linux, current system as of 2024-03-22
The text was updated successfully, but these errors were encountered:
Crash Report
I have a library, littlefs-python. Using it crashes mypy. A simple example with
mypy-1.9.0
andlittlefs-python-0.10.0
:This seems to the offending definition:
And changing LFS_TYPE_REG & LFS_TYPE_DIR to an integer constant fixes the issue. It likely is a problem of the stub and I will report a separate bug to littlefs-python upstream, however, IMHO mypy should report this as a problem, not crash.
Traceback
To Reproduce
See snippet above.
Your Environment
mypy foo.py
)mypy.ini
(and other config files): no config presentThe text was updated successfully, but these errors were encountered: