From 6943ddda51d7d258ca768975b11de27a85a5fdcd Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 4 Apr 2023 13:02:32 -0700 Subject: [PATCH 1/4] unxfail on mac --- pandas/tests/io/test_clipboard.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/test_clipboard.py b/pandas/tests/io/test_clipboard.py index 3bcf5b823647e..b5e040e05e8f7 100644 --- a/pandas/tests/io/test_clipboard.py +++ b/pandas/tests/io/test_clipboard.py @@ -4,7 +4,10 @@ import numpy as np import pytest -from pandas.compat import is_ci_environment +from pandas.compat import ( + is_ci_environment, + is_platform_mac, +) from pandas.errors import ( PyperclipException, PyperclipWindowsException, @@ -401,7 +404,8 @@ def test_round_trip_valid_encodings(self, enc, df): @pytest.mark.single_cpu @pytest.mark.parametrize("data", ["\U0001f44d...", "Ωœ∑´...", "abcd..."]) @pytest.mark.xfail( - os.environ.get("DISPLAY") is None or is_ci_environment(), + (os.environ.get("DISPLAY") is None and not is_platform_mac()) + or is_ci_environment(), reason="Cannot pass if a headless system is not put in place with Xvfb", strict=not is_ci_environment(), # Flaky failures in the CI ) From 1e83adbceb2d500bf64b141910d94f5a049b2480 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 4 Apr 2023 13:23:35 -0700 Subject: [PATCH 2/4] TYP: silence mypy complaints --- pandas/tests/io/xml/test_to_xml.py | 4 +++- pandas/tests/io/xml/test_xml.py | 8 ++++++-- pandas/tests/test_register_accessor.py | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/xml/test_to_xml.py b/pandas/tests/io/xml/test_to_xml.py index 5203506683be7..4843f40d6813d 100644 --- a/pandas/tests/io/xml/test_to_xml.py +++ b/pandas/tests/io/xml/test_to_xml.py @@ -991,7 +991,9 @@ def test_stylesheet_file_like(datapath, mode): def test_stylesheet_io(datapath, mode): xsl_path = datapath("io", "data", "xml", "row_field_output.xsl") - xsl_obj: BytesIO | StringIO + # note: By default the bodies of untyped functions are not checked, + # consider using --check-untyped-defs + xsl_obj: BytesIO | StringIO # type: ignore[annotation-unchecked] with open(xsl_path, mode) as f: if mode == "rb": diff --git a/pandas/tests/io/xml/test_xml.py b/pandas/tests/io/xml/test_xml.py index a53e5f247c73a..071bc67d2dad9 100644 --- a/pandas/tests/io/xml/test_xml.py +++ b/pandas/tests/io/xml/test_xml.py @@ -1170,7 +1170,9 @@ def test_stylesheet_io(datapath, mode): kml = datapath("io", "data", "xml", "cta_rail_lines.kml") xsl = datapath("io", "data", "xml", "flatten_doc.xsl") - xsl_obj: BytesIO | StringIO + # note: By default the bodies of untyped functions are not checked, + # consider using --check-untyped-defs + xsl_obj: BytesIO | StringIO # type: ignore[annotation-unchecked] with open(xsl, mode) as f: if mode == "rb": @@ -1349,7 +1351,9 @@ def test_stylesheet_file_close(datapath, mode): kml = datapath("io", "data", "xml", "cta_rail_lines.kml") xsl = datapath("io", "data", "xml", "flatten_doc.xsl") - xsl_obj: BytesIO | StringIO + # note: By default the bodies of untyped functions are not checked, + # consider using --check-untyped-defs + xsl_obj: BytesIO | StringIO # type: ignore[annotation-unchecked] with open(xsl, mode) as f: if mode == "rb": diff --git a/pandas/tests/test_register_accessor.py b/pandas/tests/test_register_accessor.py index a1a74dda4bd6f..d7ee208843c2d 100644 --- a/pandas/tests/test_register_accessor.py +++ b/pandas/tests/test_register_accessor.py @@ -13,7 +13,9 @@ def test_dirname_mixin(): class X(accessor.DirNamesMixin): x = 1 - y: int + # note: By default the bodies of untyped functions are not checked, + # consider using --check-untyped-defs + y: int # type: ignore[annotation-unchecked] def __init__(self) -> None: self.z = 3 From 1ad09b4a8f188125b67b2a859a0962061b53c5b3 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 4 Apr 2023 13:53:41 -0700 Subject: [PATCH 3/4] TYP: avoid mypy complaint in groupby --- pandas/core/groupby/groupby.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index b832eb90aa422..05812ca466d3f 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -3129,6 +3129,7 @@ def _nth( dropped = self.obj.dropna(how=dropna, axis=self.axis) # get a new grouper for our dropped obj + grouper: np.ndarray | Index | ops.BaseGrouper if self.keys is None and self.level is None: # we don't have the grouper info available # (e.g. we have selected out From 29234ed4bfbf85d72ed1bbe8b39a59fa9c37aee8 Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 6 Apr 2023 07:17:14 -0700 Subject: [PATCH 4/4] ignore a little less --- pandas/tests/test_register_accessor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/tests/test_register_accessor.py b/pandas/tests/test_register_accessor.py index d7ee208843c2d..a76e4b09b7f4d 100644 --- a/pandas/tests/test_register_accessor.py +++ b/pandas/tests/test_register_accessor.py @@ -8,14 +8,12 @@ from pandas.core import accessor -def test_dirname_mixin(): +def test_dirname_mixin() -> None: # GH37173 class X(accessor.DirNamesMixin): x = 1 - # note: By default the bodies of untyped functions are not checked, - # consider using --check-untyped-defs - y: int # type: ignore[annotation-unchecked] + y: int def __init__(self) -> None: self.z = 3