Skip to content
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

TypeError: Project.__init__() got an unexpected keyword argument 'files' #2

Closed
adaxi opened this issue Sep 9, 2024 · 6 comments
Closed

Comments

@adaxi
Copy link

adaxi commented Sep 9, 2024

When I attempt to build my documentation I get the following error:

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /home/gbo/Workspaces/reproducer/docs/site
[info] Loaded plugin typedoc-material-theme
[info] Documentation generated at ./site/typedoc
INFO    -  griffe_typedoc: JSON written to /tmp/tmp7i_xda5m
ERROR   -  Error reading page 'index.md': Project.__init__() got an unexpected keyword argument 'files'
Traceback (most recent call last):
  File "/home/gbo/Workspaces/reproducer/docs/.venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/__main__.py", line 288, in build_command
    build.build(cfg, dirty=not clean)
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 310, in build
    _populate_page(file.page, config, files, dirty)
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
    page.render(config, files)
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/structure/pages.py", line 285, in render
    self.content = md.convert(self.markdown)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/core.py", line 357, in convert
    root = self.parser.parseDocument(self.lines).getroot()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/blockparser.py", line 117, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/blockparser.py", line 136, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/blockparser.py", line 158, in parseBlocks
    if processor.run(parent, blocks) is not False:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocstrings/extension.py", line 128, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocstrings/extension.py", line 216, in _process_block
    data: CollectorItem = handler.collect(identifier, options)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocstrings_handlers/typescript/handler.py", line 124, in collect
    data = load_typedoc(["typedoc"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/loader.py", line 59, in load
    return json.load(tmpfile, cls=TypedocDecoder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/decoder.py", line 538, in _object_hook
    return _loader_map[kind](obj_dict, self._symbol_map)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/decoder.py", line 69, in wrapper
    obj = func(obj_dict)
          ^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/decoder.py", line 86, in _load_project
    return Project(**obj_dict)
           ^^^^^^^^^^^^^^^^^^^
TypeError: Project.__init__() got an unexpected keyword argument 'files'

Attached you can find a reproducer:
reproducer.tar.gz

To reproduce:

tar -zxf reproducer.tar.gz
cd reproducer/docs
python -m venv .venv
.venv/bin/pip install -r requirements.txt
npm install
.venv/bin/mkdocs build

The reproducer includes all the plugins I am currently using. Note that I am also also includes the typedoc plugin which generates typedoc documentation on the side, though this one does not seem to be interfering with mkdocstrings-typescript.

@pawamoy
Copy link
Member

pawamoy commented Sep 9, 2024

Thanks a lot for the report and reproduction!

Strangely, I get a different error from you:

TypeError: Project.init() missing 1 required keyword-only argument: 'readme'

I believe I can simply make the readme parameter optional, and add an optional files parameter too, to resolve both issues.

@pawamoy
Copy link
Member

pawamoy commented Sep 9, 2024

Could you somehow give me more information about this files argument that seems to be passed to Project 🤔? You can probably either run a Python debugger, or generate the JSON output with typedoc by running it manually, and checking the resulting JSON to see what these files are (list of paths?).

@pawamoy
Copy link
Member

pawamoy commented Sep 9, 2024

Ah, I now get the same error as you (fixed my setup, had typedoc installed globally).

@pawamoy
Copy link
Member

pawamoy commented Sep 9, 2024

{'entries': {'1': '../sdk/src/index.ts'}, 'reflections': {'1': 0}}

https://typedoc.org/api/interfaces/JSONOutput.FileRegistry.html#entries

@pawamoy
Copy link
Member

pawamoy commented Sep 9, 2024

OK I've pushed new commits (and tags) for both griffe-typedoc and mkdocstrings-typescript (insiders versions). This shouldn't crash anymore.

@adaxi
Copy link
Author

adaxi commented Sep 10, 2024

Thank you for the quick reaction time, has solved this issue :)

pawamoy added a commit to mkdocstrings/griffe-typedoc that referenced this issue Mar 9, 2025
pawamoy added a commit that referenced this issue Mar 24, 2025
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

No branches or pull requests

2 participants