Skip to content

Mypy does not properly type return value of decorator when decorating class #13283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zunda-arrow opened this issue Jul 29, 2022 · 1 comment
Closed
Labels
bug mypy got something wrong

Comments

@zunda-arrow
Copy link

Bug Report

Same as title. The code example below shows a function being properly typed.

To Reproduce
This code produces the bug.

class WorkedAsExpected:
    ...

def deco(a: Any) -> WorkedAsExpected:
    return WorkedAsExpected()

@deco
def function_test() -> None:
    ...

@deco
class ClassTest:
    ...

reveal_type(function_test)  # Revealed type is "test.WorkedAsExpected"
reveal_type(ClassTest)  # Revealed type is "def () -> test.ClassTest"

print(type(function_test))  # <class '__main__.WorkedAsExpected'>
print(type(ClassTest))  #<class '__main__.WorkedAsExpected'>

Expected Behavior

reveal_type should be the same type for the function and class examples. The function example is the expected result.

Your Environment

  • Mypy version used: 0.971 (compiled: yes)
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.8.12
  • Operating system and version: 5.18.14-arch1-1
@zunda-arrow zunda-arrow added the bug mypy got something wrong label Jul 29, 2022
@JelleZijlstra
Copy link
Member

Duplicate of #3135.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants