Skip to content

Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant (1 of 2)#4110

Merged
vitaut merged 6 commits intofmtlib:masterfrom
rturrado:make-support-python-init-py-pep-compliant
Aug 8, 2024
Merged

Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant (1 of 2)#4110
vitaut merged 6 commits intofmtlib:masterfrom
rturrado:make-support-python-init-py-pep-compliant

Conversation

@rturrado
Copy link
Copy Markdown
Contributor

@rturrado rturrado commented Aug 6, 2024

  • Make file PEP 8 compliant:
    • Add missing members to Definition class.
    • convert_type can return str | None.
    • et is imported as ElementTree.
    • doxyxml2html can receive either a List[ElementTree.Element] or an ElementTree.Element.
    • type variable is renamed to type_ (and type_text) to avoid conflicts with built-in type.
    • templateparamlist is renamed to template_param_list.
    • Classes and global functions are separated by 2 blank lines.
    • Continuation lines are fixed.
    • Triple single quotes are replaced by triple double quotes.
    • Unused parameters are preceded by an underscore.
  • Add a link to fmt's full license at the top of the file.

@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Aug 6, 2024

Thanks for the PR. Are you talking about PEP 8 and could you split indent/whitespace change into a separate commit/PR to make the more important changes easier to see in the diff?

@rturrado
Copy link
Copy Markdown
Contributor Author

rturrado commented Aug 7, 2024

Thanks for the PR. Are you talking about PEP 8

Yes! To be honest, I am just follow the recommendations (yellow flags) from CLion.

and could you split indent/whitespace change into a separate commit/PR to make the more important changes easier to see in the diff?

Sure, I'll do split it in 2.

@rturrado rturrado changed the title Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP compliant Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant Aug 7, 2024
@rturrado rturrado changed the title Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant Make support/python/mkdocstrings_handlers/cxx/__init__.py PEP 8 compliant (1 of 2) Aug 7, 2024
Copy link
Copy Markdown
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one error:


  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/work/fmt/fmt/support/python/mkdocstrings_handlers/cxx/__init__.py", line 53, in <module>
    def doxyxml2html(nodes: List[ElementTree.Element] | ElementTree.Element):
TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'type'

@rturrado
Copy link
Copy Markdown
Contributor Author

rturrado commented Aug 8, 2024

There is one error:


  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/work/fmt/fmt/support/python/mkdocstrings_handlers/cxx/__init__.py", line 53, in <module>
    def doxyxml2html(nodes: List[ElementTree.Element] | ElementTree.Element):
TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'type'

Ooops, Python 3.8 doesn't like that | operator.

if n.text:
out += escape_html(n.text)
out += doxyxml2html(n)
out += doxyxml2html([n])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be list(n) instead of [n] because what we need is a list of chile elements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be list(n) instead of [n] because what we need is a list of chile elements.

Oh my! I had introduced the from __future__ import annotations so that I could use the operator | (I tested this in a python:3.8 docker), but then I also pushed this change (something I was trying on my machine). Sorry about that! I hope it works now.

…tor.

Change convert_type return type to Optional[str].
@vitaut vitaut merged commit c985183 into fmtlib:master Aug 8, 2024
@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Aug 8, 2024

Merged, thanks!

@rturrado
Copy link
Copy Markdown
Contributor Author

Merged, thanks!

Yey, thanks to you!

@rturrado rturrado deleted the make-support-python-init-py-pep-compliant branch August 10, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants