From b3613458473a47ae77b748761213240f51c10266 Mon Sep 17 00:00:00 2001 From: Clinton McCrowey Date: Tue, 29 Oct 2024 16:22:07 -0400 Subject: [PATCH] clean up a source code static typing --- environment.yaml | 1 + mypy.ini | 27 +++++++- py.typed | 0 pyaqsapi/bybox/bybox.py | 51 ++++++++------- pyaqsapi/bycbsa/bycbsa.py | 43 +++++++------ pyaqsapi/bycounty/bycounty.py | 113 +++++++++++++++++---------------- pyaqsapi/byma/byma.py | 57 +++++++++-------- pyaqsapi/bypqao/bypqao.py | 65 ++++++++++--------- pyaqsapi/bysite/bysite.py | 115 +++++++++++++++++----------------- pyaqsapi/bystate/bystate.py | 115 +++++++++++++++++----------------- pyaqsapi/helperfunctions.py | 107 +++++++++++++++---------------- pyaqsapi/listfunctions.py | 44 +++++++------ pyaqsapi/metadatafunctions.py | 14 ++--- pyrightconfig.json | 3 + setup.py | 1 + 15 files changed, 385 insertions(+), 371 deletions(-) create mode 100644 py.typed create mode 100644 pyrightconfig.json diff --git a/environment.yaml b/environment.yaml index 756e464..4246490 100644 --- a/environment.yaml +++ b/environment.yaml @@ -2,6 +2,7 @@ name: setuppyaqsapi channels: - conda-forge + - defaults dependencies: - python>=3.8 - conda-build diff --git a/mypy.ini b/mypy.ini index 199742f..79553fa 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,4 +11,29 @@ exclude = (?x)( color_output = True mypy_path = $MYPY_CONFIG_FILE/ -#[mypy-pyaqsapi.*] \ No newline at end of file +[mypy-pyaqsapi.*] +ignore_missing_imports=True + +[mypy-pyaqsapi.helperfunctions] +ignore_missing_imports=True + +[mypy-pyaqsapi.bysite] +ignore_missing_imports=True + +[mypy-pyaqsapi.bycbsa] +ignore_missing_imports=True + +[mypy-pyaqsapi.byma] +ignore_missing_imports=True + +[mypy-pyaqsapi.bystate] +ignore_missing_imports=True + +[mypy-pyaqsapi.bycounty] +ignore_missing_imports=True + +[mypy-pyaqsapi.bysite] +ignore_missing_imports=True + +[mypy-pyaqsapi.listfunctions] +ignore_missing_imports=True \ No newline at end of file diff --git a/py.typed b/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyaqsapi/bybox/bybox.py b/pyaqsapi/bybox/bybox.py index b708f50..040a7cb 100644 --- a/pyaqsapi/bybox/bybox.py +++ b/pyaqsapi/bybox/bybox.py @@ -3,7 +3,6 @@ """ from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -19,9 +18,9 @@ def monitors( maxlat: str, minlon: str, maxlon: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, ): """ Return a table of monitors. @@ -52,7 +51,7 @@ def monitors( Only data west of this longitude will be returned. Note that -80 is less than -70. return_header : If FALSE (default) only returns data requested. If TRUE - returns a AQSAPI_v2 object. + returns a AQSAPI_V2 object. Examples -------- @@ -114,18 +113,18 @@ def sampledata( maxlat: str, minlon: str, maxlon: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - duration: Optional[str] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + duration: str | None = None, + return_header: bool | None = False, +) -> DataFrame | AQSAPI_V2: """ Return sample data where the data is aggregated by latitude/longitude bounding box (_by_box). If return_header is FALSE (default) this function returns a single DataFrame with the requested data. If return_header is - TRUE returns a list of AQSAPI_v2 objects + TRUE returns a list of AQSAPI_V2 objects Parameters ---------- @@ -158,7 +157,7 @@ def sampledata( aqs_sampledurations() for a list of all available duration codes. return_header : If FALSE (default) only returns data requested. If TRUE - returns a AQSAPI_v2 object. + returns a AQSAPI_V2 object. Examples -------- @@ -215,10 +214,10 @@ def annualsummary( maxlat: str, minlon: str, maxlon: str, - cbdate: Union[None, date] = None, - cedate: Union[None, date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> DataFrame | AQSAPI_V2: """ Return a DataFrame of annual data aggregated by latitude/longitude bounding box (_by_box). @@ -250,7 +249,7 @@ def annualsummary( Only data west of this longitude will be returned. Note that -80 is less than -70. return_header : If FALSE (default) only returns data requested. If TRUE - returns a AQSAPI_v2 object. + returns a AQSAPI_V2 object. Examples -------- @@ -306,10 +305,10 @@ def dailysummary( maxlat: str, minlon: str, maxlon: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> DataFrame | AQSAPI_V2: """ Return a DataFrame of daily summary data aggregated by latitude/longitude bounding box (_by_box). @@ -340,7 +339,7 @@ def dailysummary( Only data west of this longitude will be returned. Note that -80 is less than -70. return_header : If FALSE (default) only returns data requested. If TRUE - returns a AQSAPI_v2 object. + returns a AQSAPI_V2 object. Examples -------- @@ -397,11 +396,11 @@ def quarterlysummary( maxlat: str, minlon: str, maxlon: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - duration: Optional[str] = None, + cbdate: date | None = None, + cedate: date | None = None, + duration: str | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> DataFrame | AQSAPI_V2: """ Return a DataFrame of quarterly data aggregate by latitude/longitude bounding box (_by_box). @@ -449,7 +448,7 @@ def quarterlysummary( Only data west of this longitude will be returned. Note that -80 is less than -70. return_header : If FALSE (default) only returns data requested. If TRUE - returns a AQSAPI_v2 object. + returns a AQSAPI_V2 object. Examples -------- diff --git a/pyaqsapi/bycbsa/bycbsa.py b/pyaqsapi/bycbsa/bycbsa.py index dcf5586..27664f6 100644 --- a/pyaqsapi/bycbsa/bycbsa.py +++ b/pyaqsapi/bycbsa/bycbsa.py @@ -2,7 +2,6 @@ (by Core Based Statistic Area, as defined by the Census Bureau).""" from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -15,10 +14,10 @@ def monitors( bdate: date, edate: date, cbsa_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of monitors. @@ -102,11 +101,11 @@ def sampledata( bdate: date, edate: date, cbsa_code: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return sample data where the data is aggregated at the Core Based Statistical Area (cbsa) level. @@ -192,10 +191,10 @@ def annualsummary( bdate: date, edate: date, cbsa_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of annual data aggregated at the Core Based Statistical Area (cbsa) level. @@ -277,10 +276,10 @@ def dailysummary( bdate: date, edate: date, cbsa_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of data aggregated by Core Based Statistical Area (cbsa). @@ -362,10 +361,10 @@ def quarterlysummary( bdate: date, edate: date, cbsa_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return quarterly summary data aggregated by Core Based Statistical Area (cbsa_code). diff --git a/pyaqsapi/bycounty/bycounty.py b/pyaqsapi/bycounty/bycounty.py index a832aad..7394f45 100644 --- a/pyaqsapi/bycounty/bycounty.py +++ b/pyaqsapi/bycounty/bycounty.py @@ -1,7 +1,6 @@ """Functions that aggregate data by county.""" from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -15,10 +14,10 @@ def monitors( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of monitors. @@ -112,10 +111,10 @@ def qa_flowrateaudit( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[AQSAPI_V2, DataFrame]: +) -> AQSAPI_V2 | DataFrame: """ Return Quality assurance flowrate audit data. @@ -205,10 +204,10 @@ def qa_one_point_qc( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table containing flow rate audit data aggregated by parameter code, stateFIPS and countycode for bdate - edate time frame. @@ -296,10 +295,10 @@ def qa_pep_audit( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table containing quality assurance Performance Evaluation Program (PEP) audit data aggregated by parameter code, stateFIPS and countycode for @@ -403,11 +402,11 @@ def sampledata( edate: date, stateFIPS: str, countycode: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return sample data where the data is aggregated at the county level. @@ -510,10 +509,10 @@ def annualsummary( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of annual data aggregated at the county level. @@ -605,10 +604,10 @@ def qa_blanks( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of blank quality assurance data. Blanks are unexposed sample collection devices (e.g., @@ -699,10 +698,10 @@ def dailysummary( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of data aggregated at the county level. @@ -793,10 +792,10 @@ def qa_collocated_assessments( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of collocated assessment data aggregated by matching input parameter, stateFIPS and county_code provided for bdate - edate time @@ -885,10 +884,10 @@ def qa_flowrateverification( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table containing flow rate Verification data for a parameter code aggregated matching input parameter, stateFIPS, and county_code, provided @@ -977,10 +976,10 @@ def transactionsample( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return transactionsample data - aggregated by county in the AQS Submission Transaction Format (RD) sample (raw) data for a parameter code aggregated @@ -1072,10 +1071,10 @@ def qa_annualperformanceeval( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return quality assurance performance evaluation data - aggregated by site for a parameter code aggregated by matching input @@ -1166,10 +1165,10 @@ def qa_annualperformanceevaltransaction( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return AQS submissions transaction format (RD) of the annual performance evaluation data (raw). Includes data pairs for @@ -1262,10 +1261,10 @@ def quarterlysummary( edate: date, stateFIPS: str, countycode: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of quarterly data aggregated at the county level. diff --git a/pyaqsapi/byma/byma.py b/pyaqsapi/byma/byma.py index 6c2f2fa..8040037 100644 --- a/pyaqsapi/byma/byma.py +++ b/pyaqsapi/byma/byma.py @@ -1,7 +1,6 @@ """Functions that aggregate data by ma (By Monitoring Agency).""" from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -14,10 +13,10 @@ def qa_flowrateaudit( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return Quality assurance flowrate audit data. @@ -95,10 +94,10 @@ def qa_one_point_qc( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return a table one point QC check data aggregated by monitoring agency code (_by_MA). @@ -174,10 +173,10 @@ def qa_pep_audit( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return a table of Performance Evaluation Program (PEP) audit data aggregated by monitoring agency code (_by_MA) for the time frame between @@ -258,10 +257,10 @@ def qa_blanks( bdate: str, edate: str, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return a table of blank quality assurance data. Blanks are unexposed sample collection devices (e.g., filters) that are transported with the @@ -340,10 +339,10 @@ def qa_collocated_assessments( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return a table of collocated assessment data aggregated by matching input parameter, and monitoring agency (MA) code provided for bdate - edate @@ -424,10 +423,10 @@ def qa_flowrateverification( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return a table containing flow rate Verification data for a parameter code aggregated by matching input parameter, and monitoring agency (MA) code @@ -508,10 +507,10 @@ def transactionsample( bdate: str, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return transactionsample data - aggregated by Monitoring agency (MA) in the AQS Submission Transaction Format (RD) sample (raw) data for a @@ -591,10 +590,10 @@ def qa_annualpeferomanceeval( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return quality assurance performance evaluation data - aggregated by by Monitoring agency (MA) for a parameter code aggregated by matching input @@ -676,10 +675,10 @@ def qa_annualperformanceevaltransaction( bdate: date, edate: date, MA_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, + cbdate: date | None = None, + cedate: date | None = None, return_header: bool = False, -) -> Union[DataFrame, AQSAPI_V2]: +) -> AQSAPI_V2 | DataFrame: """ Return AQS submissions transaction format (RD) of the annual performance evaluation data (raw). Includes data pairs for QA - aggregated by diff --git a/pyaqsapi/bypqao/bypqao.py b/pyaqsapi/bypqao/bypqao.py index 8bb51fd..67cd468 100644 --- a/pyaqsapi/bypqao/bypqao.py +++ b/pyaqsapi/bypqao/bypqao.py @@ -2,7 +2,6 @@ (By Primary Quality Assurance Organization).""" from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -15,10 +14,10 @@ def qa_flowrateaudit( bdate: date, edate: date, pqao_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return Quality assurance flowrate audit data. @@ -98,10 +97,10 @@ def qa_one_point_qc( bdate: date, edate: date, pqao_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return Quality assurance data - collocated assessment raw data aggregated by Primary Quality Assurance Organization (PQAO) code. @@ -180,10 +179,10 @@ def qa_pep_audit( bdate: date, edate: date, pqao_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of Performance Evaluation Program (PEP) audit data aggregated by Primary Quality Assurance Organization (PQAO) code for the @@ -260,10 +259,10 @@ def qa_blanks( bdate: date, edate: date, pqao_code: date, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of blank quality assurance data. Blanks are unexposed sample collection devices (e.g., filters) that are transported with the @@ -342,10 +341,10 @@ def qa_collocated_assessments( bdate: date, edate: date, pqao_code: date, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of blank quality assurance data. Blanks are unexposed sample collection devices (e.g., filters) that are transported with the @@ -429,10 +428,10 @@ def qa_flowrateverification( bdate: date, edate: date, pqao_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table containing flow rate Verification data for a parameter code aggregated by matching input parameter, and Primary Quality Assurance @@ -514,10 +513,10 @@ def qa_annualperformanceeval( bdate: date, edate: date, pqao_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return quality assurance performance evaluation data - aggregated by Primary Quality Assurance Organization (PQAO) for a parameter @@ -601,10 +600,10 @@ def qa_annualperformanceevaltransaction( bdate: date, edate: date, pqao_code: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return AQS submissions transaction format (RD) of the annual performance evaluation data (raw). Includes data pairs for diff --git a/pyaqsapi/bysite/bysite.py b/pyaqsapi/bysite/bysite.py index 8f651e3..ef36378 100644 --- a/pyaqsapi/bysite/bysite.py +++ b/pyaqsapi/bysite/bysite.py @@ -1,7 +1,6 @@ """pyaqsapi Functions that aggregate data by site.""" from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -16,10 +15,10 @@ def monitors( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of monitors. @@ -124,10 +123,10 @@ def qa_flowrateaudit( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return Quality assurance flowrate audit data. @@ -239,10 +238,10 @@ def qa_one_point_qc( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of one point QC raw data aggregated by parameter code, stateFIPS, countycode and site number. @@ -350,11 +349,11 @@ def sampledata( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - duration: Optional[str] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + duration: str | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return sample data where the data is aggregated at the site level. @@ -472,10 +471,10 @@ def annualsummary( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of annual data aggregated at the site level. @@ -590,10 +589,10 @@ def qa_blanks( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of blank quality assurance data. Blanks are unexposed sample collection devices (e.g., @@ -705,10 +704,10 @@ def dailysummary( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> DataFrame | AQSAPI_V2: """ Return a DataFrame of data aggregated at the site level. @@ -820,10 +819,10 @@ def qa_collocated_assessments( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of collocated assessment data aggregated by matching input parameter, stateFIPS, county_code, and sitenum provided for @@ -935,10 +934,10 @@ def qa_flowrateverification( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of containing flow rate verification data aggregated by matching input parameter, stateFIPS, county_code, and sitenum provided for @@ -1048,10 +1047,10 @@ def transactionsample( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of Returns transactionsample data aggregated by site in the AQS Submission Transaction Format (RD) sample (raw) data aggregated @@ -1162,10 +1161,10 @@ def qa_annualpeferomanceeval( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return quality assurance performance evaluation data - aggregated by site for a parameter code aggregated by matching input @@ -1277,10 +1276,10 @@ def qa_annualperformanceevaltransaction( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return AQS submissions transaction format (RD) of the annual performance evaluation data (raw). Includes data pairs for @@ -1394,10 +1393,10 @@ def quarterlysummary( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of quarterly data aggregated at the site level. @@ -1511,10 +1510,10 @@ def qa_pep_audit( stateFIPS: str, countycode: str, sitenum: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of Performance Evaluation Program (PEP) audit data aggregated by parameter code, stateFIPS, countycode and diff --git a/pyaqsapi/bystate/bystate.py b/pyaqsapi/bystate/bystate.py index b78d3c6..4e758a7 100644 --- a/pyaqsapi/bystate/bystate.py +++ b/pyaqsapi/bystate/bystate.py @@ -1,7 +1,6 @@ """Functions that aggregated data by state.""" from datetime import date -from typing import Optional, Union from pandas import DataFrame @@ -14,10 +13,10 @@ def monitors( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of monitors. @@ -96,10 +95,10 @@ def qa_flowrateaudit( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return Quality assurance flowrate audit data. @@ -182,10 +181,10 @@ def qa_one_point_qc( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame or an AQS_Data Mart_APIv2 S3 object containing Quality assurance data - flow rate audit raw data aggregated by state FIPS for @@ -263,10 +262,10 @@ def qa_pep_audit( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of Performance Evaluation Program (PEP) audit data aggregated by parameter code, and stateFIPS for the time frame between @@ -343,11 +342,11 @@ def sampledata( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - duration: Optional[Union[None, str]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + duration: str | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return sample data where the data is aggregated at the state level. @@ -433,10 +432,10 @@ def annualsummary( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of annual data aggregated at the state level. @@ -516,10 +515,10 @@ def qa_blanks( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of blank quality assurance data. Blanks are unexposed sample collection devices (e.g., filters) that are transported with the @@ -600,10 +599,10 @@ def dailysummary( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of data aggregated at the state level. @@ -683,10 +682,10 @@ def qa_collocated_assessments( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of collocated assessment data aggregated by matching input parameter and stateFIPS provided for bdate - edate time frame. @@ -767,10 +766,10 @@ def qa_flowrateverification( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table containing flow rate Verification data for a parameter code aggregated matching input parameter, and stateFIPS, provided for @@ -852,10 +851,10 @@ def transactionsample( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return transactionsample data - aggregated by state in the AQS Submission Transaction Format (RD) sample (raw) data for a parameter code aggregated @@ -939,10 +938,10 @@ def qa_annualperformanceeval( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return quality assurance performance evaluation data - aggregated by site for a parameter code aggregated by matching input @@ -1026,10 +1025,10 @@ def qa_annualperformanceevaltransaction( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return AQS submissions transaction format (RD) of the annual performance evaluation data (raw). Includes data pairs for @@ -1115,10 +1114,10 @@ def quarterlysummary( bdate: date, edate: date, stateFIPS: str, - cbdate: Optional[Union[None, date]] = None, - cedate: Optional[Union[None, date]] = None, - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + cbdate: date | None = None, + cedate: date | None = None, + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of quarterly data aggregated at the state level. diff --git a/pyaqsapi/helperfunctions.py b/pyaqsapi/helperfunctions.py index f033be0..e30a70b 100644 --- a/pyaqsapi/helperfunctions.py +++ b/pyaqsapi/helperfunctions.py @@ -9,10 +9,8 @@ Iterable, List, NewType, - Optional, Sized, TypeVar, - Union, cast, no_type_check, ) @@ -22,8 +20,8 @@ from pandas import DataFrame, concat from requests import get -AQS_user: Union[None, str] = None -AQS_key: Union[None, str] = None +AQS_user: str | None = None +AQS_key: str | None = None class AQSAPI_V2: @@ -68,9 +66,9 @@ def __init__(self) -> None: """Initiate the AQSAPI_V2 instance.""" self._header: DataFrame = DataFrame() self._data: DataFrame = DataFrame() - self._request_time: Union[None, str] = None - self._rows: Union[None, str] = None - self._url: Union[None, str] = None + self._request_time: str | None = None + self._rows: str | None = None + self._url: str | None = None def set_header(self, Header: DataFrame) -> None: """ @@ -223,13 +221,13 @@ def __aqs_ratelimit(self, waittime: int = 5) -> None: @no_type_check def __aqs( self, - service: Union[None, str] = None, - aqsfilter: Union[None, str] = None, - variables: Optional[dict[Union[None, str], Union[None, str, date]]] = None, - AQS_user: Union[None, str] = None, - key: Union[None, str] = None, - AQS_domain: Optional[str] = "https://aqs.epa.gov/data/api/", - ) -> Union[DataFrame, None]: + service: str | None = None, + aqsfilter: str | None = None, + variables: dict[str | None] | None | str | date = None, + AQS_user: str | None = None, + key: str | None = None, + AQS_domain: str | None = "https://aqs.epa.gov/data/api/", + ) -> DataFrame | None: """ Send AQS request to the AQS API and returns the result. @@ -317,10 +315,10 @@ def _aqs_services_by_site( countycode: str, sitenum: str, service: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ This is a helper function and should not be called by the end user. @@ -412,10 +410,10 @@ def _aqs_services_by_county( stateFIPS: str, countycode: str, service: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ This is a helper function and should not be called by the end user. @@ -502,10 +500,10 @@ def _aqs_services_by_state( edate: date, stateFIPS: str, service: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -590,10 +588,10 @@ def _aqs_services_by_box( minlon: str, maxlon: str, service: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -689,10 +687,10 @@ def _aqs_services_by_cbsa( edate: date, cbsa_code: str, service: str, - duration: Optional[str] = None, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + duration: str | None = None, + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -772,9 +770,9 @@ def _aqs_services_by_pqao( edate: date, pqao_code: str, service: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -852,9 +850,9 @@ def _aqs_services_by_MA( edate: date, MA_code: str, service: str, - cbdate: Optional[date] = None, - cedate: Optional[date] = None, - ) -> Union[DataFrame, None]: + cbdate: date | None = None, + cedate: date | None = None, + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -919,13 +917,13 @@ def _aqs_services_by_MA( def _aqs_list_services( self, aqsfilter: str, - countycode: Optional[date] = None, - stateFIPS: Optional[str] = None, - cbsa_code: Optional[str] = None, - MA_code: Optional[str] = None, - pqao_code: Optional[str] = None, - parameterclass: Optional[str] = None, - ) -> Union[DataFrame, None]: + countycode: date | None = None, + stateFIPS: str | None = None, + cbsa_code: str | None = None, + MA_code: str | None = None, + pqao_code: str | None = None, + parameterclass: str | None = None, + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -989,8 +987,8 @@ def _aqs_list_services( ) def _aqs_metadata_services( - self, aqsfilter: Optional[str] = None, service: Optional[str] = None - ) -> Union[DataFrame, None]: + self, aqsfilter: str | None = None, service: str | None = None + ) -> DataFrame | None: """ A helper function and should not be called by the end user. @@ -1060,9 +1058,7 @@ def _renameaqsvariables(self, name1: str, name2: str) -> DataFrame: ) -def aqs_credentials( - username: Union[None, str] = None, key: Union[None, str] = None -) -> None: +def aqs_credentials(username: str | None = None, key: str | None = None) -> None: """ Set the user credentials for the AQS API. This function needs to be called once and only once every time this library @@ -1093,8 +1089,7 @@ def aqs_credentials( def aqs_removeheader( aqsobject: list[AQSAPI_V2], - # aqsobject: Union[Sized, list[DataFrame], list[AQSAPI_V2], DataFrame, AQSAPI_V2] -) -> Union[DataFrame, AQSAPI_V2]: +) -> DataFrame | AQSAPI_V2: """ Coerces a single AQS_Data_Mart_APIv2 instance or a list of AQS_Data_Mart_APIv2 instance into a single DataFrame object. @@ -1130,7 +1125,7 @@ def _aqsmultiyearcall( # name1: None | str, # name2: None | str, **kwargs: Any, -) -> Optional[list[DataFrame]]: +) -> list[DataFrame] | None: """ A helper function not to be used by end users. Used to perform multiple calls to the API on API calls which only allow a single year of data to @@ -1286,4 +1281,4 @@ def _aqsmultiyearcall( elif fun == "_aqs_services_by_box": return list(starmap(aqsresult._aqs_services_by_box, params)) # type: ignore else: - pass + return None diff --git a/pyaqsapi/listfunctions.py b/pyaqsapi/listfunctions.py index 4b3f650..0988f8e 100644 --- a/pyaqsapi/listfunctions.py +++ b/pyaqsapi/listfunctions.py @@ -1,7 +1,5 @@ """listfunctions.""" -from typing import Optional, Union - from pandas import DataFrame import pyaqsapi.helperfunctions as helperfunctions @@ -10,8 +8,8 @@ def aqs_isavailable( - return_header: Optional[bool] = False, -) -> Union[AQSAPI_V2, DataFrame]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table explaining the status of the AQS API. @@ -41,8 +39,8 @@ def aqs_isavailable( def aqs_knownissues( - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of any known issues with system functionality or the data. These are usually issues that have been identified internally and will @@ -78,8 +76,8 @@ def aqs_knownissues( def aqs_counties_by_state( - stateFIPS: str, return_header: Optional[bool] = False -) -> Union[DataFrame, AQSAPI_V2]: + stateFIPS: str, return_header: bool | None = False +) -> AQSAPI_V2 | DataFrame: """ Return a table of all counties in within the stateFIPS provided. @@ -114,8 +112,8 @@ def aqs_counties_by_state( def aqs_sites_by_county( - stateFIPS: str, countycode: str, return_header: Optional[bool] = False -) -> Union[DataFrame, AQSAPI_V2]: + stateFIPS: str, countycode: str, return_header: bool | None = False +) -> AQSAPI_V2 | DataFrame: """ Return data containing a table of all air monitoring sites with the input state and county FIPS code combination. @@ -156,7 +154,7 @@ def aqs_sites_by_county( return aqsresult.get_data() -def aqs_classes(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_V2]: +def aqs_classes(return_header: bool | None = False) -> AQSAPI_V2 | DataFrame: """ Return a table of Parameter classes (groups of parameters, i.e. "criteria" or "all"). The information from this function can be used as input to other @@ -190,8 +188,8 @@ def aqs_classes(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAP def aqs_parameters_by_class( - parameterclass: str, return_header: Optional[bool] = False -) -> Union[DataFrame, AQSAPI_V2]: + parameterclass: str, return_header: bool | None = False +) -> AQSAPI_V2 | DataFrame: """ Return a table of Parameter classes (groups of parameters, i.e. "criteria" or "all"). The information from this function can be used as input to other @@ -230,7 +228,7 @@ def aqs_parameters_by_class( return aqsresult.get_data() -def aqs_mas(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_V2]: +def aqs_mas(return_header: bool | None = False) -> AQSAPI_V2 | DataFrame: """ Return a DataFrame of monitoring agencies (MA). @@ -260,7 +258,7 @@ def aqs_mas(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_V2 return aqsresult.get_data() -def aqs_pqaos(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_V2]: +def aqs_pqaos(return_header: bool | None = False) -> AQSAPI_V2 | DataFrame: """ Return a table of primary quality assurance organizations (pqaos). @@ -289,7 +287,7 @@ def aqs_pqaos(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_ return aqsresult.get_data() -def aqs_cbsas(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_V2]: +def aqs_cbsas(return_header: bool | None = False) -> AQSAPI_V2 | DataFrame: """ Return a table of all Core Based Statistical Areas (cbsa) and their associated cbsa_codes. @@ -320,7 +318,7 @@ def aqs_cbsas(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_ return aqsresult.get_data() -def aqs_states(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI_V2]: +def aqs_states(return_header: bool | None = False) -> AQSAPI_V2 | DataFrame: """ Return a table of US states, US territories, and the district or Columbia with their respective FIPS codes. @@ -351,8 +349,8 @@ def aqs_states(return_header: Optional[bool] = False) -> Union[DataFrame, AQSAPI def aqs_revisionhistory( - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table Returns that contains change history to the AQS Data Mart API. @@ -384,8 +382,8 @@ def aqs_revisionhistory( def aqs_fields_by_service( - service: str, return_header: Optional[bool] = False -) -> Union[DataFrame, AQSAPI_V2]: + service: str, return_header: bool | None = False +) -> AQSAPI_V2 | DataFrame: """ Return a table containing the list and definitions of fields in the service requested. @@ -420,8 +418,8 @@ def aqs_fields_by_service( def aqs_sampledurations( - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of sample durations and their associated duration codes. Returned values are not calculated durations such as 8 hour carbon monoxide diff --git a/pyaqsapi/metadatafunctions.py b/pyaqsapi/metadatafunctions.py index 9b0d5b9..081d261 100644 --- a/pyaqsapi/metadatafunctions.py +++ b/pyaqsapi/metadatafunctions.py @@ -1,7 +1,5 @@ """metadatafunctions.""" -from typing import Optional, Union - from pandas import DataFrame from pyaqsapi import helperfunctions @@ -9,8 +7,8 @@ def aqs_is_available( - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return the status of the AQS API. @@ -37,8 +35,8 @@ def aqs_is_available( def aqs_knownissues( - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return a table of any known issues with system functionality or the data. These are usually issues that have been identified internally and will @@ -68,8 +66,8 @@ def aqs_knownissues( def aqs_revisionhistory( - return_header: Optional[bool] = False, -) -> Union[DataFrame, AQSAPI_V2]: + return_header: bool | None = False, +) -> AQSAPI_V2 | DataFrame: """ Return the change history to the AQS Data Mart API. diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..18afeff --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,3 @@ +{ + "reportMissingTypeStubs": true +} \ No newline at end of file diff --git a/setup.py b/setup.py index 02e75f1..1b1d1ca 100644 --- a/setup.py +++ b/setup.py @@ -36,4 +36,5 @@ def readme(): ], packages=find_packages(exclude=["*.egg-info", "build", "dev"]), python_requires=">=3.8", + package_data={"pyaqsapi": ["py.typed"]}, )