Invalid docstrings when last character of last prop comment is a double quote
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Describe your context
MacOS Mojave 10.14.3.
dash 0.43.0
dash-core-components 0.48.0
dash-html-components 0.16.0
dash-renderer 0.24.0
dash-table 3.7.0
Describe the bug
The bug occurs when generating the python class for a custom Dash component using
venv/bin/python -c \"import dash; dash.development.component_loader.generate_classes('galileo_scope_components', 'galileo_scope_components/metadata.json')\"
If the last character of the last comment on the React prop is a double quote, then the python class docstring is invalid. It has four double quotes at the end (the one from the comment, plus 3 closing quotes). Trying to load the class gives a syntax error:
Traceback (most recent call last):
File "_validate_init.py", line 14, in <module>
components_lib = importlib.import_module(components_package)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/david.crawford/src/galileo-scopes/components/galileo_scope_components/__init__.py", line 10, in <module>
from ._imports_ import *
File "/Users/david.crawford/src/galileo-scopes/components/galileo_scope_components/_imports_.py", line 4, in <module>
from .Cloudview import Cloudview
File "/Users/david.crawford/src/galileo-scopes/components/galileo_scope_components/Cloudview.py", line 35
- lidarLabel (string; optional): Optional label to distinguish lam2 files, e.g. "VIN000_LIDAR_ROOF_LEFT""""
^
SyntaxError: EOL while scanning string literal
Expected behavior
I expect the library to generate valid Python code. In this case I think a newline before the closing quotes (ideally with indentation to match the opening quotes for the docstring) would work.
Screenshots
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with dash.development.component_loader.generate_classes and reproduce the issue using the command in the report. Inspect the generated Cloudview.py docstring when the final React prop comment ends in a double quote; done means the generated Python file has valid syntax and can be imported successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, react
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100