Skip to content

Commit

Permalink
chore: improve / modernize type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraney committed Jul 26, 2024
1 parent 217ad73 commit 1f8ecb0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion python/hypy/hydrolocation/hydrolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def realized_nexus(self) -> str:
return self._realized_nexus

@property
def geometry(self) -> Point | Tuple:
def geometry(self) -> Point | tuple[float, float]:
"""
Geometric coordinates of the location as a `Point` or two-Tuple
"""
Expand Down
12 changes: 7 additions & 5 deletions python/hypy/hydrolocation/nwis_location.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Union, Tuple, TYPE_CHECKING
from __future__ import annotations

from typing import Tuple, TYPE_CHECKING
from hydrotools import nwis_client

from hypy.hydrolocation import HydroLocation, HydroLocationType
Expand All @@ -15,7 +17,7 @@ class NWISLocation(HydroLocation):
def __init__(self,
station_id: str,
realized_nexus: str,
shape: Union['Point', Tuple] = None,
shape: Point | Tuple = None,
referenced_position = None, #TODO implement indirect position?
):
"""
Expand All @@ -42,9 +44,9 @@ def station_id(self) -> str:
return self._station_id

def get_data(self,
start: Union[ str, 'datetime', 'datetime64', 'Timestamp', None ] = None,
end: Union[ str, 'datetime', 'datetime64', 'Timestamp', None ] = None
) -> 'DataFrame':
start: str | datetime | datetime64 | Timestamp | None = None,
end: str | datetime | datetime64 | Timestamp | None = None
) -> DataFrame:
"""
Get observation data from nwis
"""
Expand Down
19 changes: 12 additions & 7 deletions python/hypy/nexus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from typing import List, Optional, Tuple, TYPE_CHECKING, Union
from __future__ import annotations

from typing import TYPE_CHECKING

from .catchment import Catchment

if TYPE_CHECKING:
from .catchment import Catchment, Catchments_Collection
from .catchment import Catchments_Collection
from .hydrolocation.hydrolocation import HydroLocation

class Nexus():
"""
Expand All @@ -11,9 +16,9 @@ class Nexus():

def __init__(self,
nexus_id: str,
hydro_location,
receiving_catchments: 'Catchments_Collection' = tuple(),
contributing_catchments: 'Catchments_Collection' = tuple()):
hydro_location: HydroLocation,
receiving_catchments: Catchments_Collection = tuple(),
contributing_catchments: Catchments_Collection = tuple()):
"""
Set the nexus identity and params
Expand Down Expand Up @@ -44,7 +49,7 @@ def id(self) -> str:
return self._id

@property
def receiving_catchments (self) -> Tuple['Catchment', ...]:
def receiving_catchments (self) -> tuple[Catchment, ...]:
"""Tuple of Catchment object(s) receiving water from nexus
Returns
Expand All @@ -55,7 +60,7 @@ def receiving_catchments (self) -> Tuple['Catchment', ...]:
return self._receiving_catchments

@property
def contributing_catchments (self) -> Tuple['Catchment', ...]:
def contributing_catchments (self) -> tuple[Catchment, ...]:
"""Tuple of Catchment object(s) contributing water to nexus
Returns
Expand Down

0 comments on commit 1f8ecb0

Please sign in to comment.