Skip to content

Add type stubs #74

Open
Open

Description

@smessmer

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 :)

Activity

  1. smessmer commented on Sep 12, 2016

    @smessmer
    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.

  2. cblegare commented on Dec 21, 2019

    @cblegare

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions