mypy_clean_slate icon indicating copy to clipboard operation
mypy_clean_slate copied to clipboard

Handle multiline statements properly

Open geo7 opened this issue 5 months ago • 0 comments

Following https://github.com/geo7/mypy_clean_slate/issues/110 it was highlighted that multiline statements aren't currently being handled correctly

Running mypy_clean_slate on:

class Foo:
    bar: dict = {  # noqa: RUF012
        "int": int,
    }

Should result in:

class Foo:
    bar: dict = {  # type: ignore[type-arg] # noqa: RUF012
        "int": int,
    }

Currently (following https://github.com/geo7/mypy_clean_slate/issues/110 at least...) it raises a UserWarning

Some additional examples with expected (ish) results

Given:

x : list[int] = [1, 
     'a',
     3
]; print('hm')

Want:

x : list[int] = [1, 
                 'a', # type: ignore[list-item]
     3
]; print('hm')

Given:

x : list[int] = [
        1,  # first element
        'c',  # second element
        1,  # third element
]

Want:

x : list[int] = [
        1,  # first element
        'c', # type: ignore[list-item] # second element
        1,  # third element
]

geo7 avatar Mar 11 '24 12:03 geo7