-
Notifications
You must be signed in to change notification settings - Fork 56
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
Darker running with --diff and --quiet on VSCode #147
Comments
I haven't found a way to prevent VSCode from adding the Why do you want to run Darker without |
@akaihola I want to run without those 2 args because with them VSCode doesn't format the file for me and it also don't display what's wrong. So, it runs behind the scenes because I confirm that with the console opened but doesn't do anything else. If I close the console, I don't know what happened. |
So it's for debugging purposes to find out why Darker won't format the file? The Below are some suggestions to help you debug the problem. Please try them out and see which ones work and which fail. If these don't help you solve the problem, please describe in detail
Thanks! 1. Try formatting a simple file which is valid PythonDoes VSCode format a file which you know to be valid? E.g. import os
print ( os.listdir() ) If you reformat that in VSCode using Darker, does it fix the formatting? If yes, then your problem is probably that the file you're trying to format has a syntax error. 2. Try formatting your problematic file in VSCode using Blacki.e. enter the path to 3. Try formatting the file on the command line with Darker
If that doesn't work, try with more verbosity by adding 4. Try formatting the file on the command line with Black
|
@akaihola Thanks for the explanation and support. So, I've tried the ways you mentioned and below you can see my findings. The idea behind this is so I can have the same behaviour on my editor that I'd get on the terminal. I'm not sure if it's really for debugging but more to speed up my productivity. 1. Try formatting a simple file which is valid Python
2. Try formatting your problematic file in VSCode using Black 3. Try formatting the file on the command line with Darker
4. Try formatting the file on the command line with Black |
Also, one thing I realised is that |
@akaihola It seems to be working now. I found that my configuration on the |
Yes, the I guess what VSCode does is it quotes each "Black Args" item which contains spaces and treats it as one command line argument. So this won't work: "python.formatting.blackArgs": [
"--lint pylint"
], but this will: "python.formatting.blackArgs": [
"--lint",
"pylint"
], as well as this: "python.formatting.blackArgs": [
"--lint=pylint"
], I would assume Python's argparse understands The surprising thing is, for me
Could you try that out? I'm curious why Darker might ignore the unknown argument on some platforms/versions but not on others. |
@akaihola I've tried |
So what happens with |
@akaihola For me is the same. Nothing happen actually. No errors but no linting as well. |
Ah, what actually happens is that Darker interprets "--lint pylint" as a file path. If you run If anything, we could throw an error from Darker for any file names beginning with a dash. Is it a safe assumption that no Python source file or directory name could ever start with |
@akaihola I think it's a safe assumption. Throwing an error would be a good idea I think |
Disallow paths starting with a hyphen - those are probably due to quoting multiple arguments like "--lint pylint". Fixes #147.
@hlrossato I'm working on this in #163. Would you like to be invited as a collaborator on this repository and review the pull request? |
Disallow paths starting with a hyphen - those are probably due to quoting multiple arguments like "--lint pylint". Fixes #147.
Disallow paths starting with a hyphen - those are probably due to quoting multiple arguments like "--lint pylint". Fixes #147.
Disallow paths starting with a hyphen - those are probably due to quoting multiple arguments like "--lint pylint". Fixes #147.
Disallow paths starting with a hyphen - those are probably due to quoting multiple arguments like "--lint pylint". Fixes #147.
I've set up darker on VSCode the way it says on the tutorial but even if I don't pass
--diff
the command stills run with--diff
and--quiet
. I've seen there's a PR open for that but I also would like to know if it's possible to run the command without--diff
and--quiet
explicitly. ThanksThe text was updated successfully, but these errors were encountered: