AnswerDotAI / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.94k stars 492 forks source link

nbdev_readme fails with mysterious error if docstring contains "\" #1455

Open nikolas-claussen opened 1 month ago

nikolas-claussen commented 1 month ago

nbdev_readme fails if I have a backslash in the docstring of any exported function, e.g.

#|  export
def f():
    """ 
    Example doctring $x \mapsto y$
    """
    return None

The resulting error message is very long and does not indicate the problem (although it does point to the offending function).

jlopezpena commented 1 month ago

Are you using python 3.12? The change in string parsing can yield warnings or errors with strings that contain backslashes. Those can normally be fixed simply by telling python it is a "raw" string, eg, just prepending the quotes with an r:

#|  export
def f():
    r""" 
    Example doctring $x \mapsto y$
    """
    return None