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: 'PythonAttribute' object has no attribute 'properties' #466

Closed
selimt opened this issue Jul 22, 2024 · 1 comment
Closed
Labels

Comments

@selimt
Copy link

selimt commented Jul 22, 2024

If a property setter is called from the __init__ method of a class, sphinx-build results in the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/sphinx/cmd/build.py", line 337, in build_main
    app.build(args.force_all, args.filenames)
  File "/usr/local/lib/python3.9/site-packages/sphinx/application.py", line 374, in build
    self.builder.build_all()
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 254, in build_all
    self.build(None, summary=__('all source files'), method='all')
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 318, in build
    updated_docnames = set(self.read())
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 425, in read
    self._read_serial(docnames)
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 477, in _read_serial
    self.read_doc(docname)
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 536, in read_doc
    publisher.publish()
  File "/usr/local/lib/python3.9/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/usr/local/lib/python3.9/site-packages/sphinx/io.py", line 106, in read
    self.parse()
  File "/usr/local/lib/python3.9/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/usr/local/lib/python3.9/site-packages/sphinx/parsers.py", line 83, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
    self.explicit_list(blank_finish)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2382, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.pyTraceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/sphinx/cmd/build.py", line 337, in build_main
    app.build(args.force_all, args.filenames)
  File "/usr/local/lib/python3.9/site-packages/sphinx/application.py", line 374, in build
    self.builder.build_all()
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 254, in build_all
    self.build(None, summary=__('all source files'), method='all')
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 318, in build
    updated_docnames = set(self.read())
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 425, in read
    self._read_serial(docnames)
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 477, in _read_serial
    self.read_doc(docname)
  File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 536, in read_doc
    publisher.publish()
  File "/usr/local/lib/python3.9/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/usr/local/lib/python3.9/site-packages/sphinx/io.py", line 106, in read
    self.parse()
  File "/usr/local/lib/python3.9/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/usr/local/lib/python3.9/site-packages/sphinx/parsers.py", line 83, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2357, in explicit_markup
    self.explicit_list(blank_finish)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2382, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 316, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/local/lib/python3.9/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2660, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
    return method(self, expmatch)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
    return self.run_directive(
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
    result = directive_instance.run()
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/directive.py", line 137, in run
    documenter.generate(more_content=self.content)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 971, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 845, in document_members
    documenter.generate(
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 1918, in generate
    return super().generate(more_content=more_content,
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 971, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 1904, in document_members
    super().document_members(all_members)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 845, in document_members
    documenter.generate(
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 961, in generate
    self.add_directive_header(sig)
  File "/usr/local/lib/python3.9/site-packages/autoapi/documenters.py", line 240, in add_directive_header
    if property_type in self.object.properties:
AttributeError: 'PythonAttribute' object has no attribute 'properties'
", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2660, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
    return method(self, expmatch)
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
    return self.run_directive(
  File "/usr/local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
    result = directive_instance.run()
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/directive.py", line 137, in run
    documenter.generate(more_content=self.content)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 971, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 845, in document_members
    documenter.generate(
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 1918, in generate
    return super().generate(more_content=more_content,
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 971, in generate
    self.document_members(all_members)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 1904, in document_members
    super().document_members(all_members)
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 845, in document_members
    documenter.generate(
  File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 961, in generate
    self.add_directive_header(sig)
  File "/usr/local/lib/python3.9/site-packages/autoapi/documenters.py", line 240, in add_directive_header
    if property_type in self.object.properties:
AttributeError: 'PythonAttribute' object has no attribute 'properties'

This started happening with sphinx-autoapi release 3.2.0.
If I downgrade to 3.1.2 then this doesn't happen.

Example code:

class A():
  def __init__(x):
    self.x = x
  
  @property
  def x(self):
    return self._x
    
  @x.setter
  def x(self, value):
    self._x = value  
@selimt
Copy link
Author

selimt commented Jul 23, 2024

Thanks! Verified that the changes indeed fix the issue.

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

No branches or pull requests

2 participants