Skip to content

[pydoclint] Fix DOC501 panic #12428#12435

Merged
charliermarsh merged 4 commits intoastral-sh:mainfrom
augustelalande:doc501
Jul 21, 2024
Merged

[pydoclint] Fix DOC501 panic #12428#12435
charliermarsh merged 4 commits intoastral-sh:mainfrom
augustelalande:doc501

Conversation

@augustelalande
Copy link
Copy Markdown
Contributor

@augustelalande augustelalande commented Jul 21, 2024

Summary

Fix panic reported in #12428. Where a string would sometimes get split within a character boundary. This bypasses the need to split the string.

This does not guarantee the correct formatting of the docstring, but neither did the previous implementation.

Resolves #12428

Test Plan

Test case added to fixture

Comment thread crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs Outdated
@@ -210,7 +210,7 @@ fn parse_entries_numpy(content: &str) -> Vec<QualifiedName> {
for potential in split {
if let Some(first_char) = potential.chars().nth(indentation) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we use strip_prefix here with the indentation instead of using chars?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok I reimplemented using strip_prefix but I still needed to call chars to check if the first char is_whitepace

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense!

Copy link
Copy Markdown
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Thx!

@charliermarsh charliermarsh added bug Something isn't working fuzzer Surfaced via fuzzing. labels Jul 21, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) July 21, 2024 19:26
@charliermarsh charliermarsh merged commit 3a742c1 into astral-sh:main Jul 21, 2024
@augustelalande augustelalande deleted the doc501 branch July 21, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fuzzer Surfaced via fuzzing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checking file with rule DOC501 cause panic

2 participants