Skip to content

Commit d3859de

Browse files
committed
Ruff fixes by bot
1 parent 576d214 commit d3859de

17 files changed

Lines changed: 217 additions & 164 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,28 @@ on:
1010
branches: ['main']
1111

1212
jobs:
13+
ruff:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
18+
- name: Set up Python 3.13
19+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
20+
with:
21+
python-version: '3.13'
22+
- name: Install Ruff
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install ruff
26+
- name: Ruff check
27+
run: |
28+
ruff check .
29+
- name: Ruff format check
30+
run: |
31+
ruff format --check .
32+
1333
build:
34+
needs: ruff
1435
runs-on: ${{ matrix.os }}
1536
strategy:
1637
fail-fast: false
@@ -28,12 +49,6 @@ jobs:
2849
run: |
2950
python -m pip install --upgrade pip
3051
pip install .[test,nldi]
31-
- name: Lint with flake8
32-
run: |
33-
# stop the build if there are Python syntax errors or undefined names
34-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3752
- name: Test with pytest and report coverage
3853
run: |
3954
coverage run -m pytest tests/

dataretrieval/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
except PackageNotFoundError:
66
__version__ = "version-unknown"
77

8-
from dataretrieval.nadp import *
9-
from dataretrieval.nwis import *
10-
from dataretrieval.samples import *
11-
from dataretrieval.streamstats import *
12-
from dataretrieval.utils import *
13-
from dataretrieval.waterdata import *
14-
from dataretrieval.waterwatch import *
15-
from dataretrieval.wqp import *
8+
from dataretrieval.nadp import * # noqa: F403
9+
from dataretrieval.nwis import * # noqa: F403
10+
from dataretrieval.samples import * # noqa: F403
11+
from dataretrieval.streamstats import * # noqa: F403
12+
from dataretrieval.utils import * # noqa: F403
13+
from dataretrieval.waterdata import * # noqa: F403
14+
from dataretrieval.waterwatch import * # noqa: F403
15+
from dataretrieval.wqp import * # noqa: F403

dataretrieval/codes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .states import *
2-
from .timezones import *
1+
from .states import * # noqa: F403
2+
from .timezones import * # noqa: F403

dataretrieval/nldi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
try:
77
import geopandas as gpd
8-
except ImportError:
9-
raise ImportError("Install geopandas to use the NLDI module.")
8+
except ImportError as err:
9+
raise ImportError("Install geopandas to use the NLDI module.") from err
1010

1111
NLDI_API_BASE_URL = "https://api.water.usgs.gov/nldi/linked-data"
1212
_AVAILABLE_DATA_SOURCES = None

dataretrieval/nwis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ def get_info(ssl_check: bool = True, **kwargs) -> Tuple[pd.DataFrame, BaseMetada
696696
"refer to https://waterdata.usgs.gov.nwis/qwdata and "
697697
"https://doi-usgs.github.io/dataRetrieval/articles/Status.html "
698698
"or email CompTools@usgs.gov."
699-
)
699+
),
700+
stacklevel=2,
700701
)
701702
# convert bool to string if necessary
702703
kwargs["seriesCatalogOutput"] = "True"

dataretrieval/samples.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ def get_usgs_samples(
213213
"""
214214

215215
warnings.warn(
216-
"`get_usgs_samples` is deprecated and will be removed. Use `waterdata.get_samples` instead.",
216+
(
217+
"`get_usgs_samples` is deprecated and will be removed. "
218+
"Use `waterdata.get_samples` instead."
219+
),
217220
DeprecationWarning,
218221
stacklevel=2,
219222
)

dataretrieval/streamstats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@ def from_streamstats_json(cls, streamstats_json):
158158

159159
def __init__(self, rcode, xlocation, ylocation):
160160
"""Init method that calls the :obj:`from_streamstats_json` method."""
161-
self = get_watershed(rcode, xlocation, ylocation)
161+
get_watershed(rcode, xlocation, ylocation)

dataretrieval/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ def to_str(listlike, delimiter=","):
3939
'0+10+42'
4040
4141
"""
42-
if type(listlike) == list:
42+
if isinstance(listlike, list):
4343
return delimiter.join([str(x) for x in listlike])
4444

45-
elif type(listlike) == pd.core.series.Series:
45+
elif isinstance(listlike, pd.core.series.Series):
4646
return delimiter.join(listlike.tolist())
4747

48-
elif type(listlike) == pd.core.indexes.base.Index:
48+
elif isinstance(listlike, pd.core.indexes.base.Index):
4949
return delimiter.join(listlike.tolist())
5050

51-
elif type(listlike) == str:
51+
elif isinstance(listlike, str):
5252
return listlike
5353

5454

@@ -91,6 +91,7 @@ def format_datetime(df, date_field, time_field, tz_field):
9191
f"Warning: {count} incomplete dates found, "
9292
+ "consider setting datetime_index to False.",
9393
UserWarning,
94+
stacklevel=2,
9495
)
9596

9697
return df

0 commit comments

Comments
 (0)