Skip to content

fix(PythonCollector): error for unexpected result #1

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

Merged
merged 14 commits into from
Feb 19, 2022

Conversation

rachmadaniHaryono
Copy link
Contributor

this is fix for several error i got when trying mkdocs on https://github.com/iamtalhaasghar/yewtube

in the end i still don't know what to change when rebuild_category_lists handle empty dict

legacy error 1

ERROR    -  Error reading page 'reference/config.md': 'loading_errors'
Traceback (most recent call last):
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
    │        └ <Group cli><module 'sys' (built-in)>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           │          │       └ {}
           │          └ ()
           └ <Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         │           └ <click.core.Context object at 0x7f25a8c0c1c0><Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │                      └ <click.core.Context object at 0x7f25a8f10c40>
           │               └ <click.core.Context object at 0x7f25a8f10c40><function MultiCommand.invoke.<locals>._process_result at 0x7f25a8f8d040>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │          │                └ <click.core.Context object at 0x7f25a8f10c40>
           │          └ <Command serve><click.core.Context object at 0x7f25a8f10c40>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'dev_addr': None, 'livereload': 'livereload', 'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_di...
                       └ ()
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 177, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
    │                    │                    │             └ {'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_directory_urls': None}
    │                    │                    └ 'livereload'
    │                    └ None<module 'mkdocs.commands.serve' from '/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/m...
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
             └ <function serve.<locals>.builder at 0x7f25a7c4b670>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
    │     │                   │                  └ False
    │     │                   └ True
    │     └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ <function build at 0x7f25a7f25f70>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
    │              │          │       │      └ False
    │              │          │       └ <mkdocs.structure.files.Files object at 0x7f25a778f970>
    │              │          └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    │              └ File(src_path='reference/config.md', dest_path='reference/config/index.html', name='config', url='reference/config/')
    └ <function _populate_page at 0x7f25a7f25e50>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
    │           │       └ <mkdocs.structure.files.Files object at 0x7f25a778f970>
    │           └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/structure/pages.py", line 174, in render
    self.content = md.convert(self.markdown)
    │              │          └ Page(title='Config', url='/yewtube/reference/config/')
    │              └ <markdown.core.Markdown object at 0x7f25a7792f10>Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/core.py", line 264, in convert
    root = self.parser.parseDocument(self.lines).getroot()
           │                         └ <markdown.core.Markdown object at 0x7f25a7792f10><markdown.core.Markdown object at 0x7f25a7792f10>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
    │               │                    └ ['::: mps_youtube.config', '', '', '']
    │               └ <markdown.blockparser.BlockParser object at 0x7f25a7627340><markdown.blockparser.BlockParser object at 0x7f25a7627340>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
    │                │       └ '::: mps_youtube.config\n\n\n'
    │                └ <Element 'div' at 0x7f25a76091d0><markdown.blockparser.BlockParser object at 0x7f25a7627340>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 120, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
                          │                   │           │      └ 0
                          │                   │           └ ''
                          │                   └ 'mps_youtube.config'<mkdocstrings.extension.AutoDocProcessor object at 0x7f25a7be4070>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 185, in _process_block
    data: CollectorItem = handler.collector.collect(identifier, selection)
          │               │                         │           └ ChainMap({}, {})
          │               │                         └ 'mps_youtube.config'
          │               └ <mkdocstrings.handlers.python.PythonHandler object at 0x7f25a751db50>typing.Any
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/handlers/python/collector.py", line 161, in collect
    for loading_error in result["loading_errors"]:
KeyError: 'loading_errors'

legacy error 2

ERROR    -  Error reading page 'reference/config.md': 'parsing_errors'
Traceback (most recent call last):
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
    │        └ <Group cli><module 'sys' (built-in)>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           │          │       └ {}
           │          └ ()
           └ <Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         │           └ <click.core.Context object at 0x7fd77c7ab1c0><Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │                      └ <click.core.Context object at 0x7fd77caafc40>
           │               └ <click.core.Context object at 0x7fd77caafc40><function MultiCommand.invoke.<locals>._process_result at 0x7fd77cb2c040>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │          │                └ <click.core.Context object at 0x7fd77caafc40>
           │          └ <Command serve><click.core.Context object at 0x7fd77caafc40>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'dev_addr': None, 'livereload': 'livereload', 'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_di...
                       └ ()
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 177, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
    │                    │                    │             └ {'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_directory_urls': None}
    │                    │                    └ 'livereload'
    │                    └ None<module 'mkdocs.commands.serve' from '/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/m...
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
             └ <function serve.<locals>.builder at 0x7fd77b7db670>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
    │     │                   │                  └ False
    │     │                   └ True
    │     └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ <function build at 0x7fd77bac5f70>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
    │              │          │       │      └ False
    │              │          │       └ <mkdocs.structure.files.Files object at 0x7fd77b32f910>
    │              │          └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    │              └ File(src_path='reference/config.md', dest_path='reference/config/index.html', name='config', url='reference/config/')
    └ <function _populate_page at 0x7fd77bac5e50>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
    │           │       └ <mkdocs.structure.files.Files object at 0x7fd77b32f910>
    │           └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/structure/pages.py", line 174, in render
    self.content = md.convert(self.markdown)
    │              │          └ Page(title='Config', url='/yewtube/reference/config/')
    │              └ <markdown.core.Markdown object at 0x7fd77b331460>Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/core.py", line 264, in convert
    root = self.parser.parseDocument(self.lines).getroot()
           │                         └ <markdown.core.Markdown object at 0x7fd77b331460><markdown.core.Markdown object at 0x7fd77b331460>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
    │               │                    └ ['::: mps_youtube.config', '', '', '']
    │               └ <markdown.blockparser.BlockParser object at 0x7fd77b2c5070><markdown.blockparser.BlockParser object at 0x7fd77b2c5070>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
    │                │       └ '::: mps_youtube.config\n\n\n'
    │                └ <Element 'div' at 0x7fd77b1e5360><markdown.blockparser.BlockParser object at 0x7fd77b2c5070>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 120, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
                          │                   │           │      └ 0
                          │                   │           └ ''
                          │                   └ 'mps_youtube.config'<mkdocstrings.extension.AutoDocProcessor object at 0x7fd77b783640>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 185, in _process_block
    data: CollectorItem = handler.collector.collect(identifier, selection)
          │               │                         │           └ ChainMap({}, {})
          │               │                         └ 'mps_youtube.config'
          │               └ <mkdocstrings.handlers.python.PythonHandler object at 0x7fd77b0bbb20>typing.Any
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/handlers/python/collector.py", line 164, in collect
    for errors in result["parsing_errors"].values():
KeyError: 'parsing_errors'

legacy error 3

ERROR    -  Error reading page 'reference/config.md': 'objects'
Traceback (most recent call last):
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
    │        └ <Group cli><module 'sys' (built-in)>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           │          │       └ {}
           │          └ ()
           └ <Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         │           └ <click.core.Context object at 0x7f159dedc1c0><Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │                      └ <click.core.Context object at 0x7f159cf15940>
           │               └ <click.core.Context object at 0x7f159cf15940><function MultiCommand.invoke.<locals>._process_result at 0x7f159e25d040>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │          │                └ <click.core.Context object at 0x7f159cf15940>
           │          └ <Command serve><click.core.Context object at 0x7f159cf15940>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'dev_addr': None, 'livereload': 'livereload', 'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_di...
                       └ ()
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 177, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
    │                    │                    │             └ {'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_directory_urls': None}
    │                    │                    └ 'livereload'
    │                    └ None<module 'mkdocs.commands.serve' from '/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/m...
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
             └ <function serve.<locals>.builder at 0x7f159cf0c670>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
    │     │                   │                  └ False
    │     │                   └ True
    │     └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ <function build at 0x7f159d1f5f70>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
    │              │          │       │      └ False
    │              │          │       └ <mkdocs.structure.files.Files object at 0x7f159ca5f8b0>
    │              │          └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    │              └ File(src_path='reference/config.md', dest_path='reference/config/index.html', name='config', url='reference/config/')
    └ <function _populate_page at 0x7f159d1f5e50>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
    │           │       └ <mkdocs.structure.files.Files object at 0x7f159ca5f8b0>
    │           └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/structure/pages.py", line 174, in render
    self.content = md.convert(self.markdown)
    │              │          └ Page(title='Config', url='/yewtube/reference/config/')
    │              └ <markdown.core.Markdown object at 0x7f159c85c610>Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/core.py", line 264, in convert
    root = self.parser.parseDocument(self.lines).getroot()
           │                         └ <markdown.core.Markdown object at 0x7f159c85c610><markdown.core.Markdown object at 0x7f159c85c610>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
    │               │                    └ ['::: mps_youtube.config', '', '', '']
    │               └ <markdown.blockparser.BlockParser object at 0x7f159c85c2e0><markdown.blockparser.BlockParser object at 0x7f159c85c2e0>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
    │                │       └ '::: mps_youtube.config\n\n\n'
    │                └ <Element 'div' at 0x7f159c918590><markdown.blockparser.BlockParser object at 0x7f159c85c2e0>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 120, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
                          │                   │           │      └ 0
                          │                   │           └ ''
                          │                   └ 'mps_youtube.config'<mkdocstrings.extension.AutoDocProcessor object at 0x7f159c82c6a0>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 185, in _process_block
    data: CollectorItem = handler.collector.collect(identifier, selection)
          │               │                         │           └ ChainMap({}, {})
          │               │                         └ 'mps_youtube.config'
          │               └ <mkdocstrings.handlers.python.PythonHandler object at 0x7f159c7eca90>typing.Any
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/handlers/python/collector.py", line 169, in collect
    result = result["objects"][0]
    │        └ {'error': '', 'traceback': 'Traceback (most recent call last):\n  File "/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewt...
    └ {'error': '', 'traceback': 'Traceback (most recent call last):\n  File "/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewt...
KeyError: 'objects'

legacy error 4

ERROR    -  Error reading page 'reference/config.md': 'attributes'
Traceback (most recent call last):
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
    │        └ <Group cli><module 'sys' (built-in)>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
           │          │       └ {}
           │          └ ()
           └ <Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
         │           └ <click.core.Context object at 0x7fbae3b0d1c0><Group cli>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │                      └ <click.core.Context object at 0x7fbae3e11c40>
           │               └ <click.core.Context object at 0x7fbae3e11c40><function MultiCommand.invoke.<locals>._process_result at 0x7fbae3e8e040>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │          │                └ <click.core.Context object at 0x7fbae3e11c40>
           │          └ <Command serve><click.core.Context object at 0x7fbae3e11c40>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'dev_addr': None, 'livereload': 'livereload', 'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_di...
                       └ ()
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 177, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
    │                    │                    │             └ {'watch_theme': False, 'config_file': None, 'strict': None, 'theme': None, 'use_directory_urls': None}
    │                    │                    └ 'livereload'
    │                    └ None<module 'mkdocs.commands.serve' from '/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/m...
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
             └ <function serve.<locals>.builder at 0x7fbae2b3d670>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
    │     │                   │                  └ False
    │     │                   └ True
    │     └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ <function build at 0x7fbae2e28f70>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
    │              │          │       │      └ False
    │              │          │       └ <mkdocs.structure.files.Files object at 0x7fbae26909a0>
    │              │          └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    │              └ File(src_path='reference/config.md', dest_path='reference/config/index.html', name='config', url='reference/config/')
    └ <function _populate_page at 0x7fbae2e28e50>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
    │           │       └ <mkdocs.structure.files.Files object at 0x7fbae26909a0>
    │           └ {'config_file_path': '/mnt/ac54dceb-73a5-4f94-b52c-cb7a426c0f29/Documents/yewtube/mkdocs.yml', 'site_name': 'Yewtube', 'nav': [{...
    └ Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocs/structure/pages.py", line 174, in render
    self.content = md.convert(self.markdown)
    │              │          └ Page(title='Config', url='/yewtube/reference/config/')
    │              └ <markdown.core.Markdown object at 0x7fbae248b520>Page(title='Config', url='/yewtube/reference/config/')
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/core.py", line 264, in convert
    root = self.parser.parseDocument(self.lines).getroot()
           │                         └ <markdown.core.Markdown object at 0x7fbae248b520><markdown.core.Markdown object at 0x7fbae248b520>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
    │               │                    └ ['::: mps_youtube.config', '', '', '']
    │               └ <markdown.blockparser.BlockParser object at 0x7fbae24e8a30><markdown.blockparser.BlockParser object at 0x7fbae24e8a30>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
    │                │       └ '::: mps_youtube.config\n\n\n'
    │                └ <Element 'div' at 0x7fbae2547e50><markdown.blockparser.BlockParser object at 0x7fbae24e8a30>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/markdown/blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 120, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
                          │                   │           │      └ 0
                          │                   │           └ ''
                          │                   └ 'mps_youtube.config'<mkdocstrings.extension.AutoDocProcessor object at 0x7fbae2ae5490>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/extension.py", line 185, in _process_block
    data: CollectorItem = handler.collector.collect(identifier, selection)
          │               │                         │           └ ChainMap({}, {})
          │               │                         └ 'mps_youtube.config'
          │               └ <mkdocstrings.handlers.python.PythonHandler object at 0x7fbae241cb20>typing.Any
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/handlers/python/collector.py", line 172, in collect
    rebuild_category_lists(result)
    │                      └ {}
    └ <function rebuild_category_lists at 0x7fbae265cdc0>
  File "/home/r3r/.cache/pypoetry/virtualenvs/yewtube-kzulWQkH-py3.9/lib/python3.9/site-packages/mkdocstrings/handlers/python/collector.py", line 198, in rebuild_category_lists
    obj[category] = [obj["children"][path] for path in obj[category]]
    │   │            │                                 │   └ 'attributes'
    │   │            │                                 └ {}
    │   │            └ {}
    │   └ 'attributes'
    └ {}
KeyError: 'attributes'

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Hi @rachmadaniHaryono, thanks for the contribution!

I think there's an easier way. We see in your third error that 'error' in empty in the dict. That's something I didn't plan for, and if we fix the handling of this case, all the next cases will be fixed as well, because the "loading_errors", "parsing_errors" and "objects" keys are always present. So actually you just need to do this at lines 155 and 156:

-        error = result.get("error")
-        if error:
+        if "error" in result:
+            error = result["error"]

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

And we should definitely add a test for it. Could you do that please?

@rachmadaniHaryono
Copy link
Contributor Author

you mean like that?

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Exactly! That should cover all cases.

@rachmadaniHaryono
Copy link
Contributor Author

And we should definitely add a test for it. Could you do that please?

is it enough?

8e9966c (#1)

Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

These tests are nice to have (we can keep them), but they don't actually test the fix here.
You can probably patch the collector's process.stdout.readline method with a lambda that returns a JSON string in which there is "error": "", "traceback": "hello" and you can then check that the raised CollectionError contains "hello" in its message. Does it make sense 😅 ? I can give more details if needed 🙂

@rachmadaniHaryono
Copy link
Contributor Author

i think this cover that error and traceback branching

this will not test the program result is succesful

Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
@rachmadaniHaryono
Copy link
Contributor Author

i will fix error from the quality ci and find out what happen with windows ci test

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Ah, I can deal with the Windows one, just fix the quality warnings :)

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Windows runs should be fixed if you rebase on main branch.

rachmadaniHaryono and others added 2 commits February 19, 2022 23:10
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
@rachmadaniHaryono
Copy link
Contributor Author

i fix everything except https://github.com/m-burst/flake8-pytest-style/blob/master/docs/rules/PT012.md

i also tried this

def test():
    obj = collector.PythonCollector()
    with mock.patch("mkdocstrings.handlers.python.collector.json.loads", return_value=retval):
        with pytest.raises(CollectionError) as excinfo:
            assert obj.collect("", {})
            assert str(excinfo.value) == exp_res

if last asert move to outer part it will raise WPS441 Found control variable used after block: excinfo

if it kept as is it will raise PT012

i choose to ignore PT012 because it make less sense

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Oh yes, you did well, PT012 is just annoying (doesn't get with statements) 🙂

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Argh, it seems I've broken CI again. Let me fix it.

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

You can rebase on main, sorry 🙇‍♂️

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2022

Oh well, the mkdocs-material dep is missing from the test group. If you don't mind, that's LGTM so I'll merge and fix CI after 🙂

Thank you very much for your contribution and prompt response to my review!

@pawamoy pawamoy merged commit 0e7ab59 into mkdocstrings:main Feb 19, 2022
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