domainaware / parsedmarc

A Python package and CLI for parsing aggregate and forensic DMARC reports
https://domainaware.github.io/parsedmarc/
Apache License 2.0
962 stars 210 forks source link

Add Type Hints #455

Open nhairs opened 6 months ago

nhairs commented 6 months ago

It would be good if parsedmarc added and exposed typing information so that calling libraries can check they are passing the correct types.

In theory this shouldn't be too difficult as the doc-strings of most functions contain type information.

To support inline type hints would require dropping support for python<3.5, however given the security support schedule it may be desirable to drop support up to 3.7. Checking PyPI Stats, versions <=3.6 generally makeup less than 1% of daily downloads (though there appears to be the odd spike to ~5-10% for python 3.6).

image

In addition we'd want to add a requires-python>=3.7 to pyproject.toml to prevent older versions attempting to install a version they would be unable to run.

I'd be willing to help out with this.

nhairs commented 6 months ago

I've begun working on this at https://github.com/nhairs/parsedmarc/tree/typing

I'll note that there is more work than just adding type hints in that branch. At the same time I've done some refactoring, and applied the black code formatter (with line length 100). The end result should be more readable code that is still functionally the same as it was before adding any type hints.

There is however one major "breaking" change which is the require-python = ">=3.7" has been added to the pyproject.toml. This shouldn't actually cause breakages per-se as older python versions will not be able to download the version with incompatible changes.