From d65a3e3ddf0f657d5697dcbad7966debfdef39ea Mon Sep 17 00:00:00 2001 From: Jasmandeep Kaur Date: Mon, 21 Nov 2022 11:29:06 -0800 Subject: [PATCH 1/4] STYLE: fix pylint redefined-outer-name warnings --- pandas/util/_decorators.py | 4 ++-- pandas/util/_doctools.py | 12 ++++++------ pandas/util/_test_decorators.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index 8fef3a231a748..571c065c53351 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -77,7 +77,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: if alternative.__doc__: if alternative.__doc__.count("\n") < 3: raise AssertionError(doc_error_msg) - empty1, summary, empty2, doc = alternative.__doc__.split("\n", 3) + empty1, summary, empty2, doc_string = alternative.__doc__.split("\n", 3) if empty1 or empty2 and not summary: raise AssertionError(doc_error_msg) wrapper.__doc__ = dedent( @@ -87,7 +87,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: .. deprecated:: {version} {msg} - {dedent(doc)}""" + {dedent(doc_string)}""" ) # error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], # Callable[...,Any]]", expected "Callable[[F], F]") diff --git a/pandas/util/_doctools.py b/pandas/util/_doctools.py index dc8a22b1fe0ef..8135b3fc348a6 100644 --- a/pandas/util/_doctools.py +++ b/pandas/util/_doctools.py @@ -168,7 +168,7 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None: if __name__ == "__main__": - import matplotlib.pyplot as plt + import matplotlib.pyplot as pyplot p = TablePlotter() @@ -176,20 +176,20 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None: df2 = pd.DataFrame({"A": [10, 12], "C": [30, 32]}) p.plot([df1, df2], pd.concat([df1, df2]), labels=["df1", "df2"], vertical=True) - plt.show() + pyplot.show() df3 = pd.DataFrame({"X": [10, 12], "Z": [30, 32]}) p.plot( [df1, df3], pd.concat([df1, df3], axis=1), labels=["df1", "df2"], vertical=False ) - plt.show() + pyplot.show() idx = pd.MultiIndex.from_tuples( [(1, "A"), (1, "B"), (1, "C"), (2, "A"), (2, "B"), (2, "C")] ) - col = pd.MultiIndex.from_tuples([(1, "A"), (1, "B")]) + column = pd.MultiIndex.from_tuples([(1, "A"), (1, "B")]) df3 = pd.DataFrame({"v1": [1, 2, 3, 4, 5, 6], "v2": [5, 6, 7, 8, 9, 10]}, index=idx) - df3.columns = col + df3.columns = column p.plot(df3, df3, labels=["df3"]) - plt.show() + pyplot.show() diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index ca856fe2482ca..d54e46038cf67 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -295,11 +295,11 @@ def file_leak_context() -> Generator[None, None, None]: def async_mark(): try: import_optional_dependency("pytest_asyncio") - async_mark = pytest.mark.asyncio + asyncio_mark = pytest.mark.asyncio except ImportError: - async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") + asyncio_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") - return async_mark + return asyncio_mark def mark_array_manager_not_yet_implemented(request) -> None: From f221521a10b98c53c5a0bfdc6e8f8a5968b4ab83 Mon Sep 17 00:00:00 2001 From: Jasmandeep Kaur Date: Mon, 21 Nov 2022 11:40:22 -0800 Subject: [PATCH 2/4] removing _test_decorators.py --- pandas/util/_test_decorators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index d54e46038cf67..ca856fe2482ca 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -295,11 +295,11 @@ def file_leak_context() -> Generator[None, None, None]: def async_mark(): try: import_optional_dependency("pytest_asyncio") - asyncio_mark = pytest.mark.asyncio + async_mark = pytest.mark.asyncio except ImportError: - asyncio_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") + async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio") - return asyncio_mark + return async_mark def mark_array_manager_not_yet_implemented(request) -> None: From 7768dd782127f77d5ceea1d8bdd3b3ef42c1d2dd Mon Sep 17 00:00:00 2001 From: Jasmandeep Kaur Date: Mon, 21 Nov 2022 11:55:55 -0800 Subject: [PATCH 3/4] Moving into a main function --- pandas/util/_doctools.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pandas/util/_doctools.py b/pandas/util/_doctools.py index 8135b3fc348a6..ea2564546b52f 100644 --- a/pandas/util/_doctools.py +++ b/pandas/util/_doctools.py @@ -166,9 +166,8 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None: ax.set_title(title, size=self.font_size) ax.axis("off") - -if __name__ == "__main__": - import matplotlib.pyplot as pyplot +def main(): + import matplotlib.pyplot as plt p = TablePlotter() @@ -176,14 +175,14 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None: df2 = pd.DataFrame({"A": [10, 12], "C": [30, 32]}) p.plot([df1, df2], pd.concat([df1, df2]), labels=["df1", "df2"], vertical=True) - pyplot.show() + plt.show() df3 = pd.DataFrame({"X": [10, 12], "Z": [30, 32]}) p.plot( [df1, df3], pd.concat([df1, df3], axis=1), labels=["df1", "df2"], vertical=False ) - pyplot.show() + plt.show() idx = pd.MultiIndex.from_tuples( [(1, "A"), (1, "B"), (1, "C"), (2, "A"), (2, "B"), (2, "C")] @@ -192,4 +191,7 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None: df3 = pd.DataFrame({"v1": [1, 2, 3, 4, 5, 6], "v2": [5, 6, 7, 8, 9, 10]}, index=idx) df3.columns = column p.plot(df3, df3, labels=["df3"]) - pyplot.show() + plt.show() + +if __name__ == "__main__": + main() From 4944247cf4d7dc7f496dac6ef3dd3ba979c0ba9a Mon Sep 17 00:00:00 2001 From: Jasmandeep Kaur Date: Mon, 21 Nov 2022 22:27:06 -0800 Subject: [PATCH 4/4] pre-commit changes --- pandas/util/_doctools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/util/_doctools.py b/pandas/util/_doctools.py index ea2564546b52f..6144d1a179828 100644 --- a/pandas/util/_doctools.py +++ b/pandas/util/_doctools.py @@ -166,7 +166,8 @@ def _make_table(self, ax, df, title: str, height: float | None = None) -> None: ax.set_title(title, size=self.font_size) ax.axis("off") -def main(): + +def main() -> None: import matplotlib.pyplot as plt p = TablePlotter() @@ -193,5 +194,6 @@ def main(): p.plot(df3, df3, labels=["df3"]) plt.show() + if __name__ == "__main__": main()