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

AttributeError: 'DirectiveAdapter' object has no attribute 'get_field_type_map' since v2.1.0 #6474

Closed
p12tic opened this issue Jun 11, 2019 · 7 comments

Comments

@p12tic
Copy link

p12tic commented Jun 11, 2019

Describe the bug
I get this error since v2.1.0:

AttributeError: 'DirectiveAdapter' object has no attribute 'get_field_type_map' since v2.1.0.

The issue has been bisected to PR #6192.

To Reproduce

git clone https://github.com/buildbot/buildbot
cd buildbot
make virtualenv
source .venv/bin/activate
<edit requirements-cidocs.txt to use Sphinx==2.1.0 or newer>
pip install -r requirements-ci.txt
pip install -r requirements-cidocs.txt
make docs

Expected behavior
No error.

Your project
https://github.com/buildbot/buildbot

Screenshots
(none)

Environment info

  • OS: Kubuntu 18.04
  • Python version: 3.6.7
  • Sphinx version: 2.1.0
  • Sphinx extensions:
    sphinx-jinja==1.1.0
    sphinxcontrib-blockdiag==1.5.5
    sphinxcontrib-spelling==4.2.1
    sphinxcontrib-websupport==1.1.2

Additional context
(none)

@p12tic
Copy link
Author

p12tic commented Jun 11, 2019

Attached full traceback: sphinx-err-zlejo3ha.log

@tk0miya
Copy link
Member

tk0miya commented Jun 15, 2019

It seems the error was raised inside bbdocs/ext.py.

  File "/home/p12/code/my/checkouts/buildbot/master/docs/bbdocs/ext.py", line 97, in run
    DocFieldTransformer(self).transform_all(contentnode)
  File "/home/p12/code/my/checkouts/buildbot/.venv/lib/python3.6/site-packages/sphinx/util/docfields.py", line 252, in __init__
    self.typemap = directive.get_field_type_map()
AttributeError: 'DirectiveAdapter' object has no attribute 'get_field_type_map'

And it uses DocFieldTransformer for non ObjectDescription subclasses. That is very tricky code to me...

@p12tic
Copy link
Author

p12tic commented Jun 20, 2019

Hm, thanks for pointing this out. I'll see whether this is possible to fix on our side.

@abompard
Copy link

I'm having the same issue with the cornice_sphinx extension, because it adds a directive that isn't a subclass of ObjectDescription. Since the get_field_type_map method is called by the DocFieldTransformer unconditionnaly, maybe the method should be moved to the SphinxDirective superclass. Or the DocFieldTransformer could catch that exception and set typemap to {} instead.

@tk0miya
Copy link
Member

tk0miya commented Aug 1, 2019

I object to move get_field_type_map() to SphinxDirective because field type map is not a property of standard directives. They are only for ObjectDescription.
But I can accept another idea:

Or the DocFieldTransformer could catch that exception and set typemap to {} instead.

So reopen this again.

@tk0miya tk0miya reopened this Aug 1, 2019
@tk0miya tk0miya added this to the 2.2.0 milestone Aug 1, 2019
@tk0miya tk0miya added the markup label Aug 1, 2019
tk0miya added a commit to tk0miya/sphinx that referenced this issue Aug 1, 2019
@tk0miya
Copy link
Member

tk0miya commented Aug 1, 2019

I just posted #6624. Could you check this please?

Note: this does not mean DocFieldTransformer will accept standard directives in future. This only keeps compatibility with past versions.

tk0miya added a commit that referenced this issue Aug 17, 2019
…s_non_ObjectDescription

Fix #6474: ``DocFieldTransformer`` raises AttributeError
@tk0miya
Copy link
Member

tk0miya commented Aug 17, 2019

Fixed by #6624 .
Thank you for comment.
Closing again.

@tk0miya tk0miya closed this as completed Aug 17, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 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

3 participants