-
-
Notifications
You must be signed in to change notification settings - Fork 403
Forbid complex grammar in slice #3427
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
Labels
rule request
Adding a new rule
Comments
Thanks for the idea. I will need to think about this and analyze our / real-world use-cases. |
Let's me make a PR and you will review my ideas and updates in detail. |
Open
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rule request
Allow only a name, constant, and attribute in slice args.
Thesis
Correct:
array[3:7]
array[start_index:end_index]
array[index.start:index.end]
Wrong:
array[my_dict["start_index"]:my_list[-1]]
array[start_index():index.end()]
Should be:
Reasoning
Complex grammar are difficult to read and should be stored in separate vars.
It's really difficult to review such many dependent constructions:
new_array = array[my_dict[":"]::get_step()]
It might also be worth forbidding an attribute, but I don't think it's a complex grammar.
But not
new_array = array[Slice(arg_1).MyArray(arg_2, arg_3).start:]
The text was updated successfully, but these errors were encountered: