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

New checker for when an index-lookup is used together with dict.items() #4470

Closed
yushao2 opened this issue May 12, 2021 · 1 comment · Fixed by #4485
Closed

New checker for when an index-lookup is used together with dict.items() #4470

yushao2 opened this issue May 12, 2021 · 1 comment · Fixed by #4485
Assignees
Labels
Enhancement ✨ Improvement to a component Good first issue Friendly and approachable by new contributors Help wanted 🙏 Outside help would be appreciated, good for new contributors
Milestone

Comments

@yushao2
Copy link
Collaborator

yushao2 commented May 12, 2021

Is your feature request related to a problem? Please describe

As discussed with @cdce8p in #4445 :

A checker can be implemented to detect for instances where an index-lookup is used with dict.items()

for k10, v in b_dict.items():
  val = v + 2
  print(b_dict[k10])  # this is bad

Describe the solution you'd like

A new checker should be implemented to discourage use of index-lookup when the value can be pulled from v

for k10, v in b_dict.items():
  val = v + 2
  print(b_dict[k10])  # [use-value-from-dict-items]

Additional context

We could also think about what should happen if an index-lookup is used together with dict.items.

for k10, v in b_dict.items():
    val = v + 2
    print(b_dict[k10])

--
I realize this might all be a bit much at once, but keep in mind: The work you have already done is really good! Especially for a first-time contributor These are now just the finishing touches. If you encounter any issues or need help, please don't hesitate to ask.

@cdce8p,

I think this should be in a different error message altogether -- should I try my hand at implementing it within this PR or perhaps I should create a separate PR for that. I think it might be better to not bloat up this PR

Originally posted by @yushao2 in #4445 (comment)

@cdce8p cdce8p added Good first issue Friendly and approachable by new contributors Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors labels May 12, 2021
@yushao2
Copy link
Collaborator Author

yushao2 commented May 18, 2021

@cdce8p please assign this to me, i'll work on this alongside str-partition checker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Good first issue Friendly and approachable by new contributors Help wanted 🙏 Outside help would be appreciated, good for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants