question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue recognizing my docstring

See original GitHub issue

For the following docstring I get an error:

def logTraceback(logFunction):
  r''' Logs the exception traceback to the specified log function.

  >>> try: raise Exception()  # doctest: +ELLIPSIS
  ... except Exception: logTraceback(lambda *a, **b: sys.stdout.write(a[0] + "\n", *a[1:], **b))
  Traceback (most recent call last):
  ...
  Exception
  ...
  '''
  # here is the code

Error:

running 62 test(s)
====== <exec> ======
* DOCTEST : D:\forks\HACE\autocook\autocook\base.py::logTraceback:0, line 21 <- wrt source file
DOCTEST SOURCE
1 >>> try: raise Exception()  # doctest: +ELLIPSIS
2 ... except Exception: logTraceback(lambda *a, **b: sys.stdout.write(a[0] + "\n", *a[1:], **b))
  Traceback (most recent call last):
  ...
  Exception
  ...
DOCTEST STDOUT/STDERR

Traceback (most recent call last):
  File "d:\apps\Miniforge3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\apps\Miniforge3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "d:\apps\Miniforge3\lib\site-packages\xdoctest\__main__.py", line 172, in <module>
    retcode = main()
  File "d:\apps\Miniforge3\lib\site-packages\xdoctest\__main__.py", line 160, in main
    run_summary = xdoctest.doctest_module(modname, argv=[command], style=style,
  File "d:\apps\Miniforge3\lib\site-packages\xdoctest\runner.py", line 302, in doctest_module
    run_summary = _run_examples(enabled_examples, verbose, config,
  File "d:\apps\Miniforge3\lib\site-packages\xdoctest\runner.py", line 465, in _run_examples
    summary = example.run(verbose=verbose, on_error=on_error)
  File "d:\apps\Miniforge3\lib\site-packages\xdoctest\doctest_example.py", line 612, in run
    code = compile(
  File "<doctest:D:\forks\HACE\autocook\autocook\base.py::logTraceback:0>", line 2
    except Exception: logTraceback(lambda *a, **b: sys.stdout.write(a[0] + "\n", *a[1:], **b))
                                                                                             ^
SyntaxError: unexpected EOF while parsing

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ArneBachmannDLRcommented, Sep 24, 2021

Thanks, great work! I can finally see xdoctest do a full run through all detected doctests, in beautiful color with helpful highlights!

0reactions
Erotemiccommented, Sep 24, 2021

This should be fixed in the released 0.15.9. Please let me know if there is still an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python docstrings not working? - Stack Overflow
Python's help() function tries to, in your case, execute the more command. It should look something like this, when more is installed: > ......
Read more >
Docparams does not recognize class docstring when placed ...
The documentation states that "Constructor parameters can be documented in either the class docstring or the init docstring, but not both.
Read more >
Python Docstrings Tutorial : Examples & Format for Pydoc ...
See Python Docstrings. Learn about the different types of docstrings & various docstring formats like Sphinx, Numpy, and Pydoc with examples now.
Read more >
Troubleshooting - mkdocstrings
For Python code, check the supported docstring styles page. Re-run the Mkdocs command with -v , and carefully read any traceback.
Read more >
Specify types with docstrings | PyCharm Documentation
To specify the parameter types, follow these general steps · Press Ctrl+Alt+S and go to Editor | General |Smart Keys. · Place the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found