The second error report is good, but, in line with the decision made in #6735, the first one is not:
# flags: --allow-redefinition-new --local-partial-types --strict-equalityx=1whileTrue:
ifx==str(): # error: Non-overlapping equality check (left operand type: "A", right operand type: "C")breakx=str()
ifx==int(): # error: Non-overlapping equality check (left operand type: "str", right operand type: "int")break
This could be easily fixed by letting the IterationErrorWatcher also handle COMPARISON_OVERLAP errors (which would already be an improvement over the current handling of functions with constrained type variables of just turning off --strict-equality temporarily). However, IterationErrorWatcher would need some adjustments to not accidentally filter out errors with slightly different texts, like in this case:
# flags: --allow-redefinition-new --local-partial-types --strict-equalityclassA: ...
classB: ...
classC: ...
x=A()
whileTrue:
ifx==C(): # error: Non-overlapping equality check (left operand type: "A", right operand type: "C")# error: Non-overlapping equality check (left operand type: "A | B", right operand type: "C")breakx=B()
Ideally, Mypy would only emit the last report (with A | B), which could eventually be implemented similarly to what is suggested in #19324 for reveal_type.
The second error report is good, but, in line with the decision made in #6735, the first one is not:
This could be easily fixed by letting the
IterationErrorWatcheralso handleCOMPARISON_OVERLAPerrors (which would already be an improvement over the current handling of functions with constrained type variables of just turning off--strict-equalitytemporarily). However,IterationErrorWatcherwould need some adjustments to not accidentally filter out errors with slightly different texts, like in this case:Ideally, Mypy would only emit the last report (with
A | B), which could eventually be implemented similarly to what is suggested in #19324 forreveal_type.