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

Rules D204 cause autofix error #7088

Closed
qarmin opened this issue Sep 3, 2023 · 0 comments · Fixed by #7174
Closed

Rules D204 cause autofix error #7088

qarmin opened this issue Sep 3, 2023 · 0 comments · Fixed by #7174
Assignees
Labels
bug Something isn't working fuzzer Surfaced via fuzzing.

Comments

@qarmin
Copy link

qarmin commented Sep 3, 2023

Ruff 0.0.287 (latest changes from main branch)

ruff  *.py --select D204 --no-cache --fix

file content(at least simple cpython script shows that this is valid python file):

class ServiceSorter(ABC):
	def sort_services(self,services):0
class DefaultPrioritySorter(ServiceSorter):
	'Default service sorting approach that always give S3 the highest priority.';priorities={'s3':100,'lambda':1}
	def sort_services(A,services):return sorted(services,key=lambda k:A.priorities.get(k,0),reverse=True)

error

/home/rafal/test/tmp_folder/39521.py:4:2: D204 1 blank line required after class docstring
Found 1 error.

error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in `ruff`. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/39521.py`, the rule codes D204, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!


python_compressed.zip

@zanieb zanieb added the fuzzer Surfaced via fuzzing. label Sep 3, 2023
@charliermarsh charliermarsh added the bug Something isn't working label Sep 3, 2023
@konstin konstin self-assigned this Sep 5, 2023
konstin added a commit that referenced this issue Sep 11, 2023
## Summary

Another statement on the same line as the docstring would previous make
the D204 (newline after docstring) fix fail:

```python
class StatementOnSameLineAsDocstring:
    "After this docstring there's another statement on the same line separated by a semicolon." ;priorities=1
    def sort_services(self):
        pass
```

The fix handles this case manually:

```python
class StatementOnSameLineAsDocstring:
    "After this docstring there's another statement on the same line separated by a semicolon."

    priorities=1
    def sort_services(self):
        pass
```

Fixes #7088

## Test Plan

Added a new `D` test case
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 a pull request may close this issue.

4 participants