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

[waiting for typed_ast PR] allow to write both "type: ignore" and "mypy: ignore" #2030

Closed
wants to merge 1 commit into from

Conversation

matthiaskramm
Copy link
Contributor

This is useful for adding mypy-specific ignores to typeshed.

@gvanrossum
Copy link
Member

@JukkaL what do you think of the idea?
@matthiaskramm I think this should also be done in the new/fast parser.

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 17, 2016

This looks reasonable -- I've thought about other mypy-specific directives, and # mypy: <something> was what I was thinking about using for them, so this would work together with those other (still hypothetical) extensions.

@gvanrossum
Copy link
Member

@ddfisher Can you comment on the need to also support this (# mypy: ignore comments) in typed_ast and/or mypy/fastparse.py?

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 17, 2016

If we are going to eventually migrate to only typed_ast / fastparse.py, this would have to be supported, right?

@ddfisher
Copy link
Collaborator

Yes, this will need to be added to typed-ast, and I don't think we
should merge this without typed-ast support, because otherwise use of it
would break the fast parser.

On Wednesday, August 17, 2016, Jukka Lehtosalo notifications@github.com
wrote:

If we are going to eventually migrate to only typed_ast / fastparse.py,
this would have to be supported, right?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2030 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAPAkZdiLZNhrEAr6MA3gADb1rZLOpxMks5qg1MxgaJpZM4Jl-UM
.

@ddfisher
Copy link
Collaborator

Is there an example use-case for this? typed-ast support aside, I feel a bit concerned about the need for this.

@matthiaskramm
Copy link
Contributor Author

There isn't a strong use case, but it would be convenient to have a mypy-specific "ignore", especially for typeshed.
For example, python/typeshed#464 has to, in its current version, prevent either mypy or pytype from parsing the file, since pytype doesn't allow you to write # type: ignore into a stub, and mypy needs it, for the odd Complex return.

@ddfisher
Copy link
Collaborator

Ah. FWIW, you currently cannot prevent mypy from parsing a file with a # type: ignore. See #626.

@gvanrossum
Copy link
Member

gvanrossum commented Aug 18, 2016 via email

@matthiaskramm
Copy link
Contributor Author

It is. What I mean by "prevent mypy from parsing a file" is:
Files in typeshed are tested with both mypy and pytype.
We have a blacklist for files that don't yet work with the pytype. We could have the same thing for mypy. But I'd greatly prefer just having a mypy-specific ignore, since that way, we don't have to skip the entire file.

@gvanrossum
Copy link
Member

gvanrossum commented Aug 18, 2016 via email

@gvanrossum gvanrossum changed the title allow to write both "type: ignore" and "mypy: ignore" [waiting for typed_ast PR] allow to write both "type: ignore" and "mypy: ignore" Sep 29, 2016
@gvanrossum
Copy link
Member

gvanrossum commented Nov 9, 2016

Hey @matthiaskramm,

It looks like this PR is pretty much stuck. I'm trying to clean up stuck PRs so that the list of PRs is not too long. If you feel like working on this some more, just go ahead and reopen it, or open a new PR -- the corresponding issue will remain open with a reference to this (closed) PR in it, so if someone else feels like tackling this problem they still have this PR as a starting point.

(In particular, we're waiting for a change in typed-ast first. Once that has landed I expect that adding the new functionality to mypy would require a different PR anyways.)

@gvanrossum gvanrossum closed this Nov 9, 2016
@oakkitten
Copy link

if you are here looking for a remedy for PyCharm's going crazy when it sees comments like # type: ignore[attr-defined], you can try putting a tab character, not a space, between # and type:. mypy will still recognize this as type comment while PyCharm won't. As PyCharm normally converts tabs to spaces, you will have to copy it in from somewhere.

still, it would be nice to have # mypy: ignore[...] as error codes seem to be mypy-specific and not a part of PEP. this syntax might be actually breaking the rules of PEP...

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

Successfully merging this pull request may close these issues.

5 participants