Support knot.toml files in project discovery#15505
Merged
MichaReiser merged 2 commits intomainfrom Jan 17, 2025
Merged
Conversation
MichaReiser
commented
Jan 15, 2025
Comment on lines
94
to
96
| match PyProject::from_toml_str(&pyproject_str) { | ||
| Ok(pyproject) => Some(pyproject), | ||
| Err(error) => { | ||
| return Err(ProjectDiscoveryError::InvalidPyProject { | ||
| path: pyproject_path, | ||
| source: Box::new(error), | ||
| }) | ||
| } | ||
| } |
Member
Author
There was a problem hiding this comment.
map_err didn't work here (and below). The borrow checker gets mad at me for consuming pyproject_path in the closure and using it further down.
7c93c81 to
e23b85c
Compare
Contributor
|
carljm
approved these changes
Jan 15, 2025
| .unwrap_or_else(|| Name::new(root.file_name().unwrap_or("root"))) | ||
| } | ||
|
|
||
| /// Loads a project form a `knot.toml` file. |
Contributor
There was a problem hiding this comment.
Suggested change
| /// Loads a project form a `knot.toml` file. | |
| /// Loads a project from a `knot.toml` file. |
c8a8a01 to
b485a63
Compare
e23b85c to
e2fa098
Compare
e2fa098 to
9156686
Compare
dcreager
added a commit
that referenced
this pull request
Jan 17, 2025
* main: [red-knot] Inline `SubclassOfType::as_instance_type_of_metaclass()` (#15556) [`flake8-comprehensions`] strip parentheses around generators in `unnecessary-generator-set` (`C401`) (#15553) [`pylint`] Implement `redefined-slots-in-subclass` (`W0244`) (#9640) [`flake8-bugbear`] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (`B903`) (#15549) [red-knot] `type[T]` is disjoint from `type[S]` if the metaclass of `T` is disjoint from the metaclass of `S` (#15547) [red-knot] Pure instance variables declared in class body (#15515) Update snapshots of #15507 with new annotated snipetts rendering (#15546) [`pylint`] Do not report methods with only one `EM101`-compatible `raise` (`PLR6301`) (#15507) Fix unstable f-string formatting for expressions containing a trailing comma (#15545) Support `knot.toml` files in project discovery (#15505) Add support for configuring knot in `pyproject.toml` files (#15493) Fix bracket spacing for single-element tuples in f-string expressions (#15537) [`flake8-simplify`] Do not emit diagnostics for expressions inside string type annotations (`SIM222`, `SIM223`) (#15405) [`flake8-pytest-style`] Do not emit diagnostics for empty `for` loops (`PT012`, `PT031`) (#15542)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for
knot.tomlfiles during project discovery.knot.tomlfiles take precedence over anypyproject.tomlbut we still need to read thepyproject.tomlto get the project's name and any
requires-pythonconstraint (not part of this PR).This PR doesn't add support for:
knot.tomlfiles from ancestor directories (hierarchical configuration)Part of astral-sh/ty#219
Test Plan
Added unit test