jazzband / geojson

Python bindings and utilities for GeoJSON
https://pypi.python.org/pypi/geojson/
BSD 3-Clause "New" or "Revised" License
913 stars 121 forks source link

Type of `coordinates` for `Polygon` should be list of list of tuples #162

Open stefano-xy opened 3 years ago

stefano-xy commented 3 years ago

PyCharm complains that:

Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)], [(-5.21, 23.51), (15.21, -10.81), (-20.51, 1.51), (-5.21, 23.51)]])

is invalid because it believes the __init__ method of Polygon expects either a tuple, or a list of tuples. I can't spot any type annotation in the project and I don't know where it reads this hint, if not from the docstring.

If this is the case, we should make clear that list of list of tuple is needed for Polygon and I think also MultiLineString.

I'd introduce separate __init__ in each class, that would be helpful for final users. Adding type annotation to function parameters and return values would also help.