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

error while formatting arguments ... can only concatenate str (not "__qualname__") to str #10133

Closed
askpatrickw opened this issue Jan 26, 2022 · 1 comment

Comments

@askpatrickw
Copy link

Describe the bug

This project builds with 4.3.2 and with 4.4.0 it fails with this error.

Warning, treated as error:
error while formatting arguments for adafruit_azureiot.IoTCentralDevice: can only concatenate str (not "__qualname__") to str

How to Reproduce

$ git clone https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT.git
$ cd Adafruit_CircuitPython_AzureIoT
$ pip install -r requirements.txt
$ pip install Sphinx  sphinx-rtd-theme
$ cd docs
$ sphinx-build -E -W -b html . _build/html -v

Expected behavior

docs to build successfully

Your project

https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT

Screenshots

sphinx-build -E -W -b html . _build/html -v

Running Sphinx v4.4.0
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://docs.circuitpython.org/en/latest/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [ 33%] api
reading sources... [ 66%] examples
reading sources... [100%] index


Traceback (most recent call last):
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/cmd/build.py", line 284, in build_main
    app.build(args.force_all, filenames)
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/application.py", line 337, in build
    self.builder.build_update()
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    self.build(to_build,
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 308, in build
    updated_docnames = set(self.read())
  File "/Users/snip/.pyenv/versions/3.9.7/lib/python3.9/contextlib.py", line 126, in __exit__
    next(self.gen)
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/util/logging.py", line 225, in pending_warnings
    memhandler.flushTo(logger)
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/util/logging.py", line 190, in flushTo
    logger.handle(record)
  File "/Users/snip/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1599, in handle
    self.callHandlers(record)
  File "/Users/snip/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
    hdlr.handle(record)
  File "/Users/snip/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 948, in handle
    rv = self.filter(record)
  File "/Users/snip/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 806, in filter
    result = f.filter(record)
  File "/Users/snip/.pyenv/versions/3.9.7/envs/cp_base/lib/python3.9/site-packages/sphinx/util/logging.py", line 433, in filter
    raise exc
sphinx.errors.SphinxWarning: error while formatting arguments for adafruit_azureiot.IoTCentralDevice: can only concatenate str (not "__qualname__") to str

Warning, treated as error:
error while formatting arguments for adafruit_azureiot.IoTCentralDevice: can only concatenate str (not "__qualname__") to str

OS

Mac, Ubuntu

Python version

3.9.7, 3.10.2

Sphinx version

4.latest

Sphinx extensions

"sphinx.ext.autodoc",     "sphinx.ext.intersphinx",     "sphinx.ext.napoleon",     "sphinx.ext.todo",

Extra tools

n\a

Additional context

adafruit/Adafruit_CircuitPython_AzureIoT#38

@tk0miya
Copy link
Member

tk0miya commented Jan 26, 2022

I reproduced this error:

# example.py
import mocked_module

def foo(s: mocked_module):
    """docstring"""
# index.rst
.. automodule:: example
   :members:
# conf.py
extensions = ['sphinx.ext.autodoc']
autodoc_mock_imports = ["mocked_module"]

The error is raised when some object or argument is annotated by mocked module. Before 4.4, it did not crash. But it does not mean supported because it's not rendered correctly.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 26, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 26, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 26, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 30, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 30, 2022
tk0miya added a commit that referenced this issue Jan 30, 2022
Fix #10133: autodoc: Crashed when mocked module is used for type annotation
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants