Skip to content
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

Inconsistency for [func-returns-value]: Error not reported for staticmethods #14179

Open
harahu opened this issue Nov 24, 2022 · 0 comments · May be fixed by #18015
Open

Inconsistency for [func-returns-value]: Error not reported for staticmethods #14179

harahu opened this issue Nov 24, 2022 · 0 comments · May be fixed by #18015
Labels
bug mypy got something wrong

Comments

@harahu
Copy link

harahu commented Nov 24, 2022

Bug Report

Static methods decorated with staticmethod that return None do not result in a [func-returns-value] error being reported.

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.11&gist=519f480fe4f8840e0043c2555f951f2f

class Example:
    def no_op0(self) -> None:
        return None
        
    @staticmethod
    def no_op0s() -> None:
        return None
        
    def no_op1(self) -> None:
        return
    
    @staticmethod    
    def no_op1s() -> None:
        return
    
ex = Example()

# error: "no_op0" of "Example" does not return a value  [func-returns-value]
assert ex.no_op0() is None

# Decorated version is fine
assert ex.no_op0s() is None

# error: "no_op1" of "Example" does not return a value  [func-returns-value]
assert ex.no_op1() is None

# Decorated version is fine
assert ex.no_op1s() is None

Expected Behavior

A static method is just another callable and it makes sense for the behavior of the [func-returns-value] error to be the same for it as for other callables.

Actual Behavior

The behavior of the [func-returns-value] error for decorated static methods is different from that for other callables. No error is reported.

Your Environment

  • Mypy version used: 0.991
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11
@harahu harahu added the bug mypy got something wrong label Nov 24, 2022
brianschubert added a commit to brianschubert/mypy that referenced this issue Sep 27, 2024
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

Successfully merging a pull request may close this issue.

1 participant