Skip to content

BUG: Addition of __set_module__ breaks PyCharm PyDev debugger functionalities #62121

@dangreb

Description

@dangreb

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import sys

import pandas as pd

# Envo. must have "pydev-pycharm", install with:
# pip install pydevd-pycharm
from _pydevd_bundle.pydevd_user_type_renderers import UserTypeRenderer, parse_set_type_renderers_message
from _pydevd_bundle.pydevd_user_type_renderers_utils import try_get_type_renderer_for_var

# Payload extrated from PyCharm's PyDev runtime. Contains the payload provided by the IDE's Java side,
# built from a sample customizing. It contains two "Custom Views", one for builtins.object (working fine)
# and one for pandas.DataFrame (not working).
SAMPLE_TR_CONFIG_MESSAGE = """RENDERERS	9	builtins.object	builtins.object	object	C:/Program Files/JetBrains/PyCharm 2025.2.0.1/plugins/python-ce/helpers/typeshed/stdlib/builtins.pyi	1	0	"DBG:"+ type(self).__name__	1	0	9	pandas.DataFrame	pandas.DataFrame	pandas.core.frame.DataFrame	<PYTHON_PATH>/Lib/site-packages/pandas-stubs/core/frame.pyi	0	0	"DBG:"+ type(self).__name__	1	0"""

def main() -> None:
    pass
    renderers = parse_set_type_renderers_message(SAMPLE_TR_CONFIG_MESSAGE)
    df = pd.DataFrame({"dmmy": map(float,range(8))})
    obj = object()

    object_type_renderer: UserTypeRenderer = try_get_type_renderer_for_var(obj, renderers)
    dataframe_type_renderer: UserTypeRenderer = try_get_type_renderer_for_var(df, renderers)

    print(f'Type Renderer for builtins.object | {object_type_renderer}')
    print(f'Type Renderer for pandas.DataFrame | {dataframe_type_renderer}')

    # Should Output
    """
    Type Renderer for builtins.object | <_pydevd_bundle.pydevd_user_type_renderers.UserTypeRenderer object at 0x0000048DDD0B2950>
    Type Renderer for pandas.DataFrame | None
    """


if __name__ in {"__main__", "__mp_main__"}:
    sys.exit(main())

Issue Description

As described at the referenced comment at "ENH: 55178":

The addition of the decorator set_module for DataFrames and Series, as far as i managed to verify, seems to be causing issues in PyCharm's Type Renderers functionality. When a Custom Data View is created at the IDE, we need to inform the target type, and the settings engine will validate the input against stubs and save the full qualified name it gets from them! Since no such abreviation is in place at the stubs, it will record "pandas.core.frame.DataFrame" as the qualified name.

Then when JetBrains's PyDev fork, that is base for PyCharm debugger, search for Type Renderers customized for the DataFrame, it compares the abreviated "qualname" from runtime (basically f'{type(obj)module}.{type(obj)name}' that will make for "andas.DataFrame") with the one he recorded from the customizing based on the stubs (that will be "pandas.core.frame.DataFrame").

There's also some hard-codes for pandas.core.frame.DataFrame and pandas.core.frame.Series at a "Table Provider" routine, used to determine PyCharm's "Data View" tool engine for pandas's DataFrames and Series, but that i believe should be addressed over there?

Thanks!

Expected Behavior

Considering the reproducible provided, "pydevd-pycharm" should provide a "UserTypeRenderer" object from the call performed to "try_get_type_renderer_for_var", since it was configured correctly at PyCharm's Type Rederers settings.

Installed Versions

None

For some reason "show_versions" return None. I identified this issue while experimenting with pandas release provided at the scientific nightly conda channel, where we have a pandas 3.0.0 release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions