Open Avasam opened 6 days ago
Thanks. We're aware of the deviation with preview=False
but the way this gets formatted with preview=True
is rather bad
class Polygon:
def cut_section(
self, line
) -> tuple[
RegularPolygon
| Polygon
| Triangle
| Point
| Point2D
| Point3D
| Segment2D
| Segment3D
| Segment
| None,
RegularPolygon
| Polygon
| Triangle
| Point
| Point2D
| Point3D
| Segment2D
| Segment3D
| Segment
| None,
]: ...
Interestingly, prettier does the exact same playground
This is similar to https://github.com/astral-sh/ruff/issues/11791, but for return type annotations rather than variable annotations.
With
preview = True
:Black:
Ruff:
See https://github.com/microsoft/python-type-stubs/commit/9eb6bb50ec2d16eccde13e8d51fc03f11a7c0807 for a lot more examples
As an added note, with
preview = False
, I also get the following deviation:Black:
Ruff:
The command you invoked (e.g.,
ruff /path/to/file.py --fix
), ideally including the--isolated
flag.ruff format
The current Ruff settings (any relevant sections from your
pyproject.toml
).ruff --version
).ruff 0.7.2