Open sobolevn opened 5 years ago
I would say that something like this should be done:
def safe_literal_eval(node) -> Optional[str]:
try:
return ast.literal_eval(node)
except ValueError:
return None # happens when literal eval cannot process node
And then check that instead of ast.literal_eval
this function is used and None
value is checked.
Docstrings may not be f-strings. So actually the better fix is to specifically look for attempting to use a docstring as an f-string and issue a new error code.
@lordmauve agreed, new rules are always a good idea 🙂
Any progress on this? It's quite puzzling to run into this, because there's no indication on what/where the error is, just a big fat python backtrace.
Just came across this error, since we autogenerate some docstrings with f-strings using a decorator.
I could resolve the issue in our case by using --ignore-decorators
.
pydocstyle <source_dir> --ignore-decorators=<name_of_decorator_gerating_docstring>
Any progress on this? It's quite puzzling to run into this, because there's no indication on what/where the error is, just a big fat python backtrace.
I plan to pick it up and release a fix this weekend :)
I have https://github.com/PyCQA/pydocstyle/pull/381 updated. Waiting for a review so that we can merge it.
Is this bug fixed?
still present
Hi! I am running
pydocstyle
as a part offlake8-docstrings
plugin which is a plugin forwemake-python-styleguide
.Original issue: https://github.com/wemake-services/wemake-python-styleguide/issues/579
One of my users reported this bug:
This happens here: https://github.com/PyCQA/pydocstyle/blob/master/src/pydocstyle/checker.py#L159
Reproduction code: