Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYP: simple return types from ruff #56568

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
# TODO: remove autofixe-only rules when they are checked by ruff
name: ruff-selected-autofixes
alias: ruff-selected-autofixes
args: [--select, "ANN001,ANN204", --fix-only, --exit-non-zero-on-fix]
args: [--select, "ANN001,ANN2", --fix-only, --exit-non-zero-on-fix]
- repo: https://github.com/jendrikseipp/vulture
rev: 'v2.10'
hooks:
Expand Down
10 changes: 5 additions & 5 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _process_single_doc(self, single_doc):
)

@staticmethod
def _run_os(*args):
def _run_os(*args) -> None:
"""
Execute a command as a OS terminal.

Expand Down Expand Up @@ -149,7 +149,7 @@ def _sphinx_build(self, kind: str):
]
return subprocess.call(cmd)

def _open_browser(self, single_doc_html):
def _open_browser(self, single_doc_html) -> None:
"""
Open a browser tab showing single
"""
Expand Down Expand Up @@ -183,7 +183,7 @@ def _get_page_title(self, page):

return title.astext()

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

@staticmethod
def clean():
def clean() -> None:
"""
Clean documentation generated files.
"""
shutil.rmtree(BUILD_PATH, ignore_errors=True)
shutil.rmtree(os.path.join(SOURCE_PATH, "reference", "api"), ignore_errors=True)

def zip_html(self):
def zip_html(self) -> None:
"""
Compress HTML documentation into a zip file.
"""
Expand Down
2 changes: 1 addition & 1 deletion doc/scripts/eval_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def bench(mn=3, mx=7, num=100, engines=("python", "numexpr"), verbose=False):
return ev, qu


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

sns.set()
Expand Down
14 changes: 7 additions & 7 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class AccessorDocumenter(MethodDocumenter):
# lower than MethodDocumenter so this is not chosen for normal methods
priority = 0.6

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


# based on numpy doc/source/conf.py
def linkcode_resolve(domain, info):
def linkcode_resolve(domain, info) -> str | None:
"""
Determine the URL corresponding to Python object
"""
Expand Down Expand Up @@ -694,12 +694,12 @@ def linkcode_resolve(domain, info):

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


def process_class_docstrings(app, what, name, obj, options, lines):
def process_class_docstrings(app, what, name, obj, options, lines) -> None:
"""
For those classes for which we use ::

Expand Down Expand Up @@ -751,7 +751,7 @@ def process_class_docstrings(app, what, name, obj, options, lines):
]


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


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


def setup(app):
def setup(app) -> None:
app.connect("source-read", rstjinja)
app.connect("autodoc-process-docstring", remove_flags_docstring)
app.connect("autodoc-process-docstring", process_class_docstrings)
Expand Down
4 changes: 2 additions & 2 deletions generate_pxi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from Cython import Tempita


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


def main():
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("infile", type=str, help="Path to the input file")
parser.add_argument("-o", "--outdir", type=str, help="Path to the output directory")
Expand Down
4 changes: 2 additions & 2 deletions generate_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sys.path.insert(0, "")


def write_version_info(path):
def write_version_info(path) -> None:
version = None
git_version = None

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


def main():
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"-o",
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pyproject.toml defines addopts: --strict-data-files
# strict-data-files is defined & used in pandas/conftest.py
def pytest_addoption(parser):
def pytest_addoption(parser) -> None:
parser.addoption(
"--strict-data-files",
action="store_true",
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/test_no_bool_in_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
GOOD_FILE = "def foo(a: bool_t) -> bool_t:\n return bool(0)\n"


def test_bad_file_with_replace():
def test_bad_file_with_replace() -> None:
content = BAD_FILE
mutated, result = check_for_bool_in_generic(content)
expected = GOOD_FILE
assert result == expected
assert mutated


def test_good_file_with_replace():
def test_good_file_with_replace() -> None:
content = GOOD_FILE
mutated, result = check_for_bool_in_generic(content)
expected = content
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/test_sort_whatsnew_note.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from scripts.sort_whatsnew_note import sort_whatsnew_note


def test_sort_whatsnew_note():
def test_sort_whatsnew_note() -> None:
content = (
".. _whatsnew_200:\n"
"\n"
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/test_use_io_common_urlopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
PATH = "t.py"


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


def test_consistent_usage():
def test_consistent_usage() -> None:
# should not raise
content = "from pandas.io.common import urlopen"
use_io_common_urlopen(content, PATH)
4 changes: 2 additions & 2 deletions scripts/tests/test_use_pd_array_in_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


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


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