Closed rabernat closed 1 year ago
Hi @rabernat, thanks for raising this issue! Unfortunately I won't have time to look into this in the short term, but I'd be happy to accept a PR if you're up for it.
Side note: I'm not sure if lib2to3 was updated to support match/case.
Looks like lib2to3
is incapable of parsing match
(due to it being LL(1)) and is deprecated / scheduled to be removed from the language:
https://docs.python.org/3.11/library/2to3.html#module-lib2to3
These packages are recommended as alternatives:
I'm taking a look at it now as I just ran into this issue and getting rid of match
isn't really an option. No promises I'll get anywhere with it but if I do I'll share the code.
@rabernat @NiklasRosenstein This passes the docspec-python
tests, including a new one for the match
statement:
https://github.com/nrser/docspec/tree/blib2to3
It's a single commit:
https://github.com/nrser/docspec/commit/1a08d2a94aae13253f3c5b0abed8829472c1c49d
It seems the black folks have their own fork/extension of lib2to3
called blib2to3
that is bundled with the black
package. They managed to get it to parse at least some amount of match
forms.
I added black
as a dependency and swapped blib2to3
in. This is totally a "quick fix", and I have no idea how well it will work, but I wanted to share it now in case I never end up getting any further with it.
Just a heads up, tried that code on source from an actual project and there are a bunch of issues. Looks like relatively minor stuff involving the AST being slightly different, but it's gonna take some time to grind through.
Merged #80, thanks @nrser!
Thanks for maintaining this fantastic project! :pray: We are using it to integrate our python API docs with a Docusaurus site.
Describe the bug Python 3.10 introduced structural pattern matching with
match
/case
syntax. I have found that mydoc markdown cannot parse code with this syntax. I am filing the bug report here rather than in pydoc-markdown because the stack trace indicates that the error comes fromdocspec_python
To Reproduce Steps to reproduce the behavior:
Create the following python module
Create a pydoc-markdown configuration to parse it. Mine looks like this
Then run
pydoc-markdown
. My stack trace looks like thisExpected behavior Given that docspec-python supports Python >=3.7, I would expect it to be able to parse all valid python 3.10 syntax.
Versions pydoc-markdown, version 4.6.3 docspec-python, version 2.0.2