Skip to content

Add support for dependency groups#883

Open
mluogh-xdof wants to merge 3 commits intotach-org:mainfrom
mluogh-xdof:mluogh/dep-groups
Open

Add support for dependency groups#883
mluogh-xdof wants to merge 3 commits intotach-org:mainfrom
mluogh-xdof:mluogh/dep-groups

Conversation

@mluogh-xdof
Copy link
Copy Markdown

References #565

Add basic support for including dependency groups when using check-external. When the bool is set to true, the set of declared dependencies includes everything in all the dependency groups.

This should be a no-op by default as it is default (false).

If desired, later on we can do something more advanced like what the FR requests, but this would be enough for my use right now.

Copy link
Copy Markdown
Collaborator

@DetachHead DetachHead left a comment

Choose a reason for hiding this comment

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

thanks for the contribution!

"description": "List of module:name pairs to rename imports (e.g. 'PIL:pillow')"
},
"include_dependency_groups": {
"type": "boolean",
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 make this an array of strings. i can't think of many cases where you'd want to include all groups. i know you said this can be added later, but i would prefer if we did it now so we don't need to support two different ways of specifying this setting

if your use case is to include all groups, i think the best approach is to create an all group like the example in the PEP and reference it in your tach config like so:

[external]
include_dependency_groups = ["all"]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

To support this, I have changed it to read from pyproject.toml instead of a single global file, to better support the uv workspace monorepo pattern.

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 that's inconsistent with all the other settings which can be configured in either pyproject.toml or tach.toml. so ideally it would work in both (related: #854)

@mluogh-xdof
Copy link
Copy Markdown
Author

I believe many of these issues should be fixed now! PTAL


### 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

"description": "List of module:name pairs to rename imports (e.g. 'PIL:pillow')"
},
"include_dependency_groups": {
"type": "boolean",
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 that's inconsistent with all the other settings which can be configured in either pyproject.toml or tach.toml. so ideally it would work in both (related: #854)

Comment on lines +130 to +131
/// If `include_groups` contains "all", all groups are processed.
/// Otherwise, only the specified groups are processed.
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.

when i suggested an "all" group, i meant that you could define a group called "all" that includes all the other groups, rather than us having to special case the name "all" in tach.

i think if we do want to do this, to avoid ambiguity with a dependency group called "all", we should only allow "all" as a string instead of an item in the array. ie. the python type would be list[str] | Literal["all"].

this will also prevent users from specifying "all" with other dependency groups, which would be redundant

[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)

@DetachHead DetachHead linked an issue Dec 18, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: add support for dependency-groups

2 participants