wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

False positive for `WPS529`

Open sobolevn opened this issue 4 months ago • 2 comments

Code like this

def func(**kwargs):
    if 'a' in kwargs:
        assert 'a_kwargs' not in kwargs
    else:
        kwargs['a'] = other(
            **kwargs.pop('a_kwargs', {}),
        )

raises WPS529

I don't think that it is correct, because we can't replace it with .get.

    # Correct:
    value = collection.get(key)
    if value is not None:
        print(value)

    # Wrong:
    if key in collection:
        print(collection[key])

sobolevn avatar Aug 03 '25 11:08 sobolevn

Can I work on this?)

LordGvozd avatar Aug 03 '25 12:08 LordGvozd

@LordGvozd thank you!

sobolevn avatar Aug 03 '25 14:08 sobolevn