ruff/crates/ruff_macros/src
Micha Reiser eb47a6634d
Add support for configuring knot in pyproject.toml files (#15493)
## Summary

This PR adds support for configuring Red Knot in the `tool.knot` section
of the project's
`pyproject.toml` section. Options specified on the CLI precede the
options in the configuration file.

This PR only supports the `environment` and the `src.root` options for
now.
Other options will be added as separate PRs.

There are also a few concerns that I intentionally ignored as part of
this PR:

* Handling of relative paths: We need to anchor paths relative to the
current working directory (CLI), or the project (`pyproject.toml` or
`knot.toml`)
* Tracking the source of a value. Diagnostics would benefit from knowing
from which configuration a value comes so that we can point the user to
the right configuration file (or CLI) if the configuration is invalid.
* Schema generation and there's a lot more; see
https://github.com/astral-sh/ruff/issues/15491

This PR changes the default for first party codes: Our existing default
was to only add the project root. Now, Red Knot adds the project root
and `src` (if such a directory exists).

Theoretically, we'd have to add a file watcher event that changes the
first-party search paths if a user later creates a `src` directory. I
think this is pretty uncommon, which is why I ignored the complexity for
now but I can be persuaded to handle it if it's considered important.

Part of https://github.com/astral-sh/ruff/issues/15491

## Test Plan

Existing tests, new file watching test demonstrating that changing the
python version and platform is correctly reflected.
2025-01-17 09:41:06 +01:00
..
cache_key.rs Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
combine.rs Add support for configuring knot in pyproject.toml files (#15493) 2025-01-17 09:41:06 +01:00
combine_options.rs Add #[automatically_derived] to derived impls (#8080) 2023-10-20 00:12:27 +00:00
config.rs Enable nursery rules: 'redundant_clone', 'debug_assert_with_mut_call', and 'unused_peekable' (#13920) 2024-10-25 09:46:30 +02:00
derive_message_formats.rs Derive message formats macro support to string (#14093) 2024-11-04 18:06:25 +01:00
kebab_case.rs [red-knot] Add infrastructure to declare lints (#14873) 2024-12-10 16:14:44 +00:00
lib.rs Add support for configuring knot in pyproject.toml files (#15493) 2025-01-17 09:41:06 +01:00
map_codes.rs Use a derive macro for Violations (#14557) 2024-11-27 09:41:40 +00:00
newtype_index.rs Fix comment copy/paste typo in newtype_index (#10892) 2024-04-11 18:43:52 -06:00
rule_code_prefix.rs Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
rule_namespace.rs Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
violation_metadata.rs Use a derive macro for Violations (#14557) 2024-11-27 09:41:40 +00:00