Skip to content

feat(python): add pyproject.toml support for Python projects#311

Merged
mwbrooks merged 13 commits intomainfrom
mwbrooks-python-toml
Jan 29, 2026
Merged

feat(python): add pyproject.toml support for Python projects#311
mwbrooks merged 13 commits intomainfrom
mwbrooks-python-toml

Conversation

@mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented Jan 28, 2026

Changelog

Add pyproject.toml support to Bolt for Python projects. The slack create and slack init commands will now detect pyproject.toml files, add the slack-cli-hooks<1.0.0 to the dependency section (when missing), and display instructions on how to install the dependencies. Python projects now support either/both requirements.txt and pyproject.toml.

Summary

This pull request adds pyproject.toml support for Python projects with the following features:

  • Adds pyproject.toml support for Python projects when using slack init and slack create, complementing existing requirements.txt support
  • Automatically detects and updates either/both dependency files with slack-cli-hooks<1.0.0
  • Preserves original file formatting when modifying pyproject.toml (comments, whitespace, indentation)
  • Shows appropriate install instructions based on which dependency file(s) exist

🧪 50% of all +++ Additions are tests, so hopefully this isn't a scary PR review! 🙇🏻

Preview

2026-01-27-cli-pyproject-toml.mov

Reviewers

1. a) pyproject.toml exists with slack-cli-hooks

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
$ cp pyproject.toml.with-slack-cli-hooks pyproject.toml

# Test the app
$ lack init
→ Confirm: "Found pyproject.toml with slack-cli-hooks"

# Delete the app
$ cd ..
$ rm -rf test-app/

1. b) pyproject.toml exists missing slack-cli-hooks

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
$ cp pyproject.toml.no-slack-cli-hooks pyproject.toml

# Test the app
$ lack init
→ Confirm: "Updated pyproject.toml with slack-cli-hooks<1.0.0"

# Delete the app
$ cd ..
$ rm -rf test-app/

2. a) requirements.txt exists with slack-cli-hooks

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
$ cp requirements.txt.with-slack-cli-hooks requirements.txt

# Test the app
$ lack init
→ Confirm: "Found requirements.txt with slack-cli-hooks"

# Delete the app
$ cd ..
$ rm -rf test-app/

2. b) requirements.txt exists missing slack-cli-hooks

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
$ cp requirements.txt.no-slack-cli-hooks requirements.txt

# Test the app
$ lack init
→ Confirm: "Updated requirements.txt with slack-cli-hooks<1.0.0"

# Delete the app
$ cd ..
$ rm -rf test-app/

3. a) Both files exist with slack-cli-hooks

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
$ cp pyproject.toml.with-slack-cli-hooks pyproject.toml
$ cp requirements.txt.with-slack-cli-hooks requirements.txt

# Test the app
$ lack init
→ Confirm: "Found requirements.txt with slack-cli-hooks"
→ Confirm: "Found pyproject.toml with slack-cli-hooks"

# Delete the app
$ cd ..
$ rm -rf test-app/

3. b) Both files exist missing slack-cli-hooks

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
$ cp pyproject.toml.no-slack-cli-hooks pyproject.toml
$ cp requirements.txt.no-slack-cli-hooks requirements.txt

# Test the app
$ lack init
→ Confirm: "Updated requirements.txt with slack-cli-hooks<1.0.0"
→ Confirm: "Updated pyproject.toml with slack-cli-hooks<1.0.0"

# Delete the app
$ cd ..
$ rm -rf test-app/

4. Neither file exists

# Create the sample app
$ lack create test-app -t https://github.com/slack-samples/bolt-python-search-template -b mwbrooks-python-toml
$ cd test-app/

# Setup app with correct config file
# → Do nothing, there should not be a pyproject.toml or requirements.txt

# Test the app
$ lack init
→ Confirm: "Error: no Python dependency file found (requirements.txt or pyproject.toml)"

# Delete the app
$ cd ..
$ rm -rf test-app/

Requirements

@mwbrooks mwbrooks added this to the Next Release milestone Jan 28, 2026
@mwbrooks mwbrooks self-assigned this Jan 28, 2026
@mwbrooks mwbrooks requested a review from a team as a code owner January 28, 2026 00:31
@mwbrooks mwbrooks added enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment labels Jan 28, 2026
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 78.02198% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.93%. Comparing base (358f1cc) to head (98622fe).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/runtime/python/python.go 77.77% 11 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #311      +/-   ##
==========================================
+ Coverage   64.88%   64.93%   +0.04%     
==========================================
  Files         212      212              
  Lines       17555    17623      +68     
==========================================
+ Hits        11391    11443      +52     
- Misses       5095     5104       +9     
- Partials     1069     1076       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@mwbrooks LGTM! This is a nice addition and solid implementation! The parsing is good 📠

I left a few comments but nothing needing changes! Feel free to ship! 🚢 ✨

Comment on lines +115 to +118
// Check if slack-cli-hooks is already declared
if strings.Contains(fileData, slackCLIHooksPackageName) {
return fmt.Sprintf("Found pyproject.toml with %s", style.Highlight(slackCLIHooksPackageName)), nil
}
Copy link
Member

Choose a reason for hiding this comment

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

🧠 praise: Nice check for optional dependencies too!

Comment on lines +231 to +237
// Provide appropriate install command based on which file exists
if hasRequirementsTxt {
outputs = append(outputs, fmt.Sprintf(" Install project dependencies: %s", style.CommandText("pip install -r requirements.txt")))
}
if hasPyProjectToml {
outputs = append(outputs, fmt.Sprintf(" Install project dependencies: %s", style.CommandText("pip install -e .")))
}
Copy link
Member

Choose a reason for hiding this comment

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

🐍 praise: Supporting both together is a good call! IIRC pyproject.toml is recommended in current versions - we can follow up with findings across samples later too!

@mwbrooks
Copy link
Member Author

Thanks for the review @zimeg! 🙇🏻 I'm happy to hear that it's looking good and running smooth on your end too. 🧈 It feels like a healthy improvement for the CLI to support the pyproject.toml format. It's a step up from requirements.txt.

@mwbrooks mwbrooks enabled auto-merge (squash) January 29, 2026 00:41
@mwbrooks mwbrooks merged commit 2853d95 into main Jan 29, 2026
8 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-python-toml branch January 29, 2026 19:44
@mwbrooks mwbrooks added the changelog Use on updates to be included in the release notes label Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Use on updates to be included in the release notes enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments