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

feature request: print ruff config #3177

Closed
upstartjohnvandivier opened this issue Feb 23, 2023 · 6 comments
Closed

feature request: print ruff config #3177

upstartjohnvandivier opened this issue Feb 23, 2023 · 6 comments
Labels
question Asking for support or clarification

Comments

@upstartjohnvandivier
Copy link

as a developer, I'd like the ability to print the ruff config so that I can better troubleshoot whether an issue is a local config issue or a geniune bug in ruff

related issue where I ran into this troubleshooting limitation: #3174

I have no particular opinion on the cli command syntax but let me propose a new ruff log config command for now

This command would print the config path used (whether pyproject.toml or something else), the python target version, selected rulesets, ignored rule information, and all of the other content that would normally be written inside the config file

this feature should also be documented clearly within https://beta.ruff.rs/docs/configuration/

possibly this print command could be added to the github ruff issue template as it will also probably assist in issue resolution

thanks!

@charliermarsh
Copy link
Member

Can you try ruff --show-settings foo.py? It needs some cleaning up but it should include everything you've described.

@charliermarsh charliermarsh added the question Asking for support or clarification label Feb 23, 2023
@upstartjohnvandivier
Copy link
Author

upstartjohnvandivier commented Feb 23, 2023

This works! actually it's perhaps too verbose, including formatting and values not optimized for quick developer troubleshooting, like:

                    LiteralStrategy(
                        {
                            [
                                46,
                                98,
                                122,
                                114,
                            ]: [

I would add that I didn't see the source file used to generate the config, but it seems consistent with my pyproject.toml and specifies target_version: Py37 as I expect

I also now see this flag (--show-settings) documented under ruff help check

I think I passed over it because I was looking for a substring like config* rather than settings

I also see this flag is enabled at the top level but not mentioned under the top level info at ruff help

overall, it seems my concern is basically handled and this issue can be closed. optionally, we can enhance some of those points above which are basically nits

3 optional nits recap:

  1. enhance ruff help
  2. --show-config as an alias for --show-settings
  3. rework printed content for ruff --show-settings . to be a bit easier to read: rm json formatting, hide low level numerical values behind a verbose flag, and/or add sourcefile for config gen

@charliermarsh
Copy link
Member

Yeah we used to manually omit some of that LiteralStrategy stuff but it was kind of a pain.

@charliermarsh
Copy link
Member

I thought we did show where the config came from but doesn't look like it.

@charliermarsh
Copy link
Member

Let's leave this open since there are a few things to improve here. We can't really change ruff help, since ruff --show-settings /path/to/file.py only works for historical reasons. We didn't used to have multiple subcommands, but then we moved linting to ruff check. For backwards compatibility, we treat ruff check as the "default" subcommand. It's a little hacky, but it does work.

@charliermarsh
Copy link
Member

Fixed one of these issues, tracking the other in #3202.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

2 participants