Skip to content

Support variable keys in static dictionary key rule#9411

Merged
charliermarsh merged 1 commit intomainfrom
charlie/B
Jan 6, 2024
Merged

Support variable keys in static dictionary key rule#9411
charliermarsh merged 1 commit intomainfrom
charlie/B

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

Closes #9410.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jan 6, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) January 6, 2024 20:38
@charliermarsh charliermarsh merged commit 701697c into main Jan 6, 2024
@charliermarsh charliermarsh deleted the charlie/B branch January 6, 2024 20:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 6, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

{(1, "a"): value.upper() for value in data} # constant tuple
{(1, "a"): value.upper() for value in data} # Constant tuple
{constant: value.upper() for value in data}
{constant + constant: value.upper() for value in data}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome 🎉, so quick :)

I dont know if this is a common use case but I guess one case not covered here is if the key in an attr.
e.g.

{SomeClass.CONSTANT: val for val in data}
{Some.Class.CONSTANT: val for val in data}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, let me test that!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #9416

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement more flake8-bugbear rules

2 participants