Remove the checks to see an object was already created before creating
or obtaining it. This is not necessary as each entire run of `flake8`
calls these methods *only* once.
The `values` parameter is safe to remove since it is not provided as an
argument by any callers and the remaining arguments are guaranteed to
always be provided by all callers.
This commit simplifies and updates the method for handling the creation
of the configuration file finder. The main takeaways are:
- Renaming the parameter (i.e., `extra_config_files`) to be a noun to
better describe the input versus what the option name was called.
- Refreshed the docstring to align with changes from previous commits
and this one.
- Remove the check to see if it a configuration file finder was already
created. This is not necessary as each entire run of a `flake8` calls
this method once. When the programmatic API is provided,
configuration would be provided 'in-code' and not rely upon external
files/resources.
- Use directly the program name from the `Application`, itself since
this is the authoritative source for defining it.
Now that `parse_preliminary_options_and_args()` ignores unknown options
and arguments, forward the remaining unknown arguments to the main CLI
and configuration method to be consumed. This prevents re-parsing the
entire `argv` list again by forwarding the remaining arguments left to
be consumed.
Positional arguments aren't necessary for determining where to
load configuration anymore and is safe to keep both options and
arguments to be forwarded for later parsing after configuration is
loaded.
Now that preliminary options are registered with the preliminary parser
on the `Application`, leverage that for parsing known options.
This important change removes the `Application.option_manager` from
being responsible for pre-configuration parsing and the workarounds
needed in the `Application.parse_preliminary_options_and_args()` to
account for the fact that `Application.option_manager` was aware of
*all* options, not just the options necessary for pre-configuration
loading. A following commit will address removing these workarounds.
We introduce a new `ArgumentParser` for registering the preliminary
options to be inherited by the `Application.option_manager`. The next
step will be to use the `Application.prelim_arg_parser` for parsing and
handling preliminary options and arguments.
Note that we prevent the preliminary parser from handling `-h/--help`
and defer to that to the primary parser.
Allow for including options from parent `argparse.ArgumentParser`
objects in preparation of splitting out the handling of preliminary
options from the `OptionManager`.
The `ConfigFileFinder` doesn't utilize the preliminary arguments (i.e.,
the file names) anymore for computing the starting path for the
configuration file search.
Now that `args` parameters is not being used, it is safe to remove from
the constructor signature.
Further work is required to evaluate and clean-up tearing out the
threading-through of `args` from various callers and tests.
This is the initial incision to only search for configuration relative
to the current working directory where `flake8` is invoked. This brings
configuration file detection closer to other CLI-like programs.