Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Failure upon two ignores for type checkers #4880

@cmp0xff

Description

@cmp0xff

I am using the online formatter.

Describe the bug

black failed with two ignores for type checkers.

To Reproduce

import pandas as pd


interval_td = pd.Interval(
    pd.Timedelta("1 days"), pd.Timedelta("2 days"), closed="neither"
)


_td = (  # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
    interval_td
    - pd.Interval(  # type: ignore[operator]
        pd.Timedelta(1, "ns"), pd.Timedelta(2, "ns")
    )
)

And run it with the online playground.

The resulting error is:

INTERNAL ERROR: Black 25.1.1.dev28+g314f8cf on Python (CPython) 3.12.11 produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_rf3407oy.log

--- src
+++ dst
@@ -215,8 +215,6 @@
                 keywords=
             )  # /Call
         )  # /BinOp
     )  # /Assign
     type_ignores=
-    TypeIgnore(
-    )  # /TypeIgnore
 )  # /Module

Expected behavior

black should handle this.

Environment

Online playground

Additional context

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions