Skip to content

Clarify SyntaxWarning with literal comparison #103492

Closed
@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