mtkennerly / dunamai

Dynamic versioning library and CLI
https://dunamai.readthedocs.io/en/latest
MIT License
312 stars 24 forks source link

Add explicit Optional to types #44

Closed jonathangreen closed 2 years ago

jonathangreen commented 2 years ago

This PR adds Optional[] to type hints for parameters that can take None. This is useful when running mypy on code consuming Dunami as a library. Otherwise you get type errors from mypy when passing None as an argument to these functions.

error: Argument "metadata" to "serialize" of "Version" has incompatible type "Optional[bool]"; expected "bool"

I also updated the .pre-commit-config.yaml to run mypy with the --no-implicit-optional flag to catch parameters that should be marked as Optional in the future.

Thank you for the very helpful library! 🙏🏻