Skip to content

BUG: Fix RecursionError when apply native container types as a func #61615

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

heoh
Copy link

@heoh heoh commented Jun 9, 2025

Description

Fixes a bug in DataFrame.apply raising RecursionError when passing func=list[int].

Cause

The existing code handled parameterized container types, but not native container types, yielding false positives. I also added a check for types.GenericAlias to handle native container types.

Reference: https://github.com/python/cpython/blob/3.12/Lib/typing.py#L1251

class _GenericAlias(_BaseGenericAlias, _root=True):
    ...
    # Objects which are instances of this class include:
    # * Parameterized container types, e.g. `Tuple[int]`, `List[int]`.
    #  * Note that native container types, e.g. `tuple`, `list`, use
    #    `types.GenericAlias` instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: RecursionError when apply generic alias as a func
1 participant