Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type stubs #74

Open
smessmer opened this issue Sep 12, 2016 · 2 comments
Open

Add type stubs #74

smessmer opened this issue Sep 12, 2016 · 2 comments

Comments

@smessmer
Copy link

Great library, thanks.

I'm using it in one of my projects and recently wanted to migrate it to type hinting with mypy. Unfortunately, I failed, because appdirs doesn't provide type hints.

Could you either add type hints to appdirs.py, or alternatively, add a appdirs.pyi type stub file?

Thank you :)

@smessmer
Copy link
Author

Added a pull request with a working type stub file: #75

What's then still missing is including it into setup.py so it's actually downloaded to library users. Apart from that, it should work.

@cblegare
Copy link

Copying my comment from the PR

Inline typing might be a better fit, but, according to https://www.python.org/dev/peps/pep-0561/, you also would have to add the py.typed marker, which boils down to

  • convert the appdirs.py to an appdirs folder with a __init__.py
  • comment # type: ... everywhere
  • add a py.typed file in there
  • make sure that file is bundled within your wheel with some setuptools incantation, i.e
# py_modules=["appdirs"], # no need for this anymore
package_data={"appdirs": ["py.typed"]},
packages=["appdirs"]

see also https://mypy.readthedocs.io/en/latest/installed_packages.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants