Skip to content
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

Docstring not shown on hover for patched methods #24045

Open
arjobsen opened this issue Mar 26, 2025 · 0 comments
Open

Docstring not shown on hover for patched methods #24045

arjobsen opened this issue Mar 26, 2025 · 0 comments

Comments

@arjobsen
Copy link

arjobsen commented Mar 26, 2025

Spyder always shows the docstring for objects on mouse hover. This works for classes and methods of classes and also for functions. But apparently not when functions are monkey patched to classes. Although printing the docstring of the patched function prints the docstring just as usual.

Example

class A:
    """Docstring of class A"""

    def method(self, x):
        """Docstring of method of class A"""
        pass

def patch(self, x):
    """Docstring of patch"""
    pass
        
A.patch = patch
a = A()

print(A.__doc__)            # Prints: Docstring of class A              Shows on hover
print(A.method.__doc__)     # Prints: Docstring of method of class A    Shows on hover
print(A.patch.__doc__)      # Prints: Docstring of patch                Does not show on hover
print(a.__doc__)            # Prints: Docstring of class                Shows on hover
print(a.method.__doc__)     # Prints: Docstring of method of class A    Shows on hover
print(a.patch.__doc__)      # Prints: Docstring of patch                Does not show on hover

Expected behavior is that the docstring of the patch is also being shown on mouse hover.

Spyder version: 6.0.3
Python version: 3.10.4
OS: Windows 11 Enterprise 22H2

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

No branches or pull requests

1 participant