halcy / Mastodon.py

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
MIT License
867 stars 150 forks source link

module is installed, but missing library stubs or py.typed marker #364

Closed ZeeD closed 5 months ago

ZeeD commented 6 months ago

Hi. It seems that, while skimming at the code I see it seems well annotated, the distributed library does not expose it. From what I know from pep 561 it could be enough to just add an empty py.typed in the main package and publish it

halcy commented 5 months ago

Do you have any information about how that would work in practice / tooling side? Do I need to run something to export the type information on build, or should the build system just do that?

ZeeD commented 5 months ago

Well, from a cursory glance at your pyproject.toml it seems that you relies on setuptools to build your packages.

If you use the current version of setuptools (69.x.x) it should be enough to just create an empty mastodon/py.typed file in your repo and it should autodetect and include it in the package.

Otherwise, according to https://github.com/pypa/setuptools/issues/3136 it should be necessary to add include_package_data = True and options.package_data * = py.typed

If you share how you build the packages (what commands do you launch, how are they set up, etc) I may try to do the necessary changes

halcy commented 5 months ago

I usually just python setup.py sdist bdist_wheel. I will try adding the file.

halcy commented 5 months ago

added marker file, hopefully that does the trick

ZeeD commented 5 months ago

Hi! Thank you for the change. I've just cloned and created a package from main and - indeed - the py.typed is here:

$ python3.12 setup.py sdist bdist_wheel
...
$ unzip -l dist/Mastodon.py-1.8.1-py3-none-any.whl
Archive:  dist/Mastodon.py-1.8.1-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
...
        0  02-12-2024 10:50   mastodon/py.typed
...
---------                     -------
   385403                     40 files