NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
449 stars 104 forks source link

error: databind.core.converter.NoMatchingConverter #291

Closed casperdcl closed 1 year ago

casperdcl commented 1 year ago

Environment

Describe the bug

v4.7.0 works fine. v4.8.0 (#289) results in:

Traceback (most recent call last):
...
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pydoc_markdown/main.py", line 117, in load
    config.load_config(self.config)
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pydoc_markdown/__init__.py", line 113, in load_config
    result = databind.json.load(
             ^^^^^^^^^^^^^^^^^^^
...
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 87, in convert
    raise NoMatchingConverter(self, ctx, errors)
databind.core.converter.NoMatchingConverter: no deserializer for `TypeHint(~T_Page)` and payload of type `dict`

Trace:
  In "pydoc-markdown.yml"
    $: TypeHint(pydoc_markdown.PydocMarkdown)
    .renderer: TypeHint(pydoc_markdown.interfaces.Renderer)
    ^: TypeHint(pydoc_markdown.contrib.renderers.mkdocs.MkdocsRenderer)
    .pages: TypeHint(pydoc_markdown.util.pages.Pages[pydoc_markdown.util.pages.Page])
    [2]: TypeHint(pydoc_markdown.util.pages.Page)
    .children: TypeHint(typing.List[~T_Page])
    [0]: TypeHint(~T_Page)
full trace ```python Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.11.3/x64/bin/pydoc-markdown", line 8, in sys.exit(cli()) ^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pydoc_markdown/main.py", line 371, in cli pydocmd = session.load() ^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pydoc_markdown/main.py", line 117, in load config.load_config(self.config) File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/pydoc_markdown/__init__.py", line 113, in load_config result = databind.json.load( ^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/__init__.py", line 67, in load return get_object_mapper().deserialize(value, type_, filename, settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/mapper.py", line 104, in deserialize self.convert(Direction.DESERIALIZE, value, datatype, Location(filename, None, None), settings), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/mapper.py", line 76, in convert return context.convert() ^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 45, in convert return self.deserialize(ctx) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 561, in deserialize value = ctx.spawn(container[field_name], field.datatype, field_name).convert() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 789, in convert result = child_context.convert() ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 45, in convert return self.deserialize(ctx) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 561, in deserialize value = ctx.spawn(container[field_name], field.datatype, field_name).convert() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 129, in convert values = list(values) ^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 115, in ctx.spawn(val, item_type, idx).convert() File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 45, in convert return self.deserialize(ctx) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 561, in deserialize value = ctx.spawn(container[field_name], field.datatype, field_name).convert() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 129, in convert values = list(values) ^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/json/converters.py", line 115, in ctx.spawn(val, item_type, idx).convert() File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/context.py", line 123, in convert return self.convert_func(self) ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 86, in convert raise errors[0][1] File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 80, in convert return converter.convert(ctx) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/databind/core/converter.py", line 87, in convert raise NoMatchingConverter(self, ctx, errors) databind.core.converter.NoMatchingConverter: no deserializer for `TypeHint(~T_Page)` and payload of type `dict` Trace: In "pydoc-markdown.yml" $: TypeHint(pydoc_markdown.PydocMarkdown) .renderer: TypeHint(pydoc_markdown.interfaces.Renderer) ^: TypeHint(pydoc_markdown.contrib.renderers.mkdocs.MkdocsRenderer) .pages: TypeHint(pydoc_markdown.util.pages.Pages[pydoc_markdown.util.pages.Page]) [2]: TypeHint(pydoc_markdown.util.pages.Page) .children: TypeHint(typing.List[~T_Page]) [0]: TypeHint(~T_Page) ```
mcarans commented 1 year ago

I have this error too. It doesn't happen with 4.7.0. Seems to be a problem with the databind upgrade.

NiklasRosenstein commented 1 year ago

Thanks for reporting; this is indeed a bug in databind. Turns out the unit tests do not cover the serialization sufficiently, which I'll address as well.

mcarans commented 1 year ago

@NiklasRosenstein Do the problem(s) with databind render 4.8.0 unusable for many people or are these just edge cases that affect a few? If the former, please can you consider pulling 4.8.0 from PyPI so that pinning to 4.7.0 isn't needed as I have multiple projects (that call pydoc-markdown from readthedocs) that I need to change if I have to add a pin.

NiklasRosenstein commented 1 year ago

Hey @mcarans, it does affect everyone that defines their own pages with the Mkdocs renderer. 🙈 What you suggest would've been a good call indeed, esp. given that I needed some time to find time to fix this.

But it's fixed now finally. As soon as #294 get's merged, I'll make a 4.8.1 release.

NiklasRosenstein commented 1 year ago

4.8.1 released 🚀

mcarans commented 1 year ago

Thanks @NiklasRosenstein !

casperdcl commented 1 year ago

Follow-up: pre-render hooks aren't working now

NiklasRosenstein commented 1 year ago

@casperdcl Thanks for reporting; unfortunately another issue introduced with the Databind upgrade. Fixed in https://github.com/NiklasRosenstein/pydoc-markdown/pull/295 and released as 4.8.2.