Skip to content

Commit 5511ced

Browse files
committed
refactor: return None by ruff
1 parent 7a711da commit 5511ced

File tree

8 files changed

+43
-49
lines changed

8 files changed

+43
-49
lines changed

scripts/_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Step:
1414
rollback: Callable[[], None] | None = None
1515

1616

17-
def __rollback_job(steps: deque[Step]):
17+
def __rollback_job(steps: deque[Step]) -> None:
1818
"""
1919
Responsible to run rollback of steps.
2020
"""

scripts/test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test(
2525
src: bool = False,
2626
dist: bool = False,
2727
type_checker: Literal["", "mypy", "pyright"] = "",
28-
):
28+
) -> None:
2929
steps = []
3030
if src:
3131
steps.extend(_SRC_STEPS)

scripts/test/run.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@
55
import sys
66

77

8-
def mypy_src():
8+
def mypy_src() -> None:
99
cmd = ["mypy", "pandas-stubs", "tests", "--no-incremental"]
1010
subprocess.run(cmd, check=True)
1111

1212

13-
def pyright_src():
13+
def pyright_src() -> None:
1414
cmd = ["pyright"]
1515
subprocess.run(cmd, check=True)
1616

1717

18-
def pyright_src_strict():
18+
def pyright_src_strict() -> None:
1919
cmd = ["pyright", "--project", "pyrightconfig-strict.json"]
2020
subprocess.run(cmd, check=True)
2121

2222

23-
def pytest():
23+
def pytest() -> None:
2424
cmd = ["pytest", "--cache-clear"]
2525
subprocess.run(cmd, check=True)
2626

2727

28-
def style():
28+
def style() -> None:
2929
cmd = ["pre-commit", "run", "--all-files", "--verbose"]
3030
subprocess.run(cmd, check=True)
3131

3232

33-
def stubtest(allowlist: str = "", check_missing: bool = False):
33+
def stubtest(allowlist: str = "", check_missing: bool = False) -> None:
3434
cmd = [
3535
sys.executable,
3636
"-m",
@@ -47,47 +47,47 @@ def stubtest(allowlist: str = "", check_missing: bool = False):
4747
subprocess.run(cmd, check=True)
4848

4949

50-
def build_dist():
50+
def build_dist() -> None:
5151
cmd = ["poetry", "build", "-f", "wheel"]
5252
subprocess.run(cmd, check=True)
5353

5454

55-
def install_dist():
55+
def install_dist() -> None:
5656
path = sorted(Path("dist/").glob("pandas_stubs-*.whl"))[-1]
5757
cmd = [sys.executable, "-m", "pip", "install", "--force-reinstall", str(path)]
5858
subprocess.run(cmd, check=True)
5959

6060

61-
def rename_src():
61+
def rename_src() -> None:
6262
if Path(r"pandas-stubs").exists():
6363
Path(r"pandas-stubs").rename("_pandas-stubs")
6464
else:
6565
raise FileNotFoundError("'pandas-stubs' folder does not exists.")
6666

6767

68-
def mypy_dist():
68+
def mypy_dist() -> None:
6969
cmd = ["mypy", "tests", "--no-incremental"]
7070
subprocess.run(cmd, check=True)
7171

7272

73-
def pyright_dist():
73+
def pyright_dist() -> None:
7474
cmd = ["pyright", "tests"]
7575
subprocess.run(cmd, check=True)
7676

7777

78-
def uninstall_dist():
78+
def uninstall_dist() -> None:
7979
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas-stubs"]
8080
subprocess.run(cmd, check=True)
8181

8282

83-
def restore_src():
83+
def restore_src() -> None:
8484
if Path(r"_pandas-stubs").exists():
8585
Path(r"_pandas-stubs").rename("pandas-stubs")
8686
else:
8787
raise FileNotFoundError("'_pandas-stubs' folder does not exists.")
8888

8989

90-
def nightly_pandas():
90+
def nightly_pandas() -> None:
9191
cmd = [
9292
sys.executable,
9393
"-m",
@@ -110,13 +110,13 @@ def _get_version_from_pyproject(program: str) -> str:
110110
return version_line.split('"')[1]
111111

112112

113-
def released_pandas():
113+
def released_pandas() -> None:
114114
version = _get_version_from_pyproject("pandas")
115115
cmd = [sys.executable, "-m", "pip", "install", f"pandas=={version}"]
116116
subprocess.run(cmd, check=True)
117117

118118

119-
def nightly_mypy():
119+
def nightly_mypy() -> None:
120120
cmd = [
121121
sys.executable,
122122
"-m",
@@ -138,7 +138,7 @@ def nightly_mypy():
138138
)
139139

140140

141-
def released_mypy():
141+
def released_mypy() -> None:
142142
version = _get_version_from_pyproject("mypy")
143143
cmd = [sys.executable, "-m", "pip", "install", f"mypy=={version}"]
144144
subprocess.run(cmd, check=True)
@@ -152,7 +152,7 @@ def released_mypy():
152152
)
153153

154154

155-
def ty():
155+
def ty() -> None:
156156
cmd = [
157157
"ty",
158158
"check",
@@ -163,6 +163,6 @@ def ty():
163163
subprocess.run(cmd, check=True)
164164

165165

166-
def pyrefly():
166+
def pyrefly() -> None:
167167
cmd = ["pyrefly", "check", "pandas-stubs"]
168168
subprocess.run(cmd, check=True)

tests/series/test_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3549,7 +3549,7 @@ def test_diff() -> None:
35493549
# str -> TypeError: unsupported operand type(s) for -: 'str' and 'str'
35503550
pd.Series(["a", "b"]).diff() # type: ignore[misc] # pyright: ignore[reportAttributeAccessIssue]
35513551

3552-
def _diff_invalid0(): # pyright: ignore[reportUnusedFunction]
3552+
def _diff_invalid0() -> None: # pyright: ignore[reportUnusedFunction]
35533553
# interval -> TypeError: IntervalArray has no 'diff' method. Convert to a suitable dtype prior to calling 'diff'.
35543554
assert_type(pd.Series([pd.Interval(0, 2), pd.Interval(1, 4)]).diff(), Never)
35553555

tests/test_api_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def test_union_categoricals() -> None:
373373

374374
def test_check_extension_dtypes() -> None:
375375
# GH 315
376-
def check_ext_dtype(etype: type[ExtensionDtype]):
376+
def check_ext_dtype(etype: type[ExtensionDtype]) -> None:
377377
assert issubclass(etype, ExtensionDtype)
378378

379379
check_ext_dtype(pd.Int64Dtype)

tests/test_api_typing.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_dataframegroupby() -> None:
4646
df = pd.DataFrame({"a": [1, 2, 3]})
4747
group = df.groupby("a")
4848

49-
def f1(gb: DataFrameGroupBy):
49+
def f1(gb: DataFrameGroupBy) -> None:
5050
check(gb, DataFrameGroupBy)
5151

5252
f1(group)
@@ -55,7 +55,7 @@ def f1(gb: DataFrameGroupBy):
5555
def test_seriesgroupby() -> None:
5656
sr = pd.Series([1, 2, 3], index=pd.Index(["a", "b", "a"]))
5757

58-
def f1(gb: SeriesGroupBy):
58+
def f1(gb: SeriesGroupBy) -> None:
5959
check(gb, SeriesGroupBy)
6060

6161
f1(sr.groupby(level=0))
@@ -68,7 +68,7 @@ def tests_datetimeindexersamplergroupby() -> None:
6868
)
6969
gb_df = df.groupby("col2")
7070

71-
def f1(gb: ResamplerGroupBy):
71+
def f1(gb: ResamplerGroupBy) -> None:
7272
check(gb, DatetimeIndexResamplerGroupby)
7373

7474
f1(gb_df.resample("ME"))
@@ -81,7 +81,7 @@ def test_timedeltaindexresamplergroupby() -> None:
8181
)
8282
gb_df = df.groupby("col2")
8383

84-
def f1(gb: ResamplerGroupBy):
84+
def f1(gb: ResamplerGroupBy) -> None:
8585
check(gb, TimedeltaIndexResamplerGroupby)
8686

8787
f1(gb_df.resample("1D"))
@@ -92,7 +92,7 @@ def test_periodindexresamplergroupby() -> None:
9292
idx = pd.period_range("2020-01-28 09:00", periods=4, freq="D")
9393
df = pd.DataFrame(data=4 * [range(2)], index=idx, columns=["a", "b"])
9494

95-
def f1(gb: ResamplerGroupBy):
95+
def f1(gb: ResamplerGroupBy) -> None:
9696
check(gb, PeriodIndexResamplerGroupby)
9797

9898
f1(df.groupby("a").resample("3min"))
@@ -113,7 +113,7 @@ def test_nattype() -> None:
113113
def test_expanding() -> None:
114114
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
115115

116-
def f1(gb: Expanding):
116+
def f1(gb: Expanding) -> None:
117117
check(gb, Expanding)
118118

119119
f1(df.expanding())
@@ -122,7 +122,7 @@ def f1(gb: Expanding):
122122
def test_expanding_groubpy() -> None:
123123
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
124124

125-
def f1(gb: ExpandingGroupby):
125+
def f1(gb: ExpandingGroupby) -> None:
126126
check(gb, ExpandingGroupby)
127127

128128
f1(df.groupby("B").expanding())
@@ -131,7 +131,7 @@ def f1(gb: ExpandingGroupby):
131131
def test_ewm() -> None:
132132
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
133133

134-
def f1(gb: ExponentialMovingWindow):
134+
def f1(gb: ExponentialMovingWindow) -> None:
135135
check(gb, ExponentialMovingWindow)
136136

137137
f1(df.ewm(2))
@@ -140,7 +140,7 @@ def f1(gb: ExponentialMovingWindow):
140140
def test_ewm_groubpy() -> None:
141141
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
142142

143-
def f1(gb: ExponentialMovingWindowGroupby):
143+
def f1(gb: ExponentialMovingWindowGroupby) -> None:
144144
check(gb, ExponentialMovingWindowGroupby)
145145

146146
f1(df.groupby("B").ewm(2))
@@ -149,7 +149,7 @@ def f1(gb: ExponentialMovingWindowGroupby):
149149
def test_json_reader() -> None:
150150
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
151151

152-
def f1(gb: JsonReader):
152+
def f1(gb: JsonReader) -> None:
153153
check(gb, JsonReader)
154154

155155
with ensure_clean() as path:
@@ -162,7 +162,7 @@ def f1(gb: JsonReader):
162162
def test_resampler() -> None:
163163
s = pd.Series([1, 2, 3, 4, 5], index=pd.date_range("20130101", periods=5, freq="s"))
164164

165-
def f1(gb: Resampler):
165+
def f1(gb: Resampler) -> None:
166166
check(gb, Resampler)
167167

168168
f1(s.resample("3min"))
@@ -171,7 +171,7 @@ def f1(gb: Resampler):
171171
def test_rolling() -> None:
172172
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
173173

174-
def f1(gb: Rolling):
174+
def f1(gb: Rolling) -> None:
175175
check(gb, Rolling)
176176

177177
f1(df.rolling(2))
@@ -180,7 +180,7 @@ def f1(gb: Rolling):
180180
def test_rolling_groupby() -> None:
181181
df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
182182

183-
def f1(gb: RollingGroupby):
183+
def f1(gb: RollingGroupby) -> None:
184184
check(gb, RollingGroupby)
185185

186186
f1(df.groupby("B").rolling(2))
@@ -189,7 +189,7 @@ def f1(gb: RollingGroupby):
189189
def test_timegrouper() -> None:
190190
grouper = pd.Grouper(key="Publish date", freq="1W")
191191

192-
def f1(gb: TimeGrouper):
192+
def f1(gb: TimeGrouper) -> None:
193193
check(gb, TimeGrouper)
194194

195195
f1(grouper)
@@ -198,7 +198,7 @@ def f1(gb: TimeGrouper):
198198
def test_window() -> None:
199199
ser = pd.Series([0, 1, 5, 2, 8])
200200

201-
def f1(gb: Window):
201+
def f1(gb: Window) -> None:
202202
check(gb, Window)
203203

204204
f1(ser.rolling(2, win_type="gaussian"))
@@ -213,7 +213,7 @@ def test_statereader() -> None:
213213
path, time_stamp=time_stamp, variable_labels=variable_labels, version=None
214214
)
215215

216-
def f1(gb: StataReader):
216+
def f1(gb: StataReader) -> None:
217217
check(gb, StataReader)
218218

219219
with StataReader(path) as reader:

tests/test_plotting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727

2828

2929
@pytest.fixture(autouse=True)
30-
def autouse_mpl_cleanup(mpl_cleanup):
30+
def autouse_mpl_cleanup(mpl_cleanup) -> None:
3131
pass
3232

3333

3434
@pytest.fixture
35-
def close_figures():
35+
def close_figures() -> None:
3636
plt.close("all")
3737

3838

tests/test_styler.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141

4242
@pytest.fixture(autouse=True)
43-
def reset_style():
43+
def reset_style() -> None:
4444
DF.style.clear()
4545

4646

@@ -255,10 +255,4 @@ def color_negative(v: Scalar, /, color: str) -> str | None:
255255

256256
df = DataFrame(np.random.randn(5, 2), columns=["A", "B"])
257257

258-
check(
259-
assert_type(
260-
df.style.map(color_negative, color="red"),
261-
Styler,
262-
),
263-
Styler,
264-
)
258+
check(assert_type(df.style.map(color_negative, color="red"), Styler), Styler)

0 commit comments

Comments
 (0)