1212
1313"""
1414
15+ import re
1516import warnings
16- import pandas as pd
1717from io import StringIO
18- import re
18+ from typing import List , Optional , Union , Tuple
19+
20+ import pandas as pd
1921
20- from dataretrieval .utils import to_str , format_datetime , update_merge
2122from dataretrieval .utils import BaseMetadata
23+ from dataretrieval .utils import format_datetime , to_str , update_merge
2224from .utils import query
2325
2426WATERDATA_BASE_URL = 'https://nwis.waterdata.usgs.gov/'
@@ -270,28 +272,31 @@ def _discharge_measurements(ssl_check=True, **kwargs):
270272 return _read_rdb (response .text ), NWIS_Metadata (response , ** kwargs )
271273
272274
273- def get_discharge_peaks (sites = None , start = None , end = None ,
274- multi_index = True , ssl_check = True , ** kwargs ):
275+ def get_discharge_peaks (sites : Optional [Union [List [str ], str ]] = None ,
276+ start : Optional [str ] = None , end : Optional [str ] = None ,
277+ multi_index : bool = True ,
278+ ssl_check : bool = True , ** kwargs ) -> Tuple [pd .DataFrame , BaseMetadata ]:
275279 """
276280 Get discharge peaks from the waterdata service.
277281
278282 Parameters
279283 ----------
280- sites: array of strings
284+ sites: list of strings, string, Optional
281285 If the waterdata parameter site_no is supplied, it will overwrite the
282286 sites parameter
283- start: string
287+ start: string, Optional
284288 If the waterdata parameter begin_date is supplied, it will overwrite
285289 the start parameter (YYYY-MM-DD)
286- end: string
290+ end: string, Optional
287291 If the waterdata parameter end_date is supplied, it will overwrite
288292 the end parameter (YYYY-MM-DD)
289- multi_index: boolean
290- If False, a dataframe with a single-level index (datetime) is returned
291- ssl_check: bool
293+ multi_index: boolean, Optional
294+ If False, a dataframe with a single-level index (datetime) is returned,
295+ default is True
296+ ssl_check: boolean, Optional
292297 If True, check SSL certificates, if False, do not check SSL,
293298 default is True
294- **kwargs: optional
299+ **kwargs: Optional
295300 If supplied, will be used as query parameters
296301
297302 Returns
@@ -314,6 +319,9 @@ def get_discharge_peaks(sites=None, start=None, end=None,
314319 ... start='1980-01-01', end='1980-01-02', stateCd='HI')
315320
316321 """
322+ if sites and not isinstance (sites , str ):
323+ assert isinstance (sites , list ), "sites must be a string or a list of strings"
324+
317325 start = kwargs .pop ('begin_date' , start )
318326 end = kwargs .pop ('end_date' , end )
319327 sites = kwargs .pop ('site_no' , sites )
0 commit comments