Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPS517: missed cases #1759

Closed
orsinium opened this issue Dec 4, 2020 · 2 comments
Closed

WPS517: missed cases #1759

orsinium opened this issue Dec 4, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@orsinium
Copy link
Collaborator

orsinium commented Dec 4, 2020

Bug report

What's wrong

"WPS517 | Found pointless starred expression" doesn't report string unpacking, dict constructor, and list conversion:

sum(**dict(a=2))
sum(*'hello')
sum(*list('hello'))

System information

flakehell.orsinium.dev playground

@orsinium orsinium added the bug Something isn't working label Dec 4, 2020
@sobolevn sobolevn added this to the Version 0.15 aka Python3.9 milestone Feb 6, 2021
@sobolevn sobolevn self-assigned this Feb 6, 2021
@sobolevn
Copy link
Member

sobolevn commented Feb 6, 2021

I leave *list() and **dict() for the typed-linter

@AIGeneratedUsername
Copy link

AIGeneratedUsername commented Aug 14, 2022

I am sorry for bumping an old issue, but I really wonder about what this rule. An example in docs does not mak things clear.

Here is a minimalist valid code example

def func(foo, *, bar, **kwargs):
    print(foo)
    print(bar)
    print(kwargs)


request_headers = {"spam": get_spam(), "eggs": calculated_value}

func("value", bar="hello", **request_headers)

Another obvious use case is creating models (I use dummy variables names, but the main point is that I want to show that we must unpack a dict):

calculated_data = {...  # a dict with some dynamic data
foo_bar = PydanticModel(**calculated_data)

I do not understand why I am asked to pass request_headers instead of the **request_headers when I need to pass kwargs from my dictionary with some dynamically generated data.

This is so obvious use case so either I am missing something, or you overlooked such use case when designing this rule. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants