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

How to pass arguments to ruff? #1609

Closed
peakschris opened this issue Jul 11, 2024 · 8 comments
Closed

How to pass arguments to ruff? #1609

peakschris opened this issue Jul 11, 2024 · 8 comments

Comments

@peakschris
Copy link

When run in CI, I need to run the equivalent of 'ruff --output-format=gitlab'. Is there a way to pass this parameter to hatch fmt?

We don't want to use that parameter in normal use, only CI.

Thanks!

@ofek
Copy link
Collaborator

ofek commented Jul 11, 2024

just like other scripts: hatch fmt -- arg1 arg2

@peakschris
Copy link
Author

-- doesn't seem to be working on windows, at least:

>hatch fmt -- --format gitlab
cmd [1] | ruff check --fix --format gitlab
error: unexpected argument '--format' found

  tip: to pass '--format' as a value, use '-- --format'

@peakschris
Copy link
Author

I'm also seeing the same on linux

@ofek
Copy link
Collaborator

ofek commented Jul 11, 2024

This is what's happening under the hood which you can entirely customize.

So either modify the scripts or in CI make it to steps, one for the linter and one for the formatter e.g.: hatch fmt -f -- --format gitlab

@peakschris
Copy link
Author

peakschris commented Jul 11, 2024

Ok, I'll look into customizing the fmt command, thanks.

I'm also having the same -- issue with hatch run. After defining an env named 'check', hatch run isn't passing arguments through. Note, ruff here is not defined as a script in pyproject.toml script, it is the actual ruff command that is being invoked.

[tool.hatch.envs.check]
extra-dependencies = ["ruff", "pyright"]
>hatch run check:ruff -- check . --format=gitlab
error: unexpected argument '--format' found

  tip: to pass '--format' as a value, use '-- --format'

@ofek
Copy link
Collaborator

ofek commented Jul 11, 2024

the check command appears to have no such option, argument passing is working properly

@peakschris
Copy link
Author

Apologies, my error. I was confused by the error message.

@ofek
Copy link
Collaborator

ofek commented Jul 11, 2024

no worries!

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