Skip to content

Commit 854012c

Browse files
authored
TYP: simple return types from ruff (#56568)
1 parent 87a9c55 commit 854012c

19 files changed

+80
-80
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ repos:
3232
# TODO: remove autofixe-only rules when they are checked by ruff
3333
name: ruff-selected-autofixes
3434
alias: ruff-selected-autofixes
35-
args: [--select, "ANN001,ANN204", --fix-only, --exit-non-zero-on-fix]
35+
args: [--select, "ANN001,ANN2", --fix-only, --exit-non-zero-on-fix]
3636
- repo: https://github.com/jendrikseipp/vulture
3737
rev: 'v2.10'
3838
hooks:

doc/make.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _process_single_doc(self, single_doc):
102102
)
103103

104104
@staticmethod
105-
def _run_os(*args):
105+
def _run_os(*args) -> None:
106106
"""
107107
Execute a command as a OS terminal.
108108
@@ -149,7 +149,7 @@ def _sphinx_build(self, kind: str):
149149
]
150150
return subprocess.call(cmd)
151151

152-
def _open_browser(self, single_doc_html):
152+
def _open_browser(self, single_doc_html) -> None:
153153
"""
154154
Open a browser tab showing single
155155
"""
@@ -183,7 +183,7 @@ def _get_page_title(self, page):
183183

184184
return title.astext()
185185

186-
def _add_redirects(self):
186+
def _add_redirects(self) -> None:
187187
"""
188188
Create in the build directory an html file with a redirect,
189189
for every row in REDIRECTS_FILE.
@@ -272,14 +272,14 @@ def latex_forced(self):
272272
return self.latex(force=True)
273273

274274
@staticmethod
275-
def clean():
275+
def clean() -> None:
276276
"""
277277
Clean documentation generated files.
278278
"""
279279
shutil.rmtree(BUILD_PATH, ignore_errors=True)
280280
shutil.rmtree(os.path.join(SOURCE_PATH, "reference", "api"), ignore_errors=True)
281281

282-
def zip_html(self):
282+
def zip_html(self) -> None:
283283
"""
284284
Compress HTML documentation into a zip file.
285285
"""

doc/scripts/eval_performance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def bench(mn=3, mx=7, num=100, engines=("python", "numexpr"), verbose=False):
6464
return ev, qu
6565

6666

67-
def plot_perf(df, engines, title, filename=None):
67+
def plot_perf(df, engines, title, filename=None) -> None:
6868
from matplotlib.pyplot import figure
6969

7070
sns.set()

doc/source/conf.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ class AccessorDocumenter(MethodDocumenter):
502502
# lower than MethodDocumenter so this is not chosen for normal methods
503503
priority = 0.6
504504

505-
def format_signature(self):
505+
def format_signature(self) -> str:
506506
# this method gives an error/warning for the accessors, therefore
507507
# overriding it (accessor has no arguments)
508508
return ""
@@ -632,7 +632,7 @@ def get_items(self, names):
632632

633633

634634
# based on numpy doc/source/conf.py
635-
def linkcode_resolve(domain, info):
635+
def linkcode_resolve(domain, info) -> str | None:
636636
"""
637637
Determine the URL corresponding to Python object
638638
"""
@@ -694,12 +694,12 @@ def linkcode_resolve(domain, info):
694694

695695
# remove the docstring of the flags attribute (inherited from numpy ndarray)
696696
# because these give doc build errors (see GH issue 5331)
697-
def remove_flags_docstring(app, what, name, obj, options, lines):
697+
def remove_flags_docstring(app, what, name, obj, options, lines) -> None:
698698
if what == "attribute" and name.endswith(".flags"):
699699
del lines[:]
700700

701701

702-
def process_class_docstrings(app, what, name, obj, options, lines):
702+
def process_class_docstrings(app, what, name, obj, options, lines) -> None:
703703
"""
704704
For those classes for which we use ::
705705
@@ -751,7 +751,7 @@ def process_class_docstrings(app, what, name, obj, options, lines):
751751
]
752752

753753

754-
def process_business_alias_docstrings(app, what, name, obj, options, lines):
754+
def process_business_alias_docstrings(app, what, name, obj, options, lines) -> None:
755755
"""
756756
Starting with sphinx 3.4, the "autodoc-process-docstring" event also
757757
gets called for alias classes. This results in numpydoc adding the
@@ -774,7 +774,7 @@ def process_business_alias_docstrings(app, what, name, obj, options, lines):
774774
suppress_warnings.append("ref.ref")
775775

776776

777-
def rstjinja(app, docname, source):
777+
def rstjinja(app, docname, source) -> None:
778778
"""
779779
Render our pages as a jinja template for fancy templating goodness.
780780
"""
@@ -787,7 +787,7 @@ def rstjinja(app, docname, source):
787787
source[0] = rendered
788788

789789

790-
def setup(app):
790+
def setup(app) -> None:
791791
app.connect("source-read", rstjinja)
792792
app.connect("autodoc-process-docstring", remove_flags_docstring)
793793
app.connect("autodoc-process-docstring", process_class_docstrings)

generate_pxi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from Cython import Tempita
55

66

7-
def process_tempita(pxifile, outfile):
7+
def process_tempita(pxifile, outfile) -> None:
88
with open(pxifile, encoding="utf-8") as f:
99
tmpl = f.read()
1010
pyxcontent = Tempita.sub(tmpl)
@@ -13,7 +13,7 @@ def process_tempita(pxifile, outfile):
1313
f.write(pyxcontent)
1414

1515

16-
def main():
16+
def main() -> None:
1717
parser = argparse.ArgumentParser()
1818
parser.add_argument("infile", type=str, help="Path to the input file")
1919
parser.add_argument("-o", "--outdir", type=str, help="Path to the output directory")

generate_version.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
sys.path.insert(0, "")
1111

1212

13-
def write_version_info(path):
13+
def write_version_info(path) -> None:
1414
version = None
1515
git_version = None
1616

@@ -29,7 +29,7 @@ def write_version_info(path):
2929
file.write(f'__git_version__="{git_version}"\n')
3030

3131

32-
def main():
32+
def main() -> None:
3333
parser = argparse.ArgumentParser()
3434
parser.add_argument(
3535
"-o",

scripts/tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pyproject.toml defines addopts: --strict-data-files
22
# strict-data-files is defined & used in pandas/conftest.py
3-
def pytest_addoption(parser):
3+
def pytest_addoption(parser) -> None:
44
parser.addoption(
55
"--strict-data-files",
66
action="store_true",

scripts/tests/test_no_bool_in_generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
GOOD_FILE = "def foo(a: bool_t) -> bool_t:\n return bool(0)\n"
55

66

7-
def test_bad_file_with_replace():
7+
def test_bad_file_with_replace() -> None:
88
content = BAD_FILE
99
mutated, result = check_for_bool_in_generic(content)
1010
expected = GOOD_FILE
1111
assert result == expected
1212
assert mutated
1313

1414

15-
def test_good_file_with_replace():
15+
def test_good_file_with_replace() -> None:
1616
content = GOOD_FILE
1717
mutated, result = check_for_bool_in_generic(content)
1818
expected = content

scripts/tests/test_sort_whatsnew_note.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from scripts.sort_whatsnew_note import sort_whatsnew_note
22

33

4-
def test_sort_whatsnew_note():
4+
def test_sort_whatsnew_note() -> None:
55
content = (
66
".. _whatsnew_200:\n"
77
"\n"

scripts/tests/test_use_io_common_urlopen.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
PATH = "t.py"
66

77

8-
def test_inconsistent_usage(capsys):
8+
def test_inconsistent_usage(capsys) -> None:
99
content = "from urllib.request import urlopen"
1010
result_msg = (
1111
"t.py:1:0: Don't use urllib.request.urlopen, "
@@ -17,7 +17,7 @@ def test_inconsistent_usage(capsys):
1717
assert result_msg == expected_msg
1818

1919

20-
def test_consistent_usage():
20+
def test_consistent_usage() -> None:
2121
# should not raise
2222
content = "from pandas.io.common import urlopen"
2323
use_io_common_urlopen(content, PATH)

scripts/tests/test_use_pd_array_in_core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
@pytest.mark.parametrize("content", [BAD_FILE_0, BAD_FILE_1])
13-
def test_inconsistent_usage(content, capsys):
13+
def test_inconsistent_usage(content, capsys) -> None:
1414
result_msg = (
1515
"t.py:2:0: Don't use pd.array in core, import array as pd_array instead\n"
1616
)
@@ -21,6 +21,6 @@ def test_inconsistent_usage(content, capsys):
2121

2222

2323
@pytest.mark.parametrize("content", [GOOD_FILE_0, GOOD_FILE_1])
24-
def test_consistent_usage(content):
24+
def test_consistent_usage(content) -> None:
2525
# should not raise
2626
use_pd_array(content, PATH)

0 commit comments

Comments
 (0)