Skip to content

fix: detect slack-cli-hooks under any normalized python package name - #733

Open
zimeg wants to merge 2 commits into
mainfrom
clack/python-hooks-name-normalize
Open

zimeg wants to merge 2 commits into
mainfrom
clack/python-hooks-name-normalize

Conversation

@zimeg

@zimeg zimeg commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Changelog

Python projects that list slack_cli_hooks, or another spelling of slack-cli-hooks, in requirements.txt or pyproject.toml no longer get a second slack-cli-hooks<1.0.0 dependency added during project initialization with slack create or slack init.

Summary

This pull request recognizes an existing slack-cli-hooks dependency under any normalized Python package name, so spellings like slack_cli_hooks and Slack.CLI-Hooks no longer get a duplicate.

  • Python package names that differ only by name normalization are the same package. Matching ignores case and treats any run of -, _, or . as one separator.
  • installRequirementsTxt and installPyProjectToml only matched the exact text slack-cli-hooks. The examples in chore: replace requirements.txt with pyproject.toml dependencies slack-samples/bolt-python-examples#337 list "slack_cli_hooks==0.3.0" in pyproject.toml, so the CLI added "slack-cli-hooks<1.0.0" to them as a second entry.
  • Both checks now use containsPackage from a new pip.go, next to npm.go in the Node runtime. It normalizes each package name found in the file and compares it with slack-cli-hooks. Version specifiers, extras, and markers after the name don't affect the match, as in slack_cli_hooks[x]>=0.3; python_version>"3.9".

Testing

  1. Clone the examples and check out the pull request: gh repo clone slack-samples/bolt-python-examples && cd bolt-python-examples && gh pr checkout 337
  2. Go to an example that lists slack_cli_hooks==0.3.0 in pyproject.toml: cd ai/slackbot-mcp-client/no-auth
  3. Run slack init with this branch's build. Confirm it prints Found pyproject.toml with slack-cli-hooks, then decline the prompt to link an app.
  4. Run git diff pyproject.toml and confirm there are no changes. A build from main adds "slack-cli-hooks<1.0.0", to the dependencies array here.
  5. Repeat in a project whose requirements.txt lists slack_cli_hooks==0.3.0 and confirm it prints Found requirements.txt with slack-cli-hooks and leaves the file unchanged.

Notes

  • A name anywhere in the file still counts as declared, as with the earlier text match. That includes comments, #egg=slack_cli_hooks fragments, and [tool.poetry.dependencies] keys.
  • A package whose name only starts with slack-cli-hooks, such as slack-cli-hooks-example, no longer counts as declared, so slack-cli-hooks<1.0.0 is added next to it.
  • Possible follow-up: requirements.txt still looks for the exact text slack-bolt when deciding where to add the hooks line. With slack_bolt, the line is added at the end of the file. This affects placement only, not duplicates.

Requirements

🤖 Generated with Claude Code

Python package names compare equal after PEP 503 normalization, so
slack_cli_hooks, Slack.CLI-Hooks, and slack-cli-hooks all name the
same package. The check for an existing slack-cli-hooks dependency in
requirements.txt and pyproject.toml matched only the hyphenated
spelling, which added a second slack-cli-hooks<1.0.0 entry to projects
that declare slack_cli_hooks==0.3.0.

https://packaging.python.org/en/latest/specifications/name-normalization/

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added this to the Next Release milestone Oct 29, 2026
@zimeg zimeg added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch Use on pull requests to describe the release version increment area:bolt-python Related to github.com/slackapi/bolt-python labels Oct 29, 2026
@zimeg zimeg self-assigned this Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.14%. Comparing base (6f2fa68) to head (7fd1907).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #733   +/-   ##
=======================================
  Coverage   78.13%   78.14%           
=======================================
  Files         238      239    +1     
  Lines       18115    18121    +6     
=======================================
+ Hits        14154    14160    +6     
  Misses       3961     3961           

☔ View full report in Codecov by Harness.
📢 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.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added the changelog Use on updates to be included in the release notes label Oct 29, 2026
@zimeg
zimeg marked this pull request as ready for review October 29, 2026 05:10
@zimeg
zimeg requested a review from a team as a code owner October 29, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:bolt-python Related to github.com/slackapi/bolt-python bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented changelog Use on updates to be included in the release notes semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant