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

Create py.typed #636

Merged
merged 1 commit into from
Jan 31, 2021
Merged

Create py.typed #636

merged 1 commit into from
Jan 31, 2021

Conversation

Kircheneer
Copy link
Contributor

PEP561 compliancy to enable type checking when Nornir is imported (https://www.python.org/dev/peps/pep-0561/).

This solves an issue where mypy raises "found module but no type hints or library stubs" errors when Nornir is imported to a type-checked module.

PEP561 compliancy to enable type checking when Nornir is imported (https://www.python.org/dev/peps/pep-0561/).
@ktbyers
Copy link
Collaborator

ktbyers commented Jan 29, 2021

Did you check/verify that this file will be included with Nornir when uploaded to pypi (given Nornir is using Poetry)?

@Kircheneer
Copy link
Contributor Author

Did you check/verify that this file will be included with Nornir when uploaded to pypi (given Nornir is using Poetry)?

According to the docs the include/exclude directives are seeded from the .gitignore file - which does not include/exclude the py.typed file. If I download the .tar.gz from Pypi however it does not include everything thats not excluded from the .gitignore. How is a release conducted generally?

@ktbyers
Copy link
Collaborator

ktbyers commented Jan 29, 2021

I think I would test it this way...:

  1. Do poetry build and generate a wheel file in the dist directory.
  2. Use pip to install that wheel file
  3. Verify the py.typed file is included in the directory installed via pip.

I think that would probably be sufficient for verification.

@Kircheneer
Copy link
Contributor Author

I did the following (using Windows 10 with Git Bash):

$ poetry build
$ cd /other/directory
$ python -m venv venv
$ source venv/Scripts/activate
$ pip install /nornir/dir/dist/nornir-3.0.0-py3-none-any.whl
$ ls venv/Lib/site-packages/nornir
__init__.py  __pycache__/  core/  init_nornir.py  plugins/  py.typed

It looks like the file is indeed included by default.

@ktbyers
Copy link
Collaborator

ktbyers commented Jan 31, 2021

LGTM

@ktbyers ktbyers merged commit feb35e5 into nornir-automation:develop Jan 31, 2021
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

Successfully merging this pull request may close these issues.

2 participants