12

Is there a way to ignore all of the errors in certain packages within my project?

Some of the code in my project is compiled Protocol Buffers code which doesn't pass a MyPy check. It all lives within a directory /myproj/generated/proto.

Here's what I have in my mypy config file:

[mypy-myproject.generated]
ignore_missing_imports = True
ignore_errors = True

What can I add to this to make it ignore all error messages generated from an analysis of anything that's inside of myproject.generated?

This is a duplicate of a question on GitHub.

mehdix
  • 4,984
  • 1
  • 28
  • 36
Salim Fadhley
  • 6,975
  • 14
  • 46
  • 83
  • There is already [an answer](https://github.com/python/mypy/issues/6155#issuecomment-451933525) for the question on Github. Did it work for you? – mehdix Jan 07 '19 at 14:35
  • 1
    Not quite, but I discovered you can include path globs in addition to dotted module expressions in the ini file... that actually worked. – Salim Fadhley Jan 09 '19 at 09:25

2 Answers2

13

You can use a glob.

[mypy-myproject.generated.*]
ignore_errors = True

But you have to assure that you have __init__.py in /generated

Løiten
  • 3,185
  • 4
  • 24
  • 36
Gabriel Viviani
  • 170
  • 3
  • 10
1

You can also use ignore an entire folder or file via the exclude option.

Here is an example of an ini file:

[mypy]
exclude = generated

Well, of course it's a crutch. I do not pretend that this is the most correct way.