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 assigning to a slice #1629

Closed
sobolevn opened this issue Sep 30, 2020 · 7 comments · Fixed by #1661
Closed

Forbid assigning to a slice #1629

sobolevn opened this issue Sep 30, 2020 · 7 comments · Fixed by #1661
Assignees
Labels
good first issue Entrypoint to the project Hacktoberfest Hactoberfest fun! help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule

Comments

@sobolevn
Copy link
Member

Rule request

Thesis

There might be some crazy examples of mutation, when assigning to a slice:

my_list = [1, 2, 3]
my_list[0:3] = [0, 0, 0]

So, let's ban this.

However, we still allow regular index assignments:

my_list = [1, 2, 3]
my_list[0] = [0, 0, 0]

Is ok.

@sobolevn sobolevn added help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule Hacktoberfest Hactoberfest fun! good first issue Entrypoint to the project labels Sep 30, 2020
@sobolevn sobolevn added this to the Version 0.15 aka New runtime milestone Sep 30, 2020
@sobolevn sobolevn changed the title Forbid assigning to slice Forbid assigning to a slice Sep 30, 2020
@parzuko
Copy link

parzuko commented Oct 1, 2020

hey, can i take this issue ?

@sobolevn
Copy link
Member Author

sobolevn commented Oct 1, 2020

Yes, thanks a lot!

@sudo-k-runner
Copy link
Contributor

@parzuko are you working on this? if not would like to take this up.

@sobolevn
Copy link
Member Author

@sudo-k-runner feel free to take it 🙂

@sudo-k-runner
Copy link
Contributor

@sobolevn cool! kinda new to this, so would be great if I can get some pointers. Thanks!

@sobolevn
Copy link
Member Author

I recommed to start with our CONTRIBUTING.md and then ask any specific questions you have 👍

@sudo-k-runner
Copy link
Contributor

sure thing! Thanks 👍

sobolevn added a commit that referenced this issue Feb 7, 2021
* Added AssignToSliceViolation, related code and tests

* Updated CHANGELOG.md and added a pytest mark

* Added to forbid a[slice(1)] type assignment and tests

* removed an extra line from the end of noqa.py

* Improves docs

* Fixes CI

Co-authored-by: Karmanya <kk@Aishwaryas-MacBook-Pro.local>
Co-authored-by: sobolevn <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Entrypoint to the project Hacktoberfest Hactoberfest fun! help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants