Skip to content

Strengthen Type Hints Across fpdf2 #1680

@andersonhc

Description

@andersonhc

Over the last few years, type hints have become a foundation of modern Python development. Strong typing provides several benefits like detecting bugs earlier, improving editor/IDE support, and enabling safer refactoring.

With the rise of AI-based coding tools, high-quality type hints significantly improve the accuracy of auto-generated code and reduce errors. A strictly typed fpdf2 will greatly helps our users and AI models to use the API correctly.

As more projects adopt strict typing, fpdf2 is increasingly becoming a "typed gap" in otherwise well-typed codebases.

Community efforts like [types-fpdf2](https://pypi.org/project/types-fpdf2) exist to fill the typing gap, but maintaining them is difficult. fpdf2 evolves quickly, often with many changes per release, and stub updates lag behind (e.g., 2.8.5 stubs have not yet been published).

To address all of this, I am working on a big refactor of the fpdf2 codebase to make it strict typed and adding mypy into our CI pipeline.

This issue is mainly for visibility and discussion.

Feedback, suggestions, and concerns are welcome!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions