opened
duichwer
username_0
Hi,
I am unable to build docs for one file.
If I understand those errors correct than they might be caused by the following class definition:
```python
class GSS(NamedTuple):
    """
        Helper Class to specify the return type of gss
    """

    gss: float
    nA: float
    nB: float
    nAB: float
```
Is there any way to solve this?

```bash
poetry run mkdocs build
INFO    -  Cleaning site directory 
INFO    -  Building documentation to directory: /mnt/c/Users/demo/Documents/repos/myownpackage/site 
Traceback (most recent call last):
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocs/__main__.py", line 163, in build_command
    ), dirty=not clean)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocs/commands/build.py", line 270, in build
    nav = config['plugins'].run_event('nav', nav, config=config, files=files)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocstrings/plugin.py", line 110, in on_nav
    root_object = self.documenter.get_object_documentation(import_string)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocstrings/documenter.py", line 305, in get_object_documentation
    root_object = self.get_module_documentation(obj)
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocstrings/documenter.py", line 323, in get_module_documentation
    root_object.add_child(self.get_class_documentation(member, module))
  File "/mnt/c/Users/demo/Documents/repos/myownpackage/.venv/lib/python3.6/site-packages/mkdocstrings/documenter.py", line 362, in get_class_documentation
    source = inspect.getsourcelines(actual_member)
  File "/usr/lib/python3.6/inspect.py", line 955, in getsourcelines
    lines, lnum = findsource(object)
  File "/usr/lib/python3.6/inspect.py", line 786, in findsource
    raise OSError('could not get source code')
OSError: could not get source code
Makefile:64: recipe for target 'docs' failed
make: *** [docs] Error 1
```
"OSError: could not get source code" - caused by class?
issue
created
pawamoy
username_1
Hello! Thank you for the report.

It seems `inspect` cannot access the file in which the code is written. I'll try to see if this can be fixed on `mkdocstrings` side or if we should just catch and log the error.
comment
created
duichwer
username_0
Okay. 
I do not tottaly understand what is going wrong, but maybe the issue from pytorch with `NamedTuple` is similiar? 
https://github.com/pytorch/pytorch/issues/29035
comment
created
pawamoy
username_1
Could you share a link to a repo with a procedure allowing to reproduce? What system are you using? Linux, Windows, WSL, Docker?

In the meanwhile I pushed 8e8d604 to catch the OSError and log a warning instead of failing.
comment
created
duichwer
username_0
I'm using Windows 10 with WSL (Ubuntu).
I cannot directly share this project, but I will try to create a dummy project to reproduce this issue.
comment
created
pawamoy
username_1
Hello, were you by chance able to create a dummy project to reproduce it? :slightly_smiling_face:
comment
created
duichwer
username_0
Thanks for the reminder. The last weeks have been a little tough, but now here is the demo project to reproduce the error.
https://github.com/username_0/mkdocstringsdummy
Only the error message has changed somehow.
```shell
poetry run mkdocs build
INFO    -  Cleaning site directory 
INFO    -  Building documentation to directory: /mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/site 
WARNING -  Could not read source for object mkdocstringsdummy.gss.GSS.__getnewargs__: could not get source code
WARNING -  Could not read source for object mkdocstringsdummy.gss.GSS.__new__: could not get source code
WARNING -  Could not read source for object mkdocstringsdummy.gss.GSS.__repr__: could not get source code
Traceback (most recent call last):
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/bin/mkdocs", line 11, in <module>
    sys.exit(cli())
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocs/__main__.py", line 159, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocs/commands/build.py", line 269, in build
    nav = config['plugins'].run_event('nav', nav, config=config, files=files)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocstrings/plugin.py", line 110, in on_nav
    root_object = self.documenter.get_object_documentation(import_string)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocstrings/documenter.py", line 313, in get_object_documentation
    root_object = self.get_module_documentation(obj)
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocstrings/documenter.py", line 331, in get_module_documentation
    root_object.add_child(self.get_class_documentation(member, module))
  File "/mnt/d/User/testuser/Projekte/2020/mkdocstringsdummy/.venv/lib/python3.6/site-packages/mkdocstrings/documenter.py", line 408, in get_class_documentation
    signature = inspect.signature(actual_member.fget)
  File "/usr/lib/python3.6/inspect.py", line 3065, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/lib/python3.6/inspect.py", line 2815, in from_callable
    follow_wrapper_chains=follow_wrapped)
  File "/usr/lib/python3.6/inspect.py", line 2381, in _signature_from_callable
    raise ValueError('callable {!r} is not supported by signature'.format(obj))
ValueError: callable operator.itemgetter(0) is not supported by signature
Makefile:64: recipe for target 'docs' failed
make: *** [docs] Error 1
```
comment
created
pawamoy
username_1
Thanks for the repo! Yes I'll transfer the issue over to pytkdocs.
comment