Skip to content

Commit

Permalink
TYP/TST: tests/mypy complaints failing locally (#52423)
Browse files Browse the repository at this point in the history
* unxfail on mac

* TYP: silence mypy complaints

* TYP: avoid mypy complaint in groupby

* ignore a little less
  • Loading branch information
jbrockmendel authored Apr 7, 2023
1 parent d5bfd2b commit c67fb96
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3135,6 +3135,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
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/io/test_clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/io/xml/test_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_register_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pandas.core import accessor


def test_dirname_mixin():
def test_dirname_mixin() -> None:
# GH37173

class X(accessor.DirNamesMixin):
Expand Down

0 comments on commit c67fb96

Please sign in to comment.