Skip to content

Commit

Permalink
Add show_error_codes option to mypy config (#5032)
Browse files Browse the repository at this point in the history
This causes mypy to show error codes in its output, which can be used to ignore specific type errors rather than blanket ignores. For example, given an error like:
```
cirq-core/cirq/_compat.py:37: error: Name 'cached_property' already defined (possibly by an import)  [no-redef]
```
we can then do:
```python
from backports.cached_property import cached_property  # type: ignore[no-redef]
```
Which ignores just that specific type error and also helps document what the error is.
  • Loading branch information
maffoo authored Feb 26, 2022
1 parent 853dde3 commit d696635
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev_tools/conf/mypy-next.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[mypy]
show_error_codes = true

[mypy-__main__]
follow_imports = silent
Expand Down
1 change: 1 addition & 0 deletions dev_tools/conf/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[mypy]
show_error_codes = true

[mypy-__main__]
follow_imports = silent
Expand Down

0 comments on commit d696635

Please sign in to comment.