miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
831 stars 119 forks source link

include py.typed file to make typing annotations available for library users #223

Closed karlicoss closed 2 months ago

karlicoss commented 2 months ago

Hi! Mistletoe has type hints, but sadly they aren't available when you're using it as a library unless you include py.typed file (for example see https://blog.whtsky.me/tech/2021/dont-forget-py.typed-for-your-typed-python-package )

I checked the change locally: before the change running mypy on my project would result in this

src/promnesia/sources/markdown.py:7:1:7:1: error: Skipping analyzing "mistletoe": module is installed, but missing library stubs or py.typed marker  [import-untyped]
    import mistletoe
    ^
src/promnesia/sources/markdown.py:8:1:8:1: error: Skipping analyzing "mistletoe.span_token": module is installed, but missing library stubs or py.typed marker  [import-untyped]
    from mistletoe.span_token import AutoLink, Link
    ^

After the change that works! And now it's catching possible typos etc when using mistletoe

coveralls commented 2 months ago

Coverage Status

coverage: 94.207%. remained the same when pulling 99c2ef42798f5d76c337d7d5261aa8c4162fb5f6 on karlicoss:pytyped into 14b1876e9e830f77ecffb47e384f5026bd4523e4 on miyuchina:master.

pbodnar commented 2 months ago

@karlicoss, thank you! 👍 Testing took me a while because I hit some related issues, but this seems to work just fine in the end. :)