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 py.typed file to package for PEP-561 compliance #315

Merged
merged 1 commit into from
Feb 6, 2022
Merged

Add py.typed file to package for PEP-561 compliance #315

merged 1 commit into from
Feb 6, 2022

Conversation

jdufresne
Copy link
Member

@jdufresne jdufresne commented Oct 16, 2021

Per PEP-561, packages that include type information that can be consumed
by other libraries should distribute a py.typed file. This tells mypy
and other tools to use type information shipped with the library.

This requires moving distro from a single module file to a package so
that it can ship data files. The original distro.py was not altered.
Only the __init__.py and __main__.py were added to facilitate being used
as a package. By keeping distro.py unaltered, this allows projects to
continue to vendor the file into their project without as before without
any modifications.

For details on PEP-561, see:
https://www.python.org/dev/peps/pep-0561/

For details on mypy using py.typed, see:
https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages

@jdufresne
Copy link
Member Author

This is another go at #299 but this time distro.py remains as-is to allow direct download and vendoring.

nir0s
nir0s previously approved these changes Nov 24, 2021
Copy link
Collaborator

@nir0s nir0s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

tests/test_distro.py Outdated Show resolved Hide resolved
@nir0s
Copy link
Collaborator

nir0s commented Nov 24, 2021

Please resolve conflicts.

I'm also wondering if there are cases in which people already download directly, which will now break.

Maybe there's a way to redirect? I'm not familiar with one, and believe it will result in a 301.

sethmlarson
sethmlarson previously approved these changes Dec 20, 2021
Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one small comment:

docs/conf.py Outdated Show resolved Hide resolved
@sethmlarson
Copy link
Contributor

@jdufresne This PR appears nearly complete, just pinging you in case you still intend to land it.

@sethmlarson
Copy link
Contributor

@jdufresne Looks like a recent merge introduced a rebase issue, could you handle that @jdufresne?

Per PEP-561, packages that include type information that can be consumed
by other libraries should distribute a py.typed file. This tells mypy
and other tools to use type information shipped with the library.

This requires moving distro from a single module file to a package so
that it can ship data files. The original distro.py was not altered.
Only the __init__.py and __main__.py were added to facilitate being used
as a packages. By keeping distro.py unaltered, this allows projects to
continue to vendor the file into their project without as before without
any modifications.

For details on PEP-561, see:
https://www.python.org/dev/peps/pep-0561/

For details on mypy using py.typed, see:
https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages
@jdufresne
Copy link
Member Author

@sethmlarson No problem. Rebased.

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @jdufresne!

@sethmlarson sethmlarson merged commit 4d76bd1 into python-distro:master Feb 6, 2022
@jdufresne jdufresne deleted the py-typed branch February 6, 2022 23:43
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Feb 17, 2022
https://build.opensuse.org/request/show/955104
by user sebix + dimstar_suse
- remove shebang from distro.py
- update to version 1.7.0:
 - BACKWARD COMPATIBILITY:
 - Dropped support for EOL Pythons 2.7, 3.4 and 3.5 [[#281](python-distro/distro#281)]
 - Dropped support for LSB and `uname` back-ends when `--root-dir` is specified [[#311](python-distro/distro#311)]
 - Moved `distro.py` to `src/distro/distro.py` [[#315](python-distro/distro#315)]
 - ENHANCEMENTS:
 - Documented that `distro.version()` can return an empty string on rolling releases [[#312](python-distro/distro#312)]
 - Documented support for Python 3.10 [[#316](python-distro/distro#316)]
 - Added official support for Rocky Linux distribution [[#318](https://github.com/python-distro/distr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants