First time here? Check out the FAQ!
1

OS Command to run Ruff not working properly

Wing 10.0.5.0 (rev 99de29d8e60a) on Win 10 and Python 3.11.7/64. I have an OS command to run Ruff:

ruff.exe check --ignore ERA001,T201,I001,T203,D104  ${WING:FILENAME}

When I use the wheel icon, it checks every file in the directory that ${WING:FILENAME} is in. When I open the command properties window and click Test Execute, it only checks ${WING:FILENAME}. I have all the checkboxes ticked on the Definition tab and Environment is default.

Noticed that if I select this cmd, run it, I get the correct output, run it again, correct output. If I run it and click into the output window then run it again, it scans the whole directory (and each time I click the button thereafter). If I select another command, run it then come back to the one I was trying, it works again (until I click into the output).

It used to work (check only the active file) but I can't say how far back since I haven't been doing much Python lately.

RunDeep's avatar
68
RunDeep
asked 2024-07-10 18:14:53 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2024-07-14 07:50:14 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

I think this is due to ${WING:FILENAME} being empty if there is not file at the current focus. That's somewhat of a surprise, in that I thought it was supposed to use current editor regardless of focus. May be a bug and we'll look into it.

However, you can use Ruff with Wing's Code Warnings tool, which would likely be a lot more convenient. Bring up the Code Warnings tool from the Tools menu, change to Configuration: Defaults in the drop down at the top, check on Enable External Checkers and then press Configure next to that to enable Ruff. The default configuration assumes Ruff is installed into the Python env being used by your project. If not, you can change the command line Wing uses.

After that Ruff warnings are included in the Code Warnings tool and warnings drop down at top of the editor, and the location of warnings are indicated on the source code. If you disable a warning, it disables the whole class of warnings as in the --ignore argument, so it's pretty quick to get down to just the warnings that you want, although you can also change the command line in the Ruff config in the Code Warnings tool if you want.

Wingware Support's avatar
4.2k
Wingware Support
answered 2024-07-10 18:40:33 -0600
edit flag offensive 0 remove flag delete link

Comments

Ahh, looks like you are right about it being a focus issue, I had forgotten about that behavior. In the past I recall it would throw an error vs. process the whole directory. I think I like the old behavior better, doing a ruff --fix might be annoying to run on a whole directory unintentionally...

I setup the Code Warnings tool, I kind of like doing a "dev" run where I disable a bunch of cosmetic checks, It looks like I could use the Disabled Warnings config for that too, I'll try both approaches.

RunDeep's avatar RunDeep (2024-07-11 13:34:22 -0600) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer