Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,30 @@ In most cases you should not need to specify `rename` manually (see the Note bel
distribution metadata to map module names like 'git' to their distributions
('GitPython').

### Dependency Groups (PEP 735)

Tach supports [PEP 735 dependency groups](https://peps.python.org/pep-0735/). By default, Tach will include dependencies from the `dev` dependency group when checking external dependencies.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should default to not including any dependency groups. i think in most cases you wouldn't want to import a dev dependency


To configure which dependency groups to include, add `[tool.tach.external]` to your `pyproject.toml`:

```toml
# In pyproject.toml
[dependency-groups]
dev = ["ruff", "mypy"]
test = ["pytest", "coverage"]

[tool.tach.external]
include_dependency_groups = ["dev", "test"]
```

This configuration is read from each package's `pyproject.toml`, making it suitable for monorepos where different packages may have different dependency groups.

Special values:
- `["all"]` - include all dependency groups
- `[]` - disable dependency groups entirely (only use `[project.dependencies]`)

If `[tool.tach.external]` is not specified, Tach defaults to `["dev"]`.

## Rules

Tach allows configuring the severity of certain issues. Each entry in the `rules` table can be set to `error`, `warn`, or `off`.
Expand Down
7 changes: 7 additions & 0 deletions public/tach-toml-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@
"type": "string"
},
"description": "List of external dependency names to ignore during checks"
},
"rename": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of module:name pairs to rename imports (e.g. 'PIL:pillow')"
}
},
"additionalProperties": false
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "tach"
version = "0.32.2"
version = "0.33.0"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can drop this change, i will handle bumping the version myself (there are several spots where it needs to be changed (see #851)

authors = [
{ name = "Caelean Barnes", email = "caeleanb@gmail.com" },
{ name = "Evan Doyle", email = "evanmdoyle@gmail.com" },
Expand Down
7 changes: 6 additions & 1 deletion python/tests/example/many_features/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "many_features"
version = "0.0.1"
dependencies = [
"pyyaml~=6.0",
"tomli>=1.2.2",
"tomli-w~=1.0",
"rich~=13.0",
Expand All @@ -14,6 +13,9 @@ dependencies = [
"importlib_metadata>=6.0; python_version == '3.7'",
]

[dependency-groups]
test_dep_groups = ["pyyaml~=6.0"]

[build-system]
requires = ["maturin>=1.5,<2.0"]
build-backend = "maturin"
Expand All @@ -22,3 +24,6 @@ build-backend = "maturin"
python-source = "real_src"
module-name = "tach.extension"
features = ["pyo3/extension-module"]

[tool.tach.external]
include_dependency_groups = ["test_dep_groups"]
7 changes: 7 additions & 0 deletions src/external/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ pub enum ParsingError {
TomlParse(#[from] toml::de::Error),
#[error("Missing field in TOML: {0}")]
MissingField(String),
#[error("Dependency group '{included}' included from '{from_group}' does not exist")]
MissingDependencyGroup {
included: String,
from_group: String,
},
#[error("Circular dependency group reference: '{group}' includes itself")]
CircularDependencyGroup { group: String },
}
Loading
Loading