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

Allow ruff to be used as a formatter #216

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DarkaMaul
Copy link

Until astral-sh/ruff#659 is implemented, it could still be helpful to use ruff to format the signatures.

Feel free to close the PR if you believe the perf impact is too big when spanning multiple subprocesses.

@pawamoy
Copy link
Member

pawamoy commented Dec 13, 2024

Thanks! I tried it in a project that renders quite a lot of docstrings, and I don't see any flagrant perf hit.

@pawamoy
Copy link
Member

pawamoy commented Dec 13, 2024

Thanks! I tried it in a project that renders quite a lot of docstrings, and I don't see any flagrant perf hit.

Something might be missing though: the signatures aren't actually formatted 😅 Does it work on your side?

@pawamoy
Copy link
Member

pawamoy commented Dec 13, 2024

Once I add and use the _find_ruff util, I then get this process error:

CalledProcessError(2, ['/media/data/dev/griffe/.venv/bin/ruff', 'format', '--config "line-length=60"', '--stdin-filename', 'file.py', '-'])

Its stderr is:

'error: unexpected argument '--config "line-length' found\n\n tip: a similar argument exists: '--config'\n\nUsage: ruff format --config <CONFIG_OPTION> [FILES]...\n\nFor more information, try '--help'.\n'

I guess we simply have to split that.

@pawamoy
Copy link
Member

pawamoy commented Dec 13, 2024

OK working with the suggestion above. Let me re-check the perfs. UPDATE: same, no perf hit.

@DarkaMaul
Copy link
Author

Before merging the PR (if that goes through), the documentation needs to be updated (and some of the docstrings) to reflect that now it can also use ruff when black is not found.

docs/schema.json Outdated Show resolved Hide resolved
@DarkaMaul DarkaMaul force-pushed the dm/add-ruff-formatter branch from d86eb0e to 4fc2f4a Compare December 16, 2024 13:20
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

Successfully merging this pull request may close these issues.

2 participants