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

B018 complains about f-strings as docstrings... and it's right! (but a more specific message would be helpful) #211

Closed
Zac-HD opened this issue Nov 29, 2021 · 1 comment · Fixed by #230

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Nov 29, 2021

CONSTANT = "magic value"

def f():
    f"""Return {CONSTANT!r}."""  # warning B018
    return CONSTANT

assert f.__doc__ is not None  # fails!

I was originally reporting this as a bug, but it turns out that f-strings don't work as docstrings! IMO this deserves to be split out into a new B019 check with a more specific message.

@cooperlees
Copy link
Collaborator

Nice. Would totally accept this PR if we can cleanly split this error out.

First, we need to workout our long term design with string detection in general for B018 as #208 has identified from the abstract use case sphinx uses and I am sure other edge cases will come up.

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

Successfully merging a pull request may close this issue.

2 participants