[ty] Change environment.root to accept multiple paths (#18913)

This commit is contained in:
Micha Reiser 2025-06-24 14:52:36 +02:00 committed by GitHub
parent 0194452928
commit 833be2e66a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 28 deletions

View file

@ -134,9 +134,11 @@ python-version = "3.12"
#### `root`
The root of the project, used for finding first-party modules.
The root paths of the project, used for finding first-party modules.
If left unspecified, ty will try to detect common project layouts and initialize `src.root` accordingly:
Accepts a list of directory paths searched in priority order (first has highest priority).
If left unspecified, ty will try to detect common project layouts and initialize `root` accordingly:
* if a `./src` directory exists, include `.` and `./src` in the first party search path (src layout or flat)
* if a `./<project-name>/<project-name>` directory exists, include `.` and `./<project-name>` in the first party search path
@ -147,13 +149,14 @@ it will also be included in the first party search path.
**Default value**: `null`
**Type**: `str`
**Type**: `list[str]`
**Example usage** (`pyproject.toml`):
```toml
[tool.ty.environment]
root = "./app"
# Multiple directories (priority order)
root = ["./src", "./lib", "./vendor"]
```
---