Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about invalid string type for docstring #1603

Closed
orsinium opened this issue Sep 14, 2020 · 1 comment
Closed

Warn about invalid string type for docstring #1603

orsinium opened this issue Sep 14, 2020 · 1 comment
Labels
rule request Adding a new rule

Comments

@orsinium
Copy link
Collaborator

orsinium commented Sep 14, 2020

Rule request

Thesis

F-strings and bytes cannot be used as a docstring (raw strings is ok). For example:

def ab(a, b):
  f"""oh hi
  """
  return a+b

In the example above, neither inspect.getdoc nor ast.get_docstring will interpret the f-string as a docstring.

Also, get_docstring is a good reference for the check implementation: https://github.com/python/cpython/blob/3.8/Lib/ast.py#L236-L259

Reasoning

It's a bug. Once I tried to use an f-string-based docstring to reuse something inside because we use docstrings to generate OpenAPI spec. Turned out it doesn't work.

@orsinium orsinium added the rule request Adding a new rule label Sep 14, 2020
@sobolevn
Copy link
Member

This is a duplicate of PyCQA/pydocstyle#381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule request Adding a new rule
Projects
None yet
Development

No branches or pull requests

2 participants