Content-Length: 268845 | pFad | https://github.com/python/cpython/issues/103492

CE Clarify SyntaxWarning with literal comparison · Issue #103492 · python/cpython · GitHub
Skip to content

Clarify SyntaxWarning with literal comparison #103492

@hauntsaninja

Description

@hauntsaninja

I had a coworker slightly confused about the following warning, since None is a literal and is not None is idiomatic:

>>> 'a' is not None
<stdin>:1: SyntaxWarning: "is not" with a literal. Did you mean "!="?
True

I think this would be better as:

>>> 'a' is not None
<stdin>:1: SyntaxWarning: "is not" with str literal. Did you mean "!="?
True

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/103492

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy