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

Commented arguments named type #14945

Closed
josephcomisi opened this issue Mar 23, 2023 · 2 comments
Closed

Commented arguments named type #14945

josephcomisi opened this issue Mar 23, 2023 · 2 comments
Labels
bug mypy got something wrong

Comments

@josephcomisi
Copy link

Hello,

I did not dive into the issue but this can still help, so here is what happens:

I use tox to run black, mypy and unittest.

I have dataclasses with several arguments. One of the arguments was commented and was named type, such as:

@dataclass
class A:
    first: int
    # type: int

Even though it was commented out, I have the following error message:
...: error: expected an indented block after class definition on line 190 [syntax]

I am not sure it is the intended behaviour. If it is, please disregard this issue.

@josephcomisi josephcomisi added the bug mypy got something wrong label Mar 23, 2023
@sobolevn
Copy link
Member

Mypy works with comments like # type: in a special way.

You can:

  1. Use # type: ignore comment to disable some errors
  2. (in the past) it was possible to specify types of things with # type: YOUR_TYPE comments

So, this is why # type: int comment is not understood by mypy.
Generally, it is a good idea to remove commented code, see https://github.com/wemake-services/flake8-eradicate

@hauntsaninja
Copy link
Collaborator

Yeah, this is expected behaviour. Closing as a duplicate of #13177

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2023
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

3 participants