Skip to content

Commit

Permalink
fix: typos and added type hints (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ananya2001-an committed May 23, 2023
1 parent 68fe9ac commit 2357ccd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 33 deletions.
13 changes: 7 additions & 6 deletions routingpy/direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
:class:`.Direction` returns directions results.
"""
from typing import List, Optional


class Directions(object):
Expand All @@ -39,7 +40,7 @@ def __init__(self, directions=None, raw=None):
self._raw = raw

@property
def raw(self):
def raw(self) -> Optional[dict]:
"""
Returns the directions raw, unparsed response. For details, consult the routing engine's API documentation.
:rtype: dict or None
Expand All @@ -61,7 +62,7 @@ def __len__(self):

class Direction(object):
"""
Contains a parsed directions response. Access via properties ``geometry``, ``duration`` and ``distance``.
Contains a parsed directions' response. Access via properties ``geometry``, ``duration`` and ``distance``.
"""

def __init__(self, geometry=None, duration=None, distance=None, raw=None):
Expand All @@ -87,7 +88,7 @@ def __init__(self, geometry=None, duration=None, distance=None, raw=None):
self._raw = raw

@property
def geometry(self):
def geometry(self) -> Optional[List[List[float]]]:
"""
The geometry of the route as [[lon1, lat1], [lon2, lat2], ...] list.
Expand All @@ -96,7 +97,7 @@ def geometry(self):
return self._geometry

@property
def duration(self):
def duration(self) -> int:
"""
The duration of the entire trip in seconds.
Expand All @@ -105,7 +106,7 @@ def duration(self):
return self._duration

@property
def distance(self):
def distance(self) -> int:
"""
The distance of the entire trip in meters.
Expand All @@ -114,7 +115,7 @@ def distance(self):
return self._distance

@property
def raw(self):
def raw(self) -> Optional[dict]:
"""
Returns the route's raw, unparsed response. For details, consult the routing engine's API documentation.
Expand Down
2 changes: 1 addition & 1 deletion routingpy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# the License.
#
"""
Defines exceptions that are thrown by the ORS client.
Defines exceptions that are thrown by the various routing clients.
"""


Expand Down
16 changes: 8 additions & 8 deletions routingpy/expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
self._status = statuses

@property
def geometry(self):
def geometry(self) -> Optional[List[List[float]]]:
"""
The geometry of the edge as [[lon1, lat1], [lon2, lat2]] list.
Expand All @@ -46,7 +46,7 @@ def geometry(self):
return self._geometry

@property
def distance(self):
def distance(self) -> Optional[int]:
"""
The accumulated distance in meters for the edge in order of graph traversal.
Expand All @@ -55,7 +55,7 @@ def distance(self):
return self._distance

@property
def duration(self):
def duration(self) -> Optional[int]:
"""
The accumulated duration in seconds for the edge in order of graph traversal.
Expand All @@ -64,7 +64,7 @@ def duration(self):
return self._duration

@property
def cost(self):
def cost(self) -> Optional[int]:
"""
The accumulated cost for the edge in order of graph traversal.
Expand All @@ -73,7 +73,7 @@ def cost(self):
return self._cost

@property
def edge_id(self):
def edge_id(self) -> Optional[int]:
"""
The internal edge IDs for each edge in order of graph traversal.
Expand All @@ -82,7 +82,7 @@ def edge_id(self):
return self._edge_id

@property
def status(self):
def status(self) -> Optional[str]:
"""
The edge states for each edge in order of graph traversal.
Can be one of "r" (reached), "s" (settled), "c" (connected).
Expand Down Expand Up @@ -128,7 +128,7 @@ def center(self) -> Optional[Union[List[float], Tuple[float]]]:
"""
The center coordinate in [lon, lat] of the expansion, which is the location from the user input.
:rtype: list of float
:rtype: list of float or None
"""
return self._center

Expand All @@ -137,7 +137,7 @@ def interval_type(self) -> Optional[str]:
"""
Was it based on 'distance' or 'time'?
:return: str
:return: str or None
"""
return self._interval_type

Expand Down
19 changes: 10 additions & 9 deletions routingpy/isochrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# the License.
#
"""
:class:`Isochrone` returns directions results.
:class:`Isochrone` returns isochrones results.
"""
from typing import List, Optional, Tuple, Union


class Isochrones(object):
Expand All @@ -30,9 +31,9 @@ def __init__(self, isochrones=None, raw=None):
self._raw = raw

@property
def raw(self):
def raw(self) -> Optional[dict]:
"""
Returns the isochrones's raw, unparsed response. For details, consult the routing engine's API documentation.
Returns the isochrones' raw, unparsed response. For details, consult the routing engine's API documentation.
:rtype: dict or None
"""
Expand Down Expand Up @@ -63,7 +64,7 @@ def __init__(self, geometry=None, interval=None, center=None, interval_type=None
self._interval_type = interval_type

@property
def geometry(self):
def geometry(self) -> Optional[List[List[float]]]:
"""
The geometry of the isochrone as [[lon1, lat1], [lon2, lat2], ...] list.
Expand All @@ -72,18 +73,18 @@ def geometry(self):
return self._geometry

@property
def center(self):
def center(self) -> Optional[Union[List[float], Tuple[float]]]:
"""
The center coordinate in [lon, lat] of the isochrone. Might deviate from the input coordinate.
Not available for all routing engines (e.g. GraphHopper, Mapbox OSRM or Valhalla).
In this case, it will use the location from the user input.
:rtype: list of float
:rtype: list of float or None
"""
return self._center

@property
def interval(self):
def interval(self) -> int:
"""
The interval of the isochrone in seconds or in meters.
Expand All @@ -92,11 +93,11 @@ def interval(self):
return self._interval

@property
def interval_type(self):
def interval_type(self) -> Optional[str]:
"""
Was it based on 'distance' or 'time'?
:return: str
:return: str or None
"""
return self._interval_type

Expand Down
13 changes: 7 additions & 6 deletions routingpy/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# the License.
#
"""
:class:`Matrix` returns directions results.
:class:`Matrix` returns matrix results.
"""
from typing import List, Optional


class Matrix(object):
Expand All @@ -30,7 +31,7 @@ def __init__(self, durations=None, distances=None, raw=None):
self._raw = raw

@property
def durations(self):
def durations(self) -> Optional[List[List[float]]]:
"""
The durations matrix as list akin to::
Expand All @@ -46,7 +47,7 @@ def durations(self):
duration(origin2-destination2),
duration[origin3-destination3),
...
},
],
...
]
Expand All @@ -55,7 +56,7 @@ def durations(self):
return self._durations

@property
def distances(self):
def distances(self) -> Optional[List[List[float]]]:
"""
The distance matrix as list akin to::
Expand All @@ -71,7 +72,7 @@ def distances(self):
duration(origin2-destination2),
duration[origin3-destination3),
...
},
],
...
]
Expand All @@ -80,7 +81,7 @@ def distances(self):
return self._distances

@property
def raw(self):
def raw(self) -> Optional[dict]:
"""
Returns the matrices raw, unparsed response. For details, consult the routing engine's API documentation.
Expand Down
4 changes: 1 addition & 3 deletions routingpy/valhalla_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
# License for the specific language governing permissions and limitations under
# the License.
#
"""
:class:`Expansion` returns expansion results.
"""

from enum import Enum
from typing import List, Optional, Tuple, Union

Expand Down

0 comments on commit 2357ccd

Please sign in to comment.