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

Forbid getting known key from kwargs #567

Closed
orsinium opened this issue May 18, 2019 · 4 comments
Closed

Forbid getting known key from kwargs #567

orsinium opened this issue May 18, 2019 · 4 comments
Labels
level:starter Good for newcomers rule request Adding a new rule

Comments

@orsinium
Copy link
Collaborator

Sometimes I see code like this:

def f(**kwargs):
  name = kwargs.pop('name')
  name = kwargs.get('name')
  name = kwargs['name'] 

For all 3 cases 'name' should be regular argument in function:

def f(*, name, **kwargs):
  ...

Related to #425

@sobolevn sobolevn added feature New feature or request level:starter Good for newcomers rule request Adding a new rule and removed feature New feature or request labels Jun 15, 2019
@sobolevn
Copy link
Member

What if name is not provided? And we do not want to change the function's signature (we inherit something, use existing API)?

@orsinium
Copy link
Collaborator Author

orsinium commented Jun 20, 2019

What if name is not provided?

Every this case can be altered by signature:

# kwargs.get('name'):
def f(*, name=None):
  ...

# kwargs.pop('name') or kwargs['name']:
def f(*, name):
  ...

@sobolevn
Copy link
Member

I will think about it after #425 is implemented

@sobolevn
Copy link
Member

Closing, since we won't implement #425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level:starter Good for newcomers rule request Adding a new rule
Projects
None yet
Development

No branches or pull requests

2 participants