Skip to content

E712 (Comparison to True should be cond is True) should be ignored when comparison is against pandas.Series #1852

@rsokolewicz

Description

@rsokolewicz

using ruff==0.0.215

The following snippet raises an E712 when running ruff:

import pandas as pd

df = pd.DataFrame({"x" : [False, True]})
df["x"] != False

and the autofix replaces df["x"] != False with df["x"] is not False. The two are unfortunately not equivalent and the latter leads to errors from pandas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions