Closed peterjc closed 5 years ago
What do you think @098799 ?
From what I see in my debugger, if you leave black-config =
with empty string, you get options.black_config
to be equal to empty string, while if you leave no option specified, you get the default specified in add_options()
. I see that you've changed the default to empty string -- in this case indeed there's no difference, but if you stayed with None
, you can leverage that to see if the user added black-config =
or not.
I had tried None
but it seemed to turn into empty string anyway
[flake8]
black-config =
produces:
ipdb> options.black_config
''
ipdb> options.black_config is None
False
while
[flake8]
produces
ipdb> options.black_config
ipdb> options.black_config is None
True
Btw. setting it to empty string as in:
[flake8]
black-config = ''
generates yet another result:
ipdb> options.black_config
"''"
(I'm debugging inside parse_options
and using my branch)
Does including normalize_paths=True
change things?
I'm not sure how to make it work. The only example I found (for "--exclude") was a comma_separated_list option. If I use it, e.g.
parser.add_option(
"--black-config",
default="",
comma_separated_list=True,
parse_from_config=True,
normalize_paths=True,
help=(
"Path to black configuration file"
"(overrides the default pyproject.toml)"
),
)
(doesn't matter what I put in default
, can be ""
, []
and None
) I get the same empty list whether or not I define black-config =
or not.
The big difference with normalize_paths=True
is that if I set a relative path, it will normalize it to absolute relative to the place where flake8 command was executed, which is what we've rejected at the beginning of my PR.
That result with normalize_paths=True
sounds like it should become a flake8 bug report, especially in the light of https://gitlab.com/pycqa/flake8/issues/561
And probably I am making life too complicated by trying to support a --black-config ...
way to say ignore all the possible TOML files. I'll take another stab at this tomorrow.
Your input has been valuable, thank you.
Solved the default value None
vs empty string problem by removing type="string",
which was turning a default None
value into an empty string.
Another attempt pending...
(Re-submission of #14)
Builds on #11, adds new
BLK997
if apyproject.toml
file is invalid, allows usingflake8 --black-config '-' ...
to mean ignore anypyproject.toml
file.Adds explicit failure during configuration parsing for specified TOML file missing (#12) or invalid, although currently an ugly traceback.