Disable comparison overlap checks in assert statements #17896
Labels
false-positive
mypy gave an error on correct code
feature
needs discussion
topic-overlap
Overlapping equality check
Feature
In assert statements, allow comparisons that don't appear to overlap. These are common in test cases, and tend to generate false positives.
One way to implement this would be to filter out errors with the
comparison-overlap
error code in assert statements.A potentially better way would be to not narrow down types in comparisons in assert statements, but this could be too complicated and ad hoc.
Example where we have a false positive:
Pitch
These errors are often false positives, and they are somewhat frequent in test cases. The fix seems simple.
Hints
Here is an example of filtering errors adapted from
mypy/plugins/default.py
:The text was updated successfully, but these errors were encountered: