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

autodoc events for singledispatchmethod receive None for name instead of str #10529

Open
elfjes opened this issue Jun 5, 2022 · 1 comment
Open

Comments

@elfjes
Copy link

elfjes commented Jun 5, 2022

Describe the bug

When autodoc-ing a functools.singledispatchmethod, the MethodDocumenter for the registered dispatchers do not receive/parse a valid fullname, which then cause the event handlers for this method to be called with None as the name argument instead of their actual name.

How to Reproduce

foo.py

import functools

class Foo:
    @functools.singledispatchmethod
    def bar(self, a):
        pass

    @bar.register
    def dispatch(self, a: int):
        pass

index.rst

foo module
==========

.. automodule:: foo
   :members:
   :undoc-members:
   :show-inheritance:

conf.py

import os
import sys
sys.path.insert(0, os.path.abspath('.'))

extensions = [
    'sphinx.ext.autodoc',
]

def autodoc_signature(app, what, name, obj, options, signature, return_annotation):
    if name is None:
        raise ValueError("name must not be None")

def setup(app):
    app.connect('autodoc-process-signature', autodoc_signature)
$ # create above files
$ pip install -U sphinx
$ sphinx-build -T -W -a . ./build
$ # see traceback on screen

Expected behavior

autdoc event handlers should always be called with the name argument set

Your project

Screenshots

No response

OS

all

Python version

3.8+

Sphinx version

5.0.1

Sphinx extensions

sphinx.ext.autodoc

Extra tools

No response

Additional context

No response

@cdreimer-thewriter
Copy link

Not sure if related to this bug or a separate bug. For my dispatch methods, I have the @staticmethod decorator underneath the @singledispatchmethod and @methodname.register(type) decorators. The word static is not appearing next to the method name.

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

No branches or pull requests

3 participants