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

[FURB156] Do not consider docstring(s) #16391

Merged
merged 3 commits into from
Feb 26, 2025
Merged

Conversation

VascoSch92
Copy link
Contributor

The PR solves issue #16351

I wanted to take the definition of docstring from PEP PEP257, but it is quite strict, i.e., docstring are always with triple double quotes.

I relaxed the definition to accomodate also docstring just with double quotes. In this way, the bugs presented in the issue are resolved.

Let me know what you think.

PS: I also mentioned in the description of the rule that the rule doesn't consider docstrings.

Comment on lines 52 to 56
if !matches!(checker.semantic().current_statement(), &Stmt::Assign(_))
&& !matches!(checker.semantic().current_statement(), &Stmt::AugAssign(_))
{
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you can use checker.semantic().in_pep_257_docstring() here instead. This should give us consistent behavior to other rules ignoring docstrings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was that method. The problems with this method are that

"""01234567"""

"01234567"

are not considered as docstrings and marked as violations.

To fix all the issues reported in the issue, I had to use the current condition present in the PR.

But I can change it to if checker.semantic().in_pep_257_docstring() {...} if you want to be consistent between docstrings ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I double checked and just the second string in my above example will be marked as an error as it is not at the top of the module. So it makes sense to use: in_pep_257_docstring().

I will change

Copy link
Contributor

github-actions bot commented Feb 26, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre linked an issue Feb 26, 2025 that may be closed by this pull request
@ntBre ntBre added the bug Something isn't working label Feb 26, 2025
@MichaReiser MichaReiser enabled auto-merge (squash) February 26, 2025 16:26
@MichaReiser MichaReiser merged commit b89d61b into astral-sh:main Feb 26, 2025
20 checks passed
@VascoSch92 VascoSch92 deleted the furb-156 branch February 26, 2025 16:31
dcreager added a commit that referenced this pull request Feb 27, 2025
* main:
  [red-knot] unify LoopState and saved_break_states (#16406)
  [`pylint`] Also reports `case np.nan`/`case math.nan` (`PLW0177`) (#16378)
  [FURB156] Do not consider docstring(s) (#16391)
  Use `is_none_or` in `stdlib-module-shadowing` (#16402)
  [red-knot] Upgrade salsa to include `AtomicPtr` perf improvement (#16398)
  [red-knot] Fix file watching for new non-project files (#16395)
  document MSRV policy (#16384)
  [red-knot] fix non-callable reporting for unions (#16387)
  bump MSRV to 1.83 (#16294)
  Avoid unnecessary info at non-trace server log level (#16389)
  Expand `ruff.configuration` to allow inline config (#16296)
  Start detecting version-related syntax errors in the parser (#16090)
dcreager added a commit that referenced this pull request Feb 27, 2025
* dcreager/dont-have-a-cow:
  [red-knot] unify LoopState and saved_break_states (#16406)
  [`pylint`] Also reports `case np.nan`/`case math.nan` (`PLW0177`) (#16378)
  [FURB156] Do not consider docstring(s) (#16391)
  Use `is_none_or` in `stdlib-module-shadowing` (#16402)
  [red-knot] Upgrade salsa to include `AtomicPtr` perf improvement (#16398)
  [red-knot] Fix file watching for new non-project files (#16395)
  document MSRV policy (#16384)
  [red-knot] fix non-callable reporting for unions (#16387)
  bump MSRV to 1.83 (#16294)
  Avoid unnecessary info at non-trace server log level (#16389)
  Expand `ruff.configuration` to allow inline config (#16296)
  Start detecting version-related syntax errors in the parser (#16090)
dcreager added a commit that referenced this pull request Feb 27, 2025
* main:
  [red-knot] unify LoopState and saved_break_states (#16406)
  [`pylint`] Also reports `case np.nan`/`case math.nan` (`PLW0177`) (#16378)
  [FURB156] Do not consider docstring(s) (#16391)
  Use `is_none_or` in `stdlib-module-shadowing` (#16402)
  [red-knot] Upgrade salsa to include `AtomicPtr` perf improvement (#16398)
  [red-knot] Fix file watching for new non-project files (#16395)
  document MSRV policy (#16384)
  [red-knot] fix non-callable reporting for unions (#16387)
  bump MSRV to 1.83 (#16294)
  Avoid unnecessary info at non-trace server log level (#16389)
  Expand `ruff.configuration` to allow inline config (#16296)
  Start detecting version-related syntax errors in the parser (#16090)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FURB156 should not apply to docstrings
3 participants