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

E701 is not listed on the "Conflicting lint rules" page but it conflicts with ruff format when --preview flag is used #8496

Closed
simon-liebehenschel opened this issue Nov 5, 2023 · 3 comments · Fixed by #8499
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@simon-liebehenschel
Copy link

simon-liebehenschel commented Nov 5, 2023

The original code

from contextlib import nullcontext

ctx = nullcontext()
with ctx:
    ...

Steps to reproduce

ruff format --isolated --preview sample.py moves ellipsis:

from contextlib import nullcontext

ctx = nullcontext()
with ctx: ...

and now ruff --isolated --fix --preview sample.py will complain about : and ellipsis on a same line:

sample.py:4:9: E701 Multiple statements on one line (colon)
Found 1 error.

Expected behavior

No conflicts between ruff check and ruff format.

Versions

  • ruff 0.1.4
  • Python 3.11.6

Related

In the comment a developer assumed that E701 is not conflicting https://github.com/astral-sh/ruff/pull/8088/files#r1366486452

@charliermarsh
Copy link
Member

Thanks, it should now be marked as conflicting as of that change to preview style.

@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label Nov 5, 2023
@charliermarsh
Copy link
Member

Actually, I think we should just allow this in E701.

@charliermarsh
Copy link
Member

Oh, we do allow it in some cases (#2837).

@charliermarsh charliermarsh self-assigned this Nov 5, 2023
charliermarsh added a commit that referenced this issue Nov 6, 2023
## Summary

Black and Ruff's preview styles now collapse statements like:

```python
from contextlib import nullcontext

ctx = nullcontext()
with ctx: ...
```

Historically, we made an exception here for classes
(#2837). This PR extends it to
other statement kinds for consistency with the formatter.

Closes #8496.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants