Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add show_error_codes option to mypy config #5032

Merged
merged 2 commits into from
Feb 26, 2022
Merged

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Feb 25, 2022

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:

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.

@maffoo maffoo requested review from a team, vtomole and cduck as code owners February 25, 2022 23:56
@maffoo maffoo requested a review from dabacon February 25, 2022 23:56
@CirqBot CirqBot added the Size: XS <10 lines changed label Feb 25, 2022
Copy link
Collaborator

@vtomole vtomole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Seems like we can't make mypy refuse generic # type: ignores; e.g making users have to specify which type errors they are ignoring(# type: ignore[no-redef]).

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Feb 26, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Feb 26, 2022
@CirqBot CirqBot merged commit d696635 into master Feb 26, 2022
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Feb 26, 2022
@CirqBot CirqBot deleted the u/maffoo/mypy-error-codes branch February 26, 2022 01:37
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Feb 26, 2022
95-martin-orion pushed a commit to 95-martin-orion/Cirq that referenced this pull request Mar 2, 2022
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.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: XS <10 lines changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants