Skip to content

Comments

Fix PLW1508 false positive for default string created via a mult operation#14841

Merged
AlexWaygood merged 2 commits intoastral-sh:mainfrom
UnknownPlatypus:fix-PLW1508-false_positive
Dec 8, 2024
Merged

Fix PLW1508 false positive for default string created via a mult operation#14841
AlexWaygood merged 2 commits intoastral-sh:mainfrom
UnknownPlatypus:fix-PLW1508-false_positive

Conversation

@UnknownPlatypus
Copy link
Contributor

Summary

Fix a false positive for default string created via a mult operation.

MY_VAR = os.environ.get("MY_VAR", "0" * 32)

I find the if matches!(op, Operator::Mult) branch inside the Operator::Mult match quite inelegant but was not sure of the most idiomatic way to handle this.

Test Plan

cargo nextest run and cargo insta test.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks!

@AlexWaygood
Copy link
Member

I find the if matches!(op, Operator::Mult) branch inside the Operator::Mult match quite inelegant but was not sure of the most idiomatic way to handle this.

Agreed -- I fixed it by splitting out the Operator::Mult handling into its own branch 👍 I think that makes more sense, even if it does introduce a tiny bit of repetition.

@AlexWaygood AlexWaygood added the bug Something isn't working label Dec 8, 2024
@AlexWaygood AlexWaygood enabled auto-merge (squash) December 8, 2024 18:24
@AlexWaygood AlexWaygood merged commit 8d9e408 into astral-sh:main Dec 8, 2024
@UnknownPlatypus
Copy link
Contributor Author

Wonderful thanks !

Btw, just wanted to say that the dev onboarding was really simple. The Contributing.md is doing a great job.
Thanks for that.

MichaReiser added a commit that referenced this pull request Mar 13, 2025
…LW1508`) (#16674)

## Summary
This PR stabilizes the new behavior introduced in
#14512 to also detect defalut
value arguemnts to `os.environ.get` that have an invalid type (not
`str`).
There's an upstream issue for this behavior change
pylint-dev/pylint#10092 that was accepted and
a PR, but it hasn't been merged yet.

This behavior change was first shipped with Ruff 0.8.1 (Nov 22). 

There has only be one PR since the new behavior was introduced but it
was unrelated to the scope increase
(#14841).
MichaReiser added a commit that referenced this pull request Mar 13, 2025
…LW1508`) (#16674)

## Summary
This PR stabilizes the new behavior introduced in
#14512 to also detect defalut
value arguemnts to `os.environ.get` that have an invalid type (not
`str`).
There's an upstream issue for this behavior change
pylint-dev/pylint#10092 that was accepted and
a PR, but it hasn't been merged yet.

This behavior change was first shipped with Ruff 0.8.1 (Nov 22). 

There has only be one PR since the new behavior was introduced but it
was unrelated to the scope increase
(#14841).
MichaReiser added a commit that referenced this pull request Mar 13, 2025
…LW1508`) (#16674)

## Summary
This PR stabilizes the new behavior introduced in
#14512 to also detect defalut
value arguemnts to `os.environ.get` that have an invalid type (not
`str`).
There's an upstream issue for this behavior change
pylint-dev/pylint#10092 that was accepted and
a PR, but it hasn't been merged yet.

This behavior change was first shipped with Ruff 0.8.1 (Nov 22). 

There has only be one PR since the new behavior was introduced but it
was unrelated to the scope increase
(#14841).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants