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

Spurious "Returning Any" error involving Self types #12626

Closed
inducer opened this issue Apr 19, 2022 · 1 comment
Closed

Spurious "Returning Any" error involving Self types #12626

inducer opened this issue Apr 19, 2022 · 1 comment
Labels
bug mypy got something wrong topic-self-types Types for self

Comments

@inducer
Copy link

inducer commented Apr 19, 2022

Bug Report

From the code in the following gist:

https://gist.github.com/inducer/bf7dd340bc752384c353335b665f4d68

I get an error (in strict mode) from code that I feel should not be producing one:

Returning Any from function declared to return "Taggable"

Seemingly in support of the assertion that the warning is spurious, the (largely equivalent) version remove_part_id_tag_2 (only a type hint added) checks OK.

To Reproduce

curl -L -O https://gist.githubusercontent.com/inducer/bf7dd340bc752384c353335b665f4d68/raw/23520c57e4dfdec2f31ae4fd083c917efa408600/mypy-remove-tag.py
$ mypy --strict mypy-remove-tag.py
mypy-remove-tag.py:13: error: Returning Any from function declared to return "Taggable"
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.942
  • Mypy command-line flags: --show-error-codes --strict (see run-mypy.sh)
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.10.4
  • Operating system and version: Debian Linux unstable/testing
@inducer inducer added the bug mypy got something wrong label Apr 19, 2022
@AlexWaygood AlexWaygood added the topic-self-types Types for self label Apr 19, 2022
@AlexWaygood
Copy link
Member

PEP 673 isn't yet supported by mypy, which is why you're getting strange errors here. You can follow along on progress with implementing PEP 673 support here: #11871.

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

No branches or pull requests

2 participants