Skip to content

build: add mypy type checking - #54

Merged
WilliamBergamin merged 12 commits into
mainfrom
mypy
Nov 17, 2026
Merged

WilliamBergamin merged 12 commits into
mainfrom
mypy

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request replaces pytype with mypy, using the shared config, and fixes what it found. It's PR 3 of 4 and stacks on #53.

  • Adds scripts/run_mypy.sh, scripts/install_and_run_tests.sh, and a Typecheck CI job, and removes the pytype workflow
  • Types the HTTP request helpers and removes the unused # type: ignore comments
  • Fixes import slack_discovery_sdk.examples, which raised ImportError in the published package, and removes the root __init__.py that made the repo itself look like a package

Testing

  • ./scripts/run_mypy.sh is clean
  • New offline tests in tests/test_base_client.py exercise the request success and error paths against a local HTTP server; they also pass on the code before this PR

Requirements

🤖 Generated with Claude Code

WilliamBergamin and others added 5 commits November 16, 2026 12:47
Replace setup.py, setup.cfg, and pytest.ini with pyproject.toml, matching
python-slack-sdk, bolt-python, and python-slack-hooks. The new floor is
Python 3.7. A Python CI workflow runs the tests on 3.7 to 3.15 and PyPy,
and tests that need live Discovery API tokens now skip without them.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Use the ruff config shared by python-slack-sdk, bolt-python, and
python-slack-hooks, with format.sh and lint.sh scripts and a Lint CI job.
This removes the .flake8 config and the flake8 workflow.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Output of ./scripts/format.sh with no other changes: ruff format plus the
safe ruff check fixes (one import per line, docstring blank lines, an
unused import).

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Split each docstring summary onto its own line with a blank line after it,
end summaries with a period, and document the missing args, so the google
convention checks pass with the same ignores as the other python repos.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Replace pytype with mypy, using the config and scripts shared with
python-slack-sdk, bolt-python, and python-slack-hooks, and a Typecheck CI
job. Fix the errors it found:

- type the HTTP request helpers and drop the unused type: ignore comments
- allow an empty response body in DiscoveryResponse
- remove the root __init__.py, which made the repo look like a package
- fix the examples package, whose import of a parent module failed

Offline tests with a local HTTP server cover the success and error paths of
the request code that changed.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@WilliamBergamin WilliamBergamin mentioned this pull request Nov 16, 2026
3 tasks done
@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.26316% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.75%. Comparing base (eb28a25) to head (b5005f4).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...y_sdk/examples/user_based_eDiscovery_with_edits.py 0.00% 7 Missing ⚠️
slack_discovery_sdk/base_client.py 85.71% 2 Missing ⚠️
slack_discovery_sdk/examples/DLP_call_pattern.py 0.00% 2 Missing ⚠️
slack_discovery_sdk/examples/audit_logs_pattern.py 0.00% 2 Missing ⚠️
...very_sdk/examples/user_based_eDiscovery_pattern.py 0.00% 2 Missing ⚠️
...lack_discovery_sdk/examples/get_enterprise_info.py 0.00% 1 Missing ⚠️
slack_discovery_sdk/rate_limit_support.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #54       +/-   ##
===========================================
+ Coverage   23.86%   45.75%   +21.89%     
===========================================
  Files          17       17               
  Lines         637      636        -1     
===========================================
+ Hits          152      291      +139     
+ Misses        485      345      -140     

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

WilliamBergamin and others added 3 commits November 16, 2026 14:06
The license is now an SPDX expression with LICENSE.md as its license
file. This needs setuptools 77 or newer, which runs on Python 3.9+, so
the package is built on the latest Python. The py3-none-any wheel still
installs on 3.7+.

Because of this, the unit test jobs and install.sh no longer install the
package (that would build it on 3.7/3.8). The tests import it from
source, as in python-slack-sdk.

MANIFEST.in is dropped: setuptools already ships README.md, LICENSE.md,
and py.typed. PyPy is dropped from the classifiers and the test matrix
since it isn't tested.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good so far, one small note for when it's ready.

pytest -vv $test_target
else
pytest
./scripts/run_mypy.sh --no-install

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion (non-blocking): mypy isn't installed on 3.7 and 3.8, so this fails with mypy: command not found there. Maybe skip it on older Pythons?

WilliamBergamin and others added 3 commits November 17, 2026 14:30
The license goes back to license = { text = "MIT" }, like
python-slack-sdk, bolt-python, and python-slack-hooks. Without the
PEP 639 form, setuptools no longer needs to be 77 or newer, so the
package builds and installs from source on 3.7 and 3.8 again.

That lets install.sh run pip install -e . once more, so the README
setup flow can import the SDK when running the examples. run_all.sh is
restored because the README still points to it for running every
example.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 17, 2026 19:38
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 17, 2026 19:38

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Thanks @WilliamBergamin, a Typecheck job in CI means type regressions show up on the PR instead of after a release.

Base automatically changed from ruff to pyproject November 17, 2026 19:43
Base automatically changed from pyproject to main November 17, 2026 19:48
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@WilliamBergamin
WilliamBergamin merged commit bc9acd0 into main Nov 17, 2026
14 checks passed
@WilliamBergamin
WilliamBergamin deleted the mypy branch November 17, 2026 19:58
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.

3 participants