Skip to content

Add type hints for public API#192

Merged
lavr merged 6 commits intomasterfrom
fix/issue-191-type-hints
Mar 31, 2026
Merged

Add type hints for public API#192
lavr merged 6 commits intomasterfrom
fix/issue-191-type-hints

Conversation

@lavr
Copy link
Copy Markdown
Owner

@lavr lavr commented Mar 31, 2026

Summary

  • Add type annotations to the public API surface: Message, html(), send(), attach(), render(), backend responses, DKIMSigner, file store classes, and utility functions
  • Add py.typed marker for PEP 561 compliance

Closes #191

Test plan

  • All imports verified — no runtime errors
  • Smoke test: message creation, as_string(), address parsing all work
  • Run full test suite in CI

lavr added 6 commits March 31, 2026 16:23
Python 2 support was removed in #188, so the wheel should no longer
be tagged as py2.py3-universal.
- pyupgrade: v2.4.3 → v3.21.2 (target py39+)
- reorder-python-imports: v2.3.0 → v3.16.0
- black: 19.10b0 → 26.3.1
- flake8: 3.8.2 → 7.3.0 (moved URL from gitlab to github)
- pre-commit-hooks: v3.1.0 → v6.0.0
Document all changes since v0.6, grouped by category:
breaking changes, additions, fixes, and maintenance.
Add type annotations to the public API surface:
- Message, html(), BaseMessage and all mixins
- SMTPBackend, Response, SMTPResponse
- DKIMSigner
- BaseFile, LazyHTTPFile, MemoryFileStore
- MessageID and utility functions

Add py.typed marker for PEP 561 compliance.
Use typing.Optional instead of X | None syntax in the AddressPair
type alias, since it's evaluated at runtime where PEP 604 union
syntax requires Python 3.10+.
Python 3.9 reached EOL in October 2025. Requiring 3.10+ lets us
use PEP 604 union syntax (X | Y) at runtime in type aliases.

- Add python_requires='>=3.10' to setup.py
- Remove 3.9 from CI matrix, tox envlist, and classifiers
- Update pyupgrade target to --py310-plus
- Revert Optional workaround in utils.py
@lavr lavr merged commit 0628c3c into master Mar 31, 2026
6 checks passed
@lavr lavr deleted the fix/issue-191-type-hints branch March 31, 2026 13:54
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.

Add type hints for public API

1 participant