-
Notifications
You must be signed in to change notification settings - Fork 330
Open
Description
Add Type Hints for Better Type Safety and IDE Support
Description
Currently, the python-pdfkit library does not provide type hints for its public API. This makes it harder for developers to leverage static type checking tools like mypy and reduces IDE autocompletion and linting capabilities.
Adding type hints will:
- Improve developer experience by enabling better autocompletion and inline documentation.
- Allow integration with static analysis tools for catching type-related bugs early.
- Align the library with modern Python best practices (PEP 484).
Proposed Solution
- Introduce type hints for all public functions, classes, and method signatures.
- Add a
py.typedmarker file to indicate that the package is typed. - Ensure compatibility with Python 3.7+ (or the minimum supported version).
- Optionally, provide a
typing_extensionsfallback for older versions if needed.
Example:
from typing import Optional, Dict, Any
def from_url(url: str, output_path: Optional[str] = None, options: Optional[Dict[str, Any]] = None) -> bytes:##Benefits
- Better IDE support (autocomplete, inline type info).
- Safer code through static type checking.
- Easier onboarding for new contributors and users.
References
Metadata
Metadata
Assignees
Labels
No labels