Open paisleyrob opened 1 year ago
In the flake8 source options/parse_args.py
:
args0, rest = prelim_parser.parse_known_args(argv)
# XXX (ericvw): Special case "forwarding" the output file option so
# that it can be reparsed again for the BaseFormatter.filename.
if args0.output_file:
rest.extend(("--output-file", args0.output_file))
This basically captures the --output-file
filename section for use locally, and re-appends it to the argument list so that it gets parsed later on by the main argument parser. Unfortunately, this puts it after the --
so the main argument parser sees it as a filename.
do you need --
? I'm not sure that's documented and may have only worked by accident
It's used to ensure that later on filenames that start with --
aren't accidentally used as options.
For example: rm -i *
works perfectly to ask about each file unless one of those files is named -f
. It's a very common idiom. Here's it's reference on Wikipedia: https://en.wikipedia.org/wiki/Command-line_interface#Arguments (It's down a bit from that section)
Two hyphen-minus characters without following letters (--) may indicate that the remaining arguments should not be treated as options, which is useful for example if a file name itself begins with a hyphen, or if further arguments are meant for an inner command (e.g., sudo).
do you have files starting with -
? I'm well aware of the point of --
but I don't think you need it
We have general purpose CI scripts that apply across projects company-wide. We harden those scripts against what projects might do to reduce the support burden.
As an aside: python3 -- --perfectly-valid-file-name.py
works.
again, I'm well aware of the use of --
-- my assertion is that you don't need it and that you're defending against an impossible situation
Will a Pull Request that fixes the issue be accepted?
I also can't reproduce your findings in 5.0.4 -- it also failed there too so there must be something you're not showing
I also kinda want to remove --output-file
and --tee
since you can just use >
and / or tee
directly
I also can't reproduce your findings in 5.0.4 -- it also failed there too so there must be something you're not showing
My mistake, the previous CI was using 3.7.9
I also kinda want to remove
--output-file
and--tee
since you can just use>
and / ortee
directly
Removing the options seem fine to me, though it triggers a major version change. :shrug:
I also kinda want to remove
--output-file
and--tee
since you can just use>
and / ortee
directly
I believe the justification was "Windows" and tox but with WSL and other options, I'm less and less worried about this working in cmd.exe
etc. If context is worth anything, --output-file
came first primarily because of tox
and wanting to have a way to store output in a file since >
doesn't work in tox. Then people wanted both to use that and see the output so --tee
was introduced as a way to allow for that since it seemed reasonable.
I haven't ever needed flake8
in tox to put things in a file, but perhaps tox no longer has that limitation. :shrug:
cmd.exe
has >
so it was maybe just tox (which if I need shell things I'd usually just to {toxinidir}/program
and put the more complicated logic there 🤷
how did you install flake8?
unmodified output of
flake8 --bug-report
describe the problem
I've been using
flake8
in a CI environment called with something like:find . -name '*.py' -print0 | xargs -0 flake --output-file output.txt --tee --
When upgrading to v6.0.0 I got errors from the above command. It appears to be some interaction between
--output-file
and--tee
.This sequence sums up the issue pretty well. If you use the
--
which indicates no further arguments it fails to operate properly. I expected the last two commands to behave the same.