Skip to content

Commit b48e0e3

Browse files
authored
fix: remove pandas.concat signature hook (#2173)
Signed-off-by: Ryo Kitagawa <kitadrum50@gmail.com>
1 parent 597fea7 commit b48e0e3

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

pandera/mypy.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ def __init__(self, options) -> None:
6464
self.plugin_config = PanderaPluginConfig(options)
6565
super().__init__(options)
6666

67-
def get_function_signature_hook(self, fullname: str):
68-
"""Adjust the function signatures of pandas functions."""
69-
if fullname == PANDAS_CONCAT:
70-
return self.pandas_concat_callback
71-
7267
def get_base_class_hook(
7368
self, fullname: str
7469
) -> "Optional[Callable[[ClassDefContext], None]]":
@@ -87,30 +82,6 @@ def _pandera_model_class_maker_callback(
8782
transformer = DataFrameModelTransformer(ctx, self.plugin_config)
8883
transformer.transform()
8984

90-
def pandas_concat_callback(
91-
self, ctx: Union[FunctionSigContext, MethodSigContext]
92-
) -> CallableType:
93-
"""Adjusts the signature pandas.concat to allow generator inputs."""
94-
iterable = self.lookup_fully_qualified("typing.Iterable")
95-
if iterable is not None:
96-
iterable_node = cast(TypeInfo, iterable.node)
97-
else:
98-
raise ValueError("typing.Iterable node not found")
99-
100-
union_type = cast(UnionType, ctx.default_signature.arg_types[0])
101-
102-
pandas_data_type = ctx.default_signature.ret_type
103-
arg_types = [
104-
UnionType(
105-
[
106-
Instance(iterable_node, [pandas_data_type]),
107-
*union_type.items,
108-
]
109-
),
110-
*ctx.default_signature.arg_types[1:],
111-
]
112-
return ctx.default_signature.copy_modified(arg_types=arg_types)
113-
11485

11586
class DataFrameModelTransformer:
11687
def __init__(self, ctx: ClassDefContext, plugin_config):

tests/mypy/test_pandas_static_type_checking.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ def test_pandas_stubs_false_positives(
220220
str(test_module_dir / "config" / config),
221221
]
222222
# pylint: disable=subprocess-run-check
223-
subprocess.run(commands, text=True)
223+
result = subprocess.run(commands, text=True)
224+
# NOTE: mypy return code is 0 if no errors were found, 1 if errors were found
225+
# or 2 if there was a failure in checking
226+
assert result.returncode in (0, 1)
224227
resulting_errors = _get_mypy_errors(module, capfd.readouterr().out)
225228
assert len(expected_errors) == len(resulting_errors)
226229
for expected, error in zip(expected_errors, resulting_errors):

0 commit comments

Comments
 (0)