def main(foo: 'comment with whitespace in it', # type: ignore
bar: 'yet another comment'):
print(foo + bar)
if __name__ == '__main__':
import plac; plac.call(main)
I use plac pretty much everyday, so this # type: ignore feature is very important. Unfortunately, it's not working for ~multiline~ function declarations.
Putting # type: ignore to the second line is not effective too. ~For single line function declarations, this just works okay.~
If this is not a bug and anyone knows a good workaround, I'd appreciate it.
You can skip the whole function by decorating it with @typing.no_type_check. Is this what you want?
Well, I'm afraid it isn't--I just want to skip type checking the function signature, but checking the whole contents is still necessary.
import typing
@typing.no_type_check
def main(foo: 'some comment with whitespace in it'):
print(1 + 'foo')
E.g. with this annotation, the obvious type error is not reported, which is not what I want.
--
btw I've found this problem occurs when the function signature has only one line, too; so I slightly edited the original post.
OK, I think I understand the problem. Type annotations are parsed by typed_ast and therefore should be valid Python expressions. Parse error in type annotation is a blocker currently that can't be ignored.
I think this is a bug.
Most helpful comment
OK, I think I understand the problem. Type annotations are parsed by
typed_astand therefore should be valid Python expressions. Parse error in type annotation is a blocker currently that can't be ignored.I think this is a bug.