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
Running mypy on a file with a very basic sqlalchemy ORM model raises this error.
Traceback
version: 1.5.0+dev.c13f1d416e907f58bc77d086b84819f500f1bde9
Traceback (most recent call last):
File "/path/to/project/venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/main.py", line 94, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/main.py", line 173, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/build.py", line 195, in build
result = _build(
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/build.py", line 268, in _build
graph = dispatch(sources, manager, stdout)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/build.py", line 2927, in dispatch
process_graph(graph, manager)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/build.py", line 3325, in process_graph
process_stale_scc(graph, scc, manager)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/build.py", line 3420, in process_stale_scc
mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal_main.py", line 93, in semantic_analysis_for_scc
process_top_levels(graph, scc, patches)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal_main.py", line 220, in process_top_levels
deferred, incomplete, progress = semantic_analyze_target(
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal_main.py", line 349, in semantic_analyze_target
analyzer.refresh_partial(
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 600, in refresh_partial
self.refresh_top_level(node)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 611, in refresh_top_level
self.accept(d)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 6475, in accept
node.accept(self)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/nodes.py", line 1141, in accept
return visitor.visit_class_def(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 1600, in visit_class_def
self.analyze_class(defn)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 1685, in analyze_class
self.analyze_class_body_common(defn)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 1714, in analyze_class_body_common
self.apply_class_plugin_hooks(defn)
File "/path/to/project/venv/lib/python3.11/site-packages/mypy/semanal.py", line 1801, in apply_class_plugin_hooks
hook(ClassDefContext(defn, base_expr, self))
File "/path/to/project/venv/lib/python3.11/site-packages/sqlalchemy/ext/mypy/plugin.py", line 261, in _base_cls_hook
decl_class.scan_declarative_assignments_and_apply_types(ctx.cls, ctx.api)
File "/path/to/project/venv/lib/python3.11/site-packages/sqlalchemy/ext/mypy/decl_class.py", line 96, in scan_declarative_assignments_and_apply_types
_scan_declarative_assignment_stmt(
File "/path/to/project/venv/lib/python3.11/site-packages/sqlalchemy/ext/mypy/decl_class.py", line 459, in _scan_declarative_assignment_stmt
python_type_for_type = infer.infer_type_from_right_hand_nameexpr(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/project/venv/lib/python3.11/site-packages/sqlalchemy/ext/mypy/infer.py", line 52, in infer_type_from_right_hand_nameexpr
python_type_for_type = _infer_type_from_decl_column(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/project/venv/lib/python3.11/site-packages/sqlalchemy/ext/mypy/infer.py", line 410, in _infer_type_from_decl_column
return _infer_type_from_left_and_inferred_right(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/project/venv/lib/python3.11/site-packages/sqlalchemy/ext/mypy/infer.py", line 457, in _infer_type_from_left_and_inferred_right
format_type(orig_left_hand_type),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: format_type() missing 1 required positional argument: 'options'
This is a condensed minimal reproducible example. In short, Model is my abstract base model for all ORM classes. Bar is an ORM model that has an enum property. Declaring the column as enum would be correct, but it's not necessary to trigger the bug.
Your Environment
Mypy version used: 1.5.0+dev.c13f1d416e907f58bc77d086b84819f500f1bde9
Mypy command-line flags: -
Mypy configuration options from mypy.ini (and other config files):
If the bug still exists in the latest version of the sqlalchemy mypy plugin, it indicates that they need to update the plugin following #6617 (comment)
Crash Report
Running mypy on a file with a very basic sqlalchemy ORM model raises this error.
Traceback
To Reproduce
requirements.txt
This is a condensed minimal reproducible example. In short,
Model
is my abstract base model for all ORM classes.Bar
is an ORM model that has an enum property. Declaring the column asenum
would be correct, but it's not necessary to trigger the bug.Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: