Extend invalid-envvar-default (PLW1508) to detect os.environ.get#14512
Extend invalid-envvar-default (PLW1508) to detect os.environ.get#14512MichaReiser merged 6 commits intoastral-sh:mainfrom
invalid-envvar-default (PLW1508) to detect os.environ.get#14512Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PLW1508 | 40 | 40 | 0 | 0 | 0 |
|
Should I update the doc to mention both |
|
Is this a change to align the rule with the upstream rule? I think we should gate this behind preview, considering that it extends the scope of the rule (even though it is in the rule's intent) |
No, pylint only checks
Sounds good. How can I gate it behind preview? |
|
I think I've figured it out. |
|
@MichaReiser updated the code. |
| @@ -1,6 +1,5 @@ | |||
| --- | |||
| source: crates/ruff_linter/src/rules/pylint/mod.rs | |||
| snapshot_kind: text | |||
There was a problem hiding this comment.
Not sure why this was removed.
There was a problem hiding this comment.
Can you try updating your local cargo insta version running cargo install cargo-insta --force?
invalid-envvar-default (PLW1508) to flag os.environ.getos.environ.get in invalid-envvar-default (PLW1508)
os.environ.get in invalid-envvar-default (PLW1508)invalid-envvar-default (PLW1508) to detect os.environ.get
...s/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap
Show resolved
Hide resolved
…es__pylint__tests__PLW1508_invalid_envvar_default.py.snap
...snapshots/ruff_linter__rules__pylint__tests__preview__PLW1508_invalid_envvar_default.py.snap
Show resolved
Hide resolved
…es__pylint__tests__preview__PLW1508_invalid_envvar_default.py.snap
|
The extension seem useful in my view and it makes sense that I wonder if there's a reason for pylint not supporting I think it would be great to open an upstream issue first before we deviate unnecessarily. |
|
Sounds good. Let me file a ticket. |
|
Filed pylint-dev/pylint#10092. |
|
Thank you @harupy Let's give them a few days. I'm all in for merging if we don't hear back from them in a few days. In case I forget to check in, feel free to ping me! |
|
Pylint upstream is okay with supporting this, although they generally recommend using a type checker, which makes sense. |
…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).
…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).
…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).
Summary
Fix
invalid-envvar-default (PLW1508)to flagos.environ.get.Test Plan
New test case