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

Sphinx 4.3 chokes on @lru_cache #9838

Closed
bryevdv opened this issue Nov 10, 2021 · 8 comments
Closed

Sphinx 4.3 chokes on @lru_cache #9838

bryevdv opened this issue Nov 10, 2021 · 8 comments

Comments

@bryevdv
Copy link
Contributor

bryevdv commented Nov 10, 2021

Describe the bug

Updating Sphinx to 4.3 and trying to build the Bokeh docs generate an exception:

  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 2141, in add_directive_header
    if inspect.iscoroutinefunction(obj) or inspect.isasyncgenfunction(obj):
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/inspect.py", line 194, in isasyncgenfunction
    object.__code__.co_flags & CO_ASYNC_GENERATOR)
AttributeError: 'functools._lru_cache_wrapper' object has no attribute '__code__'

Full logs:

# Sphinx version: 4.3.0
# Python version: 3.7.10 (CPython)
# Docutils version: 0.16 release
# Jinja2 version: 3.0.1
# Last messages:
#   copying bokeh-plot files... [ 90%] bokeh-content-daea7a85888d4f1198bb88d852e82fb1-docs-first_steps-first_steps_5.js
#   copying bokeh-plot files... [ 91%] bokeh-content-e4b3f645b4d14cab9f22a993f766c74d-docs-gallery-ridgeplot.js
#   copying bokeh-plot files... [ 92%] bokeh-content-e8ab12ab8de34b5f969a5819ce5d9306-docs-gallery-color_scatter.js
#   copying bokeh-plot files... [ 94%] bokeh-content-e9ab76705df2474883aa98ddc803dfeb-docs-first_steps-first_steps_5.js
#   copying bokeh-plot files... [ 95%] bokeh-content-f1ad699c8f8f43999cf4e1ceaf5cde68-docs-gallery-iris_splom.js
#   copying bokeh-plot files... [ 96%] bokeh-content-f20d56a7fc58481bbcdf9fb5ab73dc77-docs-gallery-sprint.js
#   copying bokeh-plot files... [ 97%] bokeh-content-f89cb68c11ad4347bf398617ce35a913-docs-gallery-latex_blackbody_radiation.js
#   copying bokeh-plot files... [ 98%] bokeh-content-fd2454b7293545b88f6c51fb246ef8ca-docs-gallery-dotplot.js
#   copying bokeh-plot files... [100%] bokeh-content-fe870243fa5a4f2fa2f46a66efe99a20-docs-first_steps-first_steps_4.js
#   
# Loaded extensions:
#   sphinx.ext.mathjax (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/alabaster/__init__.py
#   autoclasstoc (1.0.1) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/autoclasstoc/__init__.py
#   sphinxext.opengraph (unknown version) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxext/opengraph/__init__.py
#   sphinx_panels (0.6.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx_panels/__init__.py
#   sphinx_tabs.tabs (unknown version) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx_tabs/tabs.py
#   sphinx.ext.autodoc.preserve_defaults (1.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.autosummary (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.ifconfig (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/ifconfig.py
#   sphinx.ext.napoleon (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/napoleon/__init__.py
#   sphinx.ext.intersphinx (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/intersphinx.py
#   sphinx.ext.viewcode (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/viewcode.py
#   bokeh.sphinxext.bokeh_autodoc (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_autodoc.py
#   bokeh.sphinxext.bokeh_dataframe (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_dataframe.py
#   bokeh.sphinxext.bokeh_color (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_color.py
#   bokeh.sphinxext.bokeh_enum (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_enum.py
#   bokeh.sphinxext.bokeh_example_metadata (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_example_metadata.py
#   bokeh.sphinxext.bokeh_gallery (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_gallery.py
#   bokeh.sphinxext.bokeh_jinja (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_jinja.py
#   bokeh.sphinxext.bokeh_model (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_model.py
#   bokeh.sphinxext.bokeh_options (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_options.py
#   bokeh.sphinxext.bokeh_palette (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_palette.py
#   bokeh.sphinxext.bokeh_palette_group (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_palette_group.py
#   bokeh.sphinxext.bokeh_plot (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_plot.py
#   bokeh.sphinxext.bokeh_prop (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_prop.py
#   bokeh.sphinxext.bokeh_releases (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_releases.py
#   bokeh.sphinxext.bokeh_roles (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_roles.py
#   bokeh.sphinxext.bokeh_settings (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_settings.py
#   bokeh.sphinxext.bokeh_sitemap (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_sitemap.py
#   bokeh.sphinxext.bokehjs_content (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokehjs_content.py
#   bokeh.sphinxext.collapsible_code_block (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/collapsible_code_block.py
#   pydata_sphinx_theme (unknown version) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/pydata_sphinx_theme/__init__.py
Traceback (most recent call last):
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/application.py", line 344, in build
    self.builder.build_update()
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 296, in build_update
    len(to_build))
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 308, in build
    updated_docnames = set(self.read())
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 415, in read
    self._read_serial(docnames)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 436, in _read_serial
    self.read_doc(docname)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 476, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/io.py", line 189, in read_doc
    pub.publish()
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/core.py", line 218, in publish
    self.settings)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/io.py", line 109, in read
    self.parse()
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/readers/__init__.py", line 77, in parse
    self.parser.parse(self.input, document)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/parsers.py", line 101, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 171, in run
    input_source=document['source'])
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2769, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
    self.explicit_list(blank_finish)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2374, in explicit_list
    match_titles=self.state_machine.match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 319, in nested_list_parse
    node=node, match_titles=match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2647, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2097, in directive
    directive_class, match, type_name, option_presets)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/directive.py", line 173, in run
    result = parse_generated_content(self.state, params.result, documenter)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/directive.py", line 116, in parse_generated_content
    nested_parse_with_titles(state, content, node)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/util/nodes.py", line 335, in nested_parse_with_titles
    return state.nested_parse(content, 0, node, match_titles=1)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
    self.explicit_list(blank_finish)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2374, in explicit_list
    match_titles=self.state_machine.match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 319, in nested_list_parse
    node=node, match_titles=match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2647, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2097, in directive
    directive_class, match, type_name, option_presets)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/domains/__init__.py", line 286, in run
    return super().run()
  File "/Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_model.py", line 139, in run
    return self.parse(rst_text, "<bokeh-model>")
  File "/Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_directive.py", line 70, in parse
    nested_parse_with_titles(self.state, result, node)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/util/nodes.py", line 335, in nested_parse_with_titles
    return state.nested_parse(content, 0, node, match_titles=1)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2769, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 242, in run
    context, state, transitions)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2097, in directive
    directive_class, match, type_name, option_presets)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/directive.py", line 162, in run
    documenter.generate(more_content=self.content)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 1776, in generate
    all_members=all_members)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 984, in generate
    self.document_members(all_members)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 1765, in document_members
    super().document_members(all_members)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 862, in document_members
    check_module=members_check_module and not isattr)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 974, in generate
    self.add_directive_header(sig)
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py", line 2141, in add_directive_header
    if inspect.iscoroutinefunction(obj) or inspect.isasyncgenfunction(obj):
  File "/Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/inspect.py", line 194, in isasyncgenfunction
    object.__code__.co_flags & CO_ASYNC_GENERATOR)
AttributeError: 'functools._lru_cache_wrapper' object has no attribute '__code__'

It seems as though autodoc no longer properly handles functions that are wrapped with @lru_cache

How to Reproduce

$ git clone https://github.com/bokeh/bokeh
$ cd bokeh
$ conda env create -f environment.yml
$ conda activate bkdev
$ cd bokehjs
$ npm install -g npm@7
$ npm ci
$ cd ..
$ python setup.py install
$ bokeh sampledata
$ cd sphinx
$ BOKEH_DOCS_CDN="local" GOOGLE_API_KEY=junk make clean html

NOTE: We are pinning the sphinx version < 4.3 to unstick our broken CI builds. You may need to manually update to sphinx 4.3 manually in the environment before running make

Expected behavior

Docs successfully build without exception

Your project

https://github.com/bokeh/bokeh/tree/branch-3.0/sphinx

Screenshots

No response

OS

OSX

Python version

3.7

Sphinx version

4.3

Sphinx extensions

#   sphinx.ext.mathjax (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/alabaster/__init__.py
#   autoclasstoc (1.0.1) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/autoclasstoc/__init__.py
#   sphinxext.opengraph (unknown version) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinxext/opengraph/__init__.py
#   sphinx_panels (0.6.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx_panels/__init__.py
#   sphinx_tabs.tabs (unknown version) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx_tabs/tabs.py
#   sphinx.ext.autodoc.preserve_defaults (1.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.autosummary (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.ifconfig (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/ifconfig.py
#   sphinx.ext.napoleon (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/napoleon/__init__.py
#   sphinx.ext.intersphinx (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/intersphinx.py
#   sphinx.ext.viewcode (4.3.0) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/sphinx/ext/viewcode.py
#   bokeh.sphinxext.bokeh_autodoc (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_autodoc.py
#   bokeh.sphinxext.bokeh_dataframe (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_dataframe.py
#   bokeh.sphinxext.bokeh_color (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_color.py
#   bokeh.sphinxext.bokeh_enum (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_enum.py
#   bokeh.sphinxext.bokeh_example_metadata (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_example_metadata.py
#   bokeh.sphinxext.bokeh_gallery (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_gallery.py
#   bokeh.sphinxext.bokeh_jinja (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_jinja.py
#   bokeh.sphinxext.bokeh_model (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_model.py
#   bokeh.sphinxext.bokeh_options (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_options.py
#   bokeh.sphinxext.bokeh_palette (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_palette.py
#   bokeh.sphinxext.bokeh_palette_group (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_palette_group.py
#   bokeh.sphinxext.bokeh_plot (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_plot.py
#   bokeh.sphinxext.bokeh_prop (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_prop.py
#   bokeh.sphinxext.bokeh_releases (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_releases.py
#   bokeh.sphinxext.bokeh_roles (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_roles.py
#   bokeh.sphinxext.bokeh_settings (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_settings.py
#   bokeh.sphinxext.bokeh_sitemap (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokeh_sitemap.py
#   bokeh.sphinxext.bokehjs_content (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/bokehjs_content.py
#   bokeh.sphinxext.collapsible_code_block (unknown version) from /Users/bryan/work/bokeh/bokeh/sphinxext/collapsible_code_block.py
#   pydata_sphinx_theme (unknown version) from /Users/bryan/anaconda/envs/dev-3.7/lib/python3.7/site-packages/pydata_sphinx_theme/__init__.py

Extra tools

No response

Additional context

ref: bokeh/bokeh#11789

@bryevdv
Copy link
Contributor Author

bryevdv commented Nov 10, 2021

Maybe this is a Python issue? Here is an MRE

from functools import lru_cache
import inspect

class Foo:

    @classmethod
    @lru_cache(None)
    def foo():
        return 10

inspect.iscoroutinefunction(Foo.foo)

blows up with

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-7a30424351de> in <module>
----> 1 inspect.iscoroutinefunction(Foo.foo)

~/anaconda/envs/dev-3.7/lib/python3.7/inspect.py in iscoroutinefunction(object)
    183     """
    184     return bool((isfunction(object) or ismethod(object)) and
--> 185                 object.__code__.co_flags & CO_COROUTINE)
    186
    187 def isasyncgenfunction(object):

AttributeError: 'functools._lru_cache_wrapper' object has no attribute '__code__'

@bryevdv
Copy link
Contributor Author

bryevdv commented Nov 10, 2021

Well, I guess this is only an issue with Python 3.7 But we like to use 3.7 to have parallel builds on OSX, since otherwise they take close to ten minutes.

@tk0miya
Copy link
Member

tk0miya commented Nov 11, 2021

Indeed, this is a bug of python3.7...

@bryevdv
Copy link
Contributor Author

bryevdv commented Nov 11, 2021

Is there a way for Sphinx to work around it?

@tk0miya
Copy link
Member

tk0miya commented Nov 11, 2021

Create a wrapper of inspect.iscoroutinefunction() and ignore AttributeError. It's not difficult. But I think this should be fixed on python's side. No reason to keep it bad.

@bryevdv
Copy link
Contributor Author

bryevdv commented Nov 11, 2021

Python 3.7 is now security fixes only, unless I am misinterpreting this schedule

https://www.python.org/dev/peps/pep-0537/

@tk0miya
Copy link
Member

tk0miya commented Nov 11, 2021

Hmm... Okay, let's fix it on Sphinx side. I'll post the fix for it soon.

@bryevdv
Copy link
Contributor Author

bryevdv commented Nov 11, 2021

Thank you as always @tk0miya 😄

tk0miya added a commit that referenced this issue Nov 16, 2021
Fix #9838: autodoc: AttributeError is raised for lru_cache
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2021
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