ruff
fe095040 - `[flake8-bandit]` Don't flag `BaseLoader`/`CBaseLoader` as unsafe in preview (`S506`) (#23510)

Commit
147 days ago
`[flake8-bandit]` Don't flag `BaseLoader`/`CBaseLoader` as unsafe in preview (`S506`) (#23510) ## Summary `yaml.BaseLoader` and `yaml.CBaseLoader` use `BaseConstructor` + `BaseResolver`, which do not resolve tags or construct arbitrary Python objects — they only produce basic types (lists, dicts, strings). They are strictly *less capable* than `SafeLoader`, not less safe. Currently, S506 flags `yaml.load(..., Loader=yaml.BaseLoader)` as unsafe. This is a false positive. This PR adds `BaseLoader` and `CBaseLoader` (the C-accelerated variant from `yaml.cyaml`) to the list of recognized safe loaders, gated behind preview mode per maintainer guidance. Closes #13604 ## Test Plan - Added test fixtures covering `BaseLoader`/`CBaseLoader` via all import paths (`yaml.*`, `yaml.loader.*`, `yaml.cyaml.*`, aliased imports) - Added preview diff test case using `assert_diagnostics_diff!` to verify BaseLoader diagnostics are suppressed only in preview mode - Verified with `cargo test -p ruff_linter`, `cargo clippy`, and `uvx prek run -a` --------- Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
Author
Parents
Loading