yaph / geonamescache

geonamescache - a Python library for quick access to a subset of GeoNames data.
https://pypi.org/project/geonamescache/
MIT License
99 stars 38 forks source link

[FEATURE REQUEST] type hints? #41

Open jicruz96 opened 1 month ago

jicruz96 commented 1 month ago

It'd be nice if this package had more type hints and .pyi files to get a better IDE experience when using the package under strict type checkers.

Would the package maintainer be okay with me providing a PR that adds type hints and .pyi files to the package?

I'd ensure type hints are compatible with Python >=3.8.

yaph commented 1 month ago

Hi thanks for your proposal! Do you intend to add the type hints exclusively in .pyi files?

jicruz96 commented 1 month ago

Hi thanks for your proposal! Do you intend to add the type hints exclusively in .pyi files?

@yaph I intended to add type hints directly to the source code then use stubgen to produce the .pyi files directly from source, but am happy to keep the source code untouched if preferred.

yaph commented 1 month ago

Directly in the source is fine for me. Are the .pyi really necessary in that case? I'd rather not put generated files into git.

jicruz96 commented 1 month ago

Are the .pyi really necessary in that case?

They're not. A user can auto-gen the stub files themselves. I'll submit a PR in a day or two then (:

yaph commented 1 month ago

Fine thank you!

jicruz96 commented 1 month ago

@yap A Pull Request is now available for review: #42

yaph commented 1 month ago

I get linting errors with regards to the types. The tool suggests to use from __future__ import annotations rather than importing from typing. The End of Life of Python 3.8 is in a few months and I think the 3.0 release is a good opportunity to drop support for it. So from typing import ... could be removed and types like Dict need to be rewritten as dict etc. What are your thoughts on this and would you want to make these changes?