How to disable type checking for an entire namespace?

My few thousand line PyTorch project has 50 type warnings in PyCharm. I think it's a combination of bugs in PyTorch type hinting + bugs in PyCharm (ie, https://youtrack.jetbrains.com/issue/PY-38035). Is there a way to disable type checking for entire namespace? IE "torch.xyz" would not trigger type errors 

3 comments
Comment actions Permalink

Yes, you can define a scope for type checker inspection.

Inspection settings: File | Settings | Editor | Inspections

Scope settings: File | Settings | Appearance & Behavior | Scopes

https://www.jetbrains.com/help/pycharm/settings-scopes.html#Settings_Scopes.xml

 

Hope this helps

0
Comment actions Permalink

That doesn't seem to be quite it -- the problem is considered to be in "My Project" scope because that's where the type error is detected. I still want to detect problems inside my project, but I wanted to ignore errors in calls to "torch" module because this module is too hard to do for Type Inference (the reported type errors are not real) 

There's currently a solution to do "Suppress" which adds "noinspection PyTypeChecker" comment, but using this will add too many extra comments to my code

0
Comment actions Permalink

Yes, indeed, sorry I misunderstood. Unfortunately PyCharm doesn't have a way to disable inspections only for specific python libraries/modules.

In theory you can try writing some stubs to override default type hints, but I'm not sure it will help.

0

Please sign in to leave a comment.