Skip to content

Commit 81cc81a

Browse files
authored
Make Rtree PEP 561-compliant, so that Mypy finds type hints (#243)
* Make Rtree PEP 561-compliant, so that Mypy finds type hints After #215, I was excited to take advantage of type hints in my projects that use Rtree. However, after upgrading to v1.0.0, mypy was giving [import errors]. According to those docs, mypy will only infer/lookup types from installed packages if they are [PEP 561] compliant. Fortunately, all that seems to [involve] is the inclusion of a `py.typed` marker file in the installed package. This PR is my attempt at doing just that. In my local testing, this seems to resolve the above Mypy import warnings. I'm new to setuptools and distributing sdist wheels though, so I'm not sure how to confirm this file will be included in the built wheels? From reading the [setuptools docs], I think this is right, but probably worth review from someone who knows these things better. [import errors]: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports [PEP 561]: https://peps.python.org/pep-0561/ [involve]: https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages [setuptools docs]: https://setuptools.pypa.io/en/latest/userguide/datafiles.html * Remove explicit inclusion of py.typed in setup.cfg It will already be included because we added it to MANIFEST.in, so listing it here is redundant. * prefer including py.typed via setuptools instead of MANIFEST.in afterall
1 parent 35e9201 commit 81cc81a

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

rtree/py.typed

Whitespace-only changes.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ include_package_date = True
3636
packages = rtree
3737

3838
[options.package_data]
39-
rtree = lib
39+
rtree = lib, py.typed
4040

4141
[flake8]
4242
max-line-length = 88

0 commit comments

Comments
 (0)