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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

B021: f-string used as docstring. #230

Merged
merged 4 commits into from Mar 20, 2022

Conversation

jpy-git
Copy link
Contributor

@jpy-git jpy-git commented Mar 17, 2022

Closes #211.

The logic for detecting these f-strings intended as docstrings is fairly simple: Check that the first child of the FunctionDef/ClassDef is a JoinedStr.

I've added a working unit test and ran the pre-commit checks but since this is my first contribution here lmk if I've missed anything 馃槃

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small tweak below so that we can detect all the f-string cases, but otherwise looks good to me! @cooperlees?

bugbear.py Outdated Show resolved Hide resolved
jpy-git and others added 2 commits March 19, 2022 22:26
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow - TIL this is even possible. Lets merge this and I'll check other issues + PRs and see if we can cut a new release in the next few days.

@cooperlees cooperlees merged commit c5223e0 into PyCQA:master Mar 20, 2022
@jpy-git jpy-git deleted the b021_fstring_docstrings branch March 20, 2022 19:04
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 this pull request may close these issues.

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