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

Is it possible for ruff to preserve the multi-line list comprehension for readability? #12686

Closed
jd-solanki opened this issue Aug 5, 2024 · 1 comment

Comments

@jd-solanki
Copy link

Hi 👋🏻

Big fan of Ruff & Sister projects ❤️

Can we preserve the multi-line list comprehension for readability?

    return [
        data
        for data in sku_data
        if data.date >= today.replace(month=today.month - duration_in_months)
    ]

With ruff it's get formatted in single line:

return [data for data in sku_data if data.date >= today.replace(month=today.month - duration_in_months)]

My ruff config:

# Docs: https://docs.astral.sh/ruff/settings/
select = ["ALL"]
fix = true
target-version = "py312"
line-length = 120

ignore = [
    "D101",   # Missing docstring in public class
    "D104",   # Missing docstring in public package
    "D100",   # Missing docstring in public module
    "ANN201", # Missing return type annotation for public function `get_db`
    "D103",   # Missing docstring in public function
    "INP001", # File `X` is part of an implicit namespace package. Add an `__init__.py`.
    "D102",   # Missing docstring in public method
    "D107",   # Missing docstring in `__init__`
    "ANN101", # Missing type annotation for `self` in method
    "D106",   # Missing docstring in public nested class
    "ERA001", # Found commented-out code
    "T201",   # `print` found

    # Comments
    "TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
    "TD003", # Missing issue link on the line following this TODO

    # FastAPI only
    "B008", # Do not perform function call `Depends` in argument defaults
]
[extend-per-file-ignores]
"tests/**" = ["S101", "PLR2004"]

[format]
skip-magic-trailing-comma = false
@MichaReiser
Copy link
Member

Thanks for the kind words and reporting the improvement.

This has come up before. I'll merge the issue into #11753

@MichaReiser MichaReiser closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants