Implement strict type hinting#1691
Conversation
|
Hi @Lucas-C I’d really appreciate your thoughts on whether we should move forward with this PR. This is a large change (strict typing across the whole codebase), but I tried to keep it as simple as possible — adding types only, without refactoring behavior. One benefit already paid off: while typing Strict typing gives us better IDE validation and helps catch issues earlier, but I’m aware it can also add verbosity and reduce some flexibility. Before we merge something this big, I’d love your perspective on whether you feel the trade-offs are worth it for the project. |
|
Hi @andersonhc Sorry for my lack of answer regarding this...
You did well in merging this, this is a really nice addition to |
This PR:
Adds strict typing across fpdf2, tightening method signatures, enums, and data structures so the library ships with full type info
Add a
py.typedfile that signals IDEs the fpdf2 library is typedConfigure strict mypy and pyright in pyproject.toml
Add mypy and pyright to the lint CI runner and to the pre-commit hook
The objective of this PR is to add type hinting with minimal code change otherwise.
The changes done other than typing were:
fpdf/util.pytotest/conftest.pyChecklist:
In case of a new feature, docstrings have been added, with also some documentation in the
docs/folderA mention of the change is present in
CHANGELOG.mdThis PR is ready to be merged
By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.