TypeError / secure

Lightweight modern Python library to add security headers (CSP, HSTS, etc.) to Django, Flask, FastAPI, and more. Secure defaults or fully customizable.
MIT License
880 stars 27 forks source link

Suggestion: Add Mypy library stubs / typing #30

Open OscarVanL opened 1 month ago

OscarVanL commented 1 month ago

I get this error from Mypy:

src/py_utils/headers.py:1: error: Cannot find implementation or library stub for module named "secure"  [import-not-found]
src/py_utils/headers.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

It'd be great if the library provided typing for Mypy šŸ˜

cak commented 1 month ago

Thanks for the suggestion, Oscar! Thatā€™s an excellent point about Mypy. Iā€™ll look into why Mypy is showing errors and work on a fix for the next release. Appreciate your contribution!

cak commented 1 month ago

Also, @OscarVanL, could you please double-check that secure is installed correctly in your environment? According to the Mypy documentation (https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports), the ā€˜Cannot find implementationā€™ error could happen if the package isnā€™t installed or if the py.typed marker isnā€™t being detected. Let me know if that helps, and Iā€™ll continue to investigate on my side as well!

OscarVanL commented 4 weeks ago

Thanks, I did double-check this and the package is installed in the environment I run mypy. I have seen this same error message in the past when packages are untyped (or for whatever reason mypy can't use the typing).