sphinx-contrib / openapi

OpenAPI (fka Swagger) spec renderer for Sphinx.
https://sphinxcontrib-openapi.readthedocs.io
BSD 2-Clause "Simplified" License
111 stars 80 forks source link

0.8.4: not ready for `pyupgrade --py38-plus` #158

Closed kloczek closed 1 month ago

kloczek commented 1 month ago

According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023. I've been trying to filter all code over pyupgracde --py38-plus and loos like after that it is not possible to generate focumntation

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v8.0.2
loading translations [en]... done
making output directory... done
Converting `source_suffix = '.rst'` to `source_suffix = {'.rst': 'restructuredtext'}`.
building [mo]: targets for 0 po files that are out of date
writing output...
building [man]: all manpages
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/sphinx/cmd/build.py", line 337, in build_main
    app.build(args.force_all, args.filenames)
  File "/usr/lib/python3.10/site-packages/sphinx/application.py", line 378, in build
    self.builder.build_update()
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 293, in build_update
    self.build(['__all__'], to_build)
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 317, in build
    updated_docnames = set(self.read())
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 424, in read
    self._read_serial(docnames)
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 476, in _read_serial
    self.read_doc(docname)
  File "/usr/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 535, in read_doc
    publisher.publish()
  File "/usr/lib/python3.10/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/usr/lib/python3.10/site-packages/sphinx/io.py", line 106, in read
    self.parse()
  File "/usr/lib/python3.10/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/usr/lib/python3.10/site-packages/sphinx/parsers.py", line 83, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 3024, in text
    self.section(title.lstrip(), source, style, lineno + 1, messages)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/usr/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2355, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
    return method(self, expmatch)
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
    return self.run_directive(
  File "/usr/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
    result = directive_instance.run()
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/directive.py", line 56, in run
    return renderer_cls(self.state, self.options).render(spec)
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/renderers/abc.py", line 40, in render
    for line in self.render_restructuredtext_markup(spec):
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/renderers/_httpdomain_old.py", line 55, in render_restructuredtext_markup
    yield from openapihttpdomain(spec, **self._options)
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/openapi20.py", line 81, in _httpresource
    for line in convert_json_schema(
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/openapi20.py", line 153, in convert_json_schema
    _convert(schema)
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/openapi20.py", line 114, in _convert
    _convert(schema['items'], name + '[]')
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/openapi20.py", line 109, in _convert
    _convert(
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/openapi20.py", line 140, in _convert
    f' {schema[description]}'))
NameError: name 'description' is not defined

Exception occurred:
  File "/home/tkloczko/rpmbuild/BUILD/openapi-0.8.4/build/lib/sphinxcontrib/openapi/openapi20.py", line 140, in _convert
    f' {schema[description]}'))
NameError: name 'description' is not defined
The full traceback has been saved in /tmp/sphinx-err-5bc06nma.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
stephenfin commented 1 month ago

Thanks for the report, but really the use (or non-use) of a linter-adjacent tool like pyupgrade is up to the project and not something I'd see any benefit to someone doing out-of-tree. I definitely wouldn't be doing it myself as part of packaging activity, since it would move you further from upstream and potentially introduce new bugs not found upstream. By all means, if you'd like to submit a PR integrating pyupgrade (and addressing these issues you see) then I'll happily review it, but it's way down my own priority list.