ruff/crates/ruff_python_stdlib/src
Charlie Marsh 58f5f27dc3
Add TOML files to SourceType (#6929)
## Summary

This PR adds a higher-level enum (`SourceType`) around `PySourceType` to
allow us to use the same detection path to handle TOML files. Right now,
we have ad hoc `is_pyproject_toml` checks littered around, and some
codepaths are omitting that logic altogether (like `add_noqa`). Instead,
we should always be required to check the source type and handle TOML
files as appropriate.

This PR will also help with our pre-commit capabilities. If we add
`toml` to pre-commit (to support `pyproject.toml`), pre-commit will
start to pass _other_ files to Ruff (along with `poetry.lock` and
`Pipfile` -- see
[identify](b59996304f/identify/extensions.py (L355))).
By detecting those files and handling those cases, we avoid attempting
to parse them as Python files, which would lead to pre-commit errors.
(We tried to add `toml` to pre-commit here
(https://github.com/astral-sh/ruff-pre-commit/pull/44), but had to
revert here (https://github.com/astral-sh/ruff-pre-commit/pull/45) as it
led to the pre-commit hook attempting to parse `poetry.lock` files as
Python files.)
2023-08-28 15:01:48 +00:00
..
builtins.rs Use a match statement for builtin detection (#5798) 2023-07-16 04:57:57 +00:00
future.rs Rewrite a variety of .contains() calls as matches! statements (#5432) 2023-06-28 22:42:27 -04:00
identifiers.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
keyword.rs Remove some additional manual iterator matches (#5482) 2023-07-03 16:29:59 +00:00
lib.rs Introduce a ruff_python_semantic crate (#3865) 2023-04-04 16:50:47 +00:00
logging.rs Fix logging rules with whitespace around dot (#6022) 2023-07-24 05:14:48 +00:00
path.rs Add TOML files to SourceType (#6929) 2023-08-28 15:01:48 +00:00
str.rs Avoid allocations in lowercase comparisons (#5137) 2023-06-16 08:57:43 -04:00
sys.rs Remove HashMap and HashSet for known-standard-library detection (#5345) 2023-06-23 19:59:03 +00:00
typing.rs [B006] Add bytes to immutable types (#5776) 2023-07-15 13:04:33 +00:00