-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[red-knot] Persistent configuration #15491
Comments
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
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 take precedence over the options in the configuration file. For now, this PR only adds support for the `environment` and the `src.root` options. 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. It would be nice for diagnostics to know 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 #15491
## 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 #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 #15491 ## Test Plan Existing tests, new file watching test demonstrating that changing the python version and platform is correctly reflected.
Note mypy has gotten some use of being able to configure things on a module level, not path level. In particular, this works well for settings related to specific dependencies (e.g. ignoring them or ignoring their possible non-existence or ignoring PEP 561 warnings or setting implicit export behaviour etc etc) |
Interesting. Overall, we don't plan on emitting warnings for third-party code (we don't check third party code). Allowing non-existent modules is its own setting that only takes module names and the same is probably true for PEP 561. I'd have to look into implicit export behavior more closely. |
Support configuring Red Knot in a persistent configuration:
pyproject.toml
orknot.toml
.rules
: enable and disable rulesenvironment
: (python version, platform, search paths)files
: Override a sub-set of settings on a path levelsrc
: Which files should be considered first-party and what's the src rootterminal
: Configure color output, etc.respect-ignore-files
)requires-python
(I'm leaning towards just making it a field onProjectMetadata
because we only respect therequires-python
constraint in the project's configuration file)knot.toml
in any ancestor directory)The text was updated successfully, but these errors were encountered: