-
Notifications
You must be signed in to change notification settings - Fork 24
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
Introduce A006 for lambda shadowing #123
Conversation
Thanks, for taking the time to write the PR! 🙇🏾 😄 Though, I'm not sure if I mean, if you do: my_list = list()
my_list.append(1)
my_list.append(2)
my_list.append(3)
list = [1,2,3]
another_list = list() This last line breaks due to having reassigned the builtin But if we do the same with a lambda: one_list = list()
one_list.append(1)
one_list.append(2)
one_list.append(3)
my_lambda = lambda list: list[0]
my_lambda(one_list) # returns 1
second_list = list()
second_list.append(4)
second_list.append(5)
second_list.append(6)
my_lambda(second_list) # returns 4 This still works... let me think a bit more about it before deciding 🤔 |
I agree this isn't the same level of risk as other A002 errors , but it doesn't exactly look like great practice either. |
Indeed, but then, maybe we could use a new error code |
@gforcada done (sorry that check_function_definition and check_lambda_definition have duplicated code) |
@cielavenir Let's update the Readme too: A005:
A lambda argument is shadowing a Python builtin. |
@felixvd done. |
🙈 sorry! I just merged another contribution that added a |
@gforcada merged main |
@cielavenir one last request, sorry! 🙏🏾 could you add a line on With this it will be ready to get merged 😊 |
@gforcada done |
Thanks!! 😄 The date change was not needed, I will revert it myself after the merge. |
... and |
I added this to run_tests.py:
Then I see this:
This MR tries to fix it.
Reproduced in main/Python3, 1.5/Python3 and 1.5/Python2.
/cc @felixvd @ntohge