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
Are you reporting a bug, or opening a feature request?
Reporting a bug
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
fromtypingimport*fromdataclassesimportdataclassclassFoo:
passFooProducer=Callable[..., Foo]
@dataclass(frozen=True)classBar:
wrapped: FooProducerdefunpack_bar(x: Bar) ->FooProducer:
returnx.wrapped# This line flagsclassBaz:
def__init__(self, wrapped: FooProducer) ->None:
self.wrapped=wrappeddefunpack_baz(x: Baz) ->FooProducer:
returnx.wrapped# This line is ok
What is the actual behavior/output?
src/debug_mypy.py:18: error: Incompatible return value type (got "Foo", expected "Callable[..., Foo]")
Found 1 error in 1 file (checked 1 source file)
What is the behavior/output you expect?
No error.
What are the versions of mypy and Python you are using?
(env310) akuli@akuli-desktop:~/mypy$ cat >a.py
from typing import *
from dataclasses import dataclass
class Foo:
pass
FooProducer = Callable[..., Foo]
@dataclass(frozen=True)
class Bar:
wrapped: FooProducer
def unpack_bar(x: Bar) -> FooProducer:
return x.wrapped # This line flags
class Baz:
def __init__(self, wrapped: FooProducer) -> None:
self.wrapped = wrapped
def unpack_baz(x: Baz) -> FooProducer:
return x.wrapped # This line is ok
(env310) akuli@akuli-desktop:~/mypy$ python3 -m mypy a.py
Success: no issues found in 1 source file
Are you reporting a bug, or opening a feature request?
Reporting a bug
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
What is the actual behavior/output?
src/debug_mypy.py:18: error: Incompatible return value type (got "Foo", expected "Callable[..., Foo]")
Found 1 error in 1 file (checked 1 source file)
What is the behavior/output you expect?
No error.
What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
Yes
What are the mypy flags you are using? (For example --strict-optional)
None
If mypy crashed with a traceback, please paste
the full traceback below.
The text was updated successfully, but these errors were encountered: