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

Убрать *args в сигнатурах методов после keyword с default value #547

Closed
MarshalX opened this issue Oct 31, 2022 · 2 comments
Assignees
Labels
hacktoberfest https://hacktoberfest.com/

Comments

@MarshalX
Copy link
Owner

В сигнатурах методов библиотеки часто встречается подобное:

def foo(a, b='c', *args, **kwargs): pass

Наличие *args не имеет никакого смысла так как у b есть default value. Передать что-то в args невозможно

@MarshalX MarshalX added the hacktoberfest https://hacktoberfest.com/ label Oct 31, 2022
@MarshalX MarshalX self-assigned this Oct 31, 2022
@MarshalX MarshalX changed the title Убрать *args в сигнатурах методов после keyword Убрать *args в сигнатурах методов после keyword с default value Nov 13, 2022
@MarshalX MarshalX mentioned this issue Nov 22, 2022
7 tasks
@MarshalX
Copy link
Owner Author

MarshalX commented Apr 22, 2023

Автор попутал берега

def t(a=1, b=2, *args, **kwargs):
        return a, b, args, kwargs

def t2(a=1, b=2, **kwargs):
    return a, b, kwargs

assert t(a=1, b=2, lol=3) == t2(a=1, b=2, lol=3)
assert t(1, 2, 3, 4, lol=5) == t2(1, 2, 3, 4, lol=5)
assert t(1, 2, 3, 4) == t2(1, 2, 3, 4)

@MarshalX
Copy link
Owner Author

MarshalX commented Apr 22, 2023

Нет, не попутал. Ишус был про такие внутренние случаи: result = self._request.post(url, data=data, *args, **kwargs). Вот тут нужно убрать бесполезный *args, или наоборот оживить ео удалив data=. В зависимости от случая

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest https://hacktoberfest.com/
Projects
None yet
Development

No branches or pull requests

1 participant