How can mypy ignore a single line in a source file?
You can ignore type errors with # type: ignore
as of version 0.2 (see issue #500, Ignore specific lines):
PEP 484 uses
# type: ignore
for ignoring type errors on particular lines ...Also, using
# type: ignore
close to the top of a file [skips] checking that file altogether.Source: mypy#500
Also # mypy: ignore-errors
at the top of the file you want to ignore all works, if you are using shebang and coding lines should be like this:
#!/usr/bin/env python #-*- coding: utf-8 -*-# mypy: ignore-errors
I would rather config it in mypy.ini
For example, to ignore Django migrations:
[mypy-*.migrations.*]ignore_errors = True
And for mypy>=0.910, pyproject.toml is supported which can be set as follows:
[tool.mypy]python_version = 3.8ignore_missing_imports = true[[tool.mypy.overrides]]module = "*.migrations.*"ignore_errors = true