Skip to content

Consider adding --strict-equality to --strict #7910

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

Closed
berquist opened this issue Nov 8, 2019 · 4 comments · Fixed by #8290
Closed

Consider adding --strict-equality to --strict #7910

berquist opened this issue Nov 8, 2019 · 4 comments · Fixed by #8290

Comments

@berquist
Copy link

berquist commented Nov 8, 2019

This doesn't report any errors with --strict-equality:

def foo() -> bool:
    x: int = 5
    y: str = "foo"
    return x == y


def bar() -> bool:
    x = 5
    y = "bar"
    return x == y


def is_magic(x: bytes) -> bool:
    # Error: Non-overlapping equality check (left operand type: "bytes",
    #        right operand type: "str")  [comparison-overlap]
    return x == "magic"


if __name__ == "__main__":
    print(foo())
    print(bar())
    print(is_magic(b"magic"))

even though the third example is from the docs.

Versions:

  • Python: 3.7.4
  • mypy: 0.750+dev.59617e8f895ca12a6fb0ec46f378ce384a757118
@ilevkivskyi
Copy link
Member

I don't know what you are doing, everything works perfectly for me. Maybe you have have a broken install, or something else.

@berquist
Copy link
Author

berquist commented Nov 9, 2019

I was using --strict, not --strict-equality.

@ilevkivskyi ilevkivskyi changed the title Strict equality false negatives Consider adding --strict-equality to --strict Nov 10, 2019
@ilevkivskyi
Copy link
Member

I was using --strict, not --strict-equality.

Hm, actually now that it is a bit more "mature" we can make it a strict flag, unless @msullivan is against.

See also #7469

@ilevkivskyi ilevkivskyi reopened this Nov 10, 2019
@msullivan
Copy link
Collaborator

Fine by me.

@JukkaL JukkaL self-assigned this Jan 16, 2020
JukkaL added a commit that referenced this issue Jan 16, 2020
JukkaL added a commit that referenced this issue Jan 16, 2020
Fixes #7910.

The stub changes are needed for clean output when using --strict.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants