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
fromtypingimportSelf, Protocol, overloadfromcollections.abcimportSequenceclassEncoder(Protocol):
def__call__(self, u, /): ...
defsimplify(self) ->"Encoder":
returnselfclassChain(Encoder, Sequence[Encoder]):
encoders: list[Encoder]
def__init__(self, *encoders: Encoder):
self.encoders=list(encoders)
def__len__(self) ->int:
returnlen(self.encoders)
@overloaddef__getitem__(self, index: int) ->Encoder: ...
@overloaddef__getitem__(self, index: slice) ->Self: ...
def__getitem__(self, index, /):
returnself.encoders[index]
def__call__(self, x):
forencoderinself.encoders:
x=encoder(x)
returnxdefsimplify(self) ->Encoder|Self:
matchself:
case [encoder]:
returnencoder.simplify()
case_:
cls=type(self)
returncls(*(e.simplify() foreinself.encoders))
# The equivalent code below works...# if len(self)==1:# return self.encoders[0].simplify()# cls = type(self)# return cls(*(e.simplify() for e in self.encoders))
Actual Behavior
main.py:33: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 1.11.0+dev.0570f71f000489c94021d956662ab3373f7296bc
main.py:33: : note: please use --show-traceback to print a traceback when reporting a bug
Full Traceback
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/__main__.py", line 37, in <module>
console_entry()
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/main.py", line 100, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/main.py", line 182, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/build.py", line 192, in build
result = _build(
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/build.py", line 266, in _build
graph = dispatch(sources, manager, stdout)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/build.py", line 2942, in dispatch
process_graph(graph, manager)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/build.py", line 3340, in process_graph
process_stale_scc(graph, scc, manager)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/build.py", line 3441, in process_stale_scc
graph[id].type_check_first_pass()
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/build.py", line 2310, in type_check_first_pass
self.type_checker().check_first_pass()
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 481, in check_first_pass
self.accept(d)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 589, in accept
stmt.accept(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/nodes.py", line 1142, in accept
return visitor.visit_class_def(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 2340, in visit_class_def
self.accept(defn.defs)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 589, in accept
stmt.accept(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/nodes.py", line 1223, in accept
return visitor.visit_block(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 2802, in visit_block
self.accept(s)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 589, in accept
stmt.accept(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/nodes.py", line 787, in accept
return visitor.visit_func_def(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 1000, in visit_func_def
self._visit_func_def(defn)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 1004, in _visit_func_def
self.check_func_item(defn, name=defn.name)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 1077, in check_func_item
self.check_func_def(defn, typ, name, allow_empty)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 1309, in check_func_def
self.accept(item.body)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 589, in accept
stmt.accept(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/nodes.py", line 1223, in accept
return visitor.visit_block(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 2802, in visit_block
self.accept(s)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 589, in accept
stmt.accept(self)
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/nodes.py", line 1607, in accept
return visitor.visit_match_stmt(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 5107, in visit_match_stmt
pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checkpattern.py", line 129, in accept
result = o.accept(self)
^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/patterns.py", line 93, in accept
return visitor.visit_sequence_pattern(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checkpattern.py", line 335, in visit_sequence_pattern
new_type = self.construct_sequence_child(current_type, new_inner_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checkpattern.py", line 756, in construct_sequence_child
assert isinstance(proper_type, Instance)
AssertionError:
main.py:33: 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.0+dev.0570f71f000489c94021d956662ab3373f7296bc
main.py:33: : note: use --pdb to drop into pdb
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checker.py", line 5107, in visit_match_stmt
pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checkpattern.py", line 129, in accept
result = o.accept(self)
^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/patterns.py", line 93, in accept
return visitor.visit_sequence_pattern(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checkpattern.py", line 335, in visit_sequence_pattern
new_type = self.construct_sequence_child(current_type, new_inner_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/checkpattern.py", line 756, in construct_sequence_child
assert isinstance(proper_type, Instance)
AssertionError
Looks like a missed case in the match implementation.
Bug Report
The following causes an
INTERNAL ERROR
. The issue seems to be related to the usage of match-case.https://mypy-play.net/?mypy=master&python=3.12&flags=show-traceback&gist=7ccec270743b3e26d66d211839e82e64
To Reproduce
Actual Behavior
Full Traceback
Your Environment
https://mypy-play.net/?mypy=master&python=3.12&flags=show-traceback&gist=7ccec270743b3e26d66d211839e82e64
The text was updated successfully, but these errors were encountered: