Commit graph

1828 commits

Author SHA1 Message Date
Eric N. Vander Weele
b54164f916 application: Remove preliminary argument parsing state
The preliminary options and arguments returned from
`.parse_preliminary_options_and_args()` are now all threaded through to
the appropriate methods during initialization.
2019-10-01 08:48:18 +02:00
Eric N. Vander Weele
95a88e3fcd application: Pass prelim opts to .find_plugins()
The configuration file and boolean to ignore configuration files can be
threaded through now that `.parse_preliminary_options_and_args()`
returns options and arguments.
2019-10-01 08:48:18 +02:00
Eric N. Vander Weele
32ebb4fa55 application: Pass prelim opts and args to .make_config_finder()
Now that `.parse_preliminary_options_and_args()` returns options and
arguments, the boolean for appending configuration and the arguments can
be threaded through to the creation of the `ConfigFileFinder`.
2019-10-01 08:48:18 +02:00
Eric N. Vander Weele
55ef2c6f5e application: Pass returned prelim options to .configure_logging()
The verbosity and output file options can be obtained from options
returned by `.parse_preliminary_options_and_args()`, instead of state
from the `Application` object.
2019-10-01 08:48:18 +02:00
Eric N. Vander Weele
6043e90855 application: Return namespace and args from preliminary arg parsing
This is the initial step towards removing state from the `Application`
object during argument parsing and handling.  The goal is to remove
`Application.prelim_opts` and `Application.prelim_args`.
2019-10-01 08:48:18 +02:00
Ian Stapleton Cordasco
6bae5f7ef6 Merge branch 'remove_E101_indent_char_resetting' into 'master'
Don't reset indent_char when we encounter E101

See merge request pycqa/flake8!357
2019-09-25 23:42:44 +00:00
Anthony Sottile
fdcec2803a Don't reset indent_char when we encounter E101 2019-09-24 13:54:32 -07:00
Anthony Sottile
121ea4f056 Merge branch 'whitespace_fixers' into 'master'
Add whitespace fixers

See merge request pycqa/flake8!355
2019-09-08 06:53:48 +00:00
Anthony Sottile
e42884cf60 Add whitespace fixers 2019-09-07 23:49:47 -07:00
Anthony Sottile
5cce7c2cc3 Merge branch 'type_more' into 'master'
Add more type annotations

See merge request pycqa/flake8!353
2019-09-08 06:45:41 +00:00
Anthony Sottile
2c7b550d23 Merge branch 'disable_assert_nosec' into 'master'
Simplify bandit config and allow `assert`

See merge request pycqa/flake8!354
2019-09-08 06:45:08 +00:00
Anthony Sottile
f0cd1537ac Simplify bandit config and allow assert 2019-09-07 23:42:33 -07:00
Anthony Sottile
92fbdda253 Add type annotations for flake8.processor 2019-09-07 23:31:43 -07:00
Anthony Sottile
ae2f38fbeb Add type annotations to flake8.styleguide 2019-09-07 23:10:28 -07:00
Anthony Sottile
a13f02a386 Merge branch 'type_annotate_option_manager' into 'master'
Type annotate flake8.options.manager

See merge request pycqa/flake8!352
2019-09-07 21:51:05 +00:00
Anthony Sottile
8c4e42afaa Type annotate flake8.options.manager 2019-09-07 14:37:50 -07:00
Anthony Sottile
8cd1e0ecc7 Merge branch 'optmgr-parse-args-default-values' into 'master'
Set configuration file-provided values via ArgumentParser.set_defaults()

See merge request pycqa/flake8!350
2019-08-31 04:15:30 +00:00
Eric N. Vander Weele
aadd09dd8b Set configuration file-provided values via ArgumentParser.set_defaults()
When calling `ArgumentParser.parse_args()` with the `namespace`
argument, command-line options are just added to the  namespace without
going through any of the argument parsing and type conversion logic
(e.g., the `type` keyword argument of `ArgumentParser.add_argument()`).
In other words, it is assumed that a namespace is well-formed from a
previous invocation of `ArgumentParser.parse_args()`.

The `values` parameter is intended to be values already-provided from
configuration files.  To take advantage of the logic defined by
`ArgumentParser.add_argument()`,  utilize
`ArgumentParser.set_defaults()` instead.
2019-08-31 00:10:46 -04:00
Eric N. Vander Weele
b231c10016 Test default provided options are forwarded
Ensure options provided external to the command-line (i.e.,
configuration files) are present in the final result of options.
2019-08-31 00:10:46 -04:00
Eric N. Vander Weele
ec8fcfc8f8 Add typing to OptionManager.parse_args()
Note that the `assert` is necessary to "cast" `self.parser` since it is
specified as a `Union`.
2019-08-31 00:10:40 -04:00
Anthony Sottile
eee53d9440 Merge branch 'type-parse-known-args' into 'master'
Add typing to `OptionManager.parse_known_args()`

See merge request pycqa/flake8!348
2019-08-30 18:25:23 +00:00
Eric N. Vander Weele
8ea3c6321d Add typing to OptionManager.parse_known_args()
Note that type casting is necessary given that `self.parser` is
annotated as a `Union`.
2019-08-30 14:17:20 -04:00
Anthony Sottile
c185a2fe6a Merge branch 'remove-parse-known-args-value' into 'master'
Remove unused parameter from `OptionManager.parse_known_args()`

See merge request pycqa/flake8!347
2019-08-30 16:36:52 +00:00
Eric N. Vander Weele
220a9287f5 Remove unused parameter from OptionManager.parse_known_args()
The `values` parameter is not utilized anywhere and can be safely
removed.
2019-08-30 12:30:33 -04:00
Anthony Sottile
a649019c2e Merge branch 'type-config-file-finder' into 'master'
Add typings to ConfigFileFinder constructor

See merge request pycqa/flake8!346
2019-08-29 20:40:41 +00:00
Eric N. Vander Weele
c2216c0ddf Add typings to ConfigFileFinder constructor
`OptionManager.parse_known_args()` is guaranteed to return a list of
remaining argument strings.
2019-08-29 16:36:47 -04:00
Anthony Sottile
5144196abd Do not pass noqa to plugins, have flake8 decide whether to report 2019-08-29 13:14:12 -07:00
Anthony Sottile
45ad2faf8f Merge branch 'hoist-argv' into 'master'
Hoist passing through sys.argv at the CLI layer

See merge request pycqa/flake8!345
2019-08-29 20:09:47 +00:00
Eric N. Vander Weele
cf4bc53c12 Hoist passing through sys.argv at the CLI layer
`flake8.main.cli.main()` is the primary entry point for the command-line
implementation of flake8 (invoked via `__main__` or `console_scripts`).
Therefore, it is reasonable for the entry point to be responsible for
obtaining command line arguments from `sys.argv` there.

Note that `sys.argv[1:]` is necessary in order to strip off the script
name.  Formerly, this was not needed in
`Application.parse_preliminary_options_and_args()`, which was using
`sys.argv[:]` because the result of the argument parsing was just for
determining additional configuration to be loaded.  Then, the *real* CLI
argument parsing was forwarding the original `None` value to
`argparse.ArgumentParser.parse_args()`, which internally was obtaining
arguments as `sys.argv[1:]`.

Additionally, the contract for various argument parsing methods to be
guaranteed a `List[str]`.
2019-08-29 16:06:02 -04:00
Anthony Sottile
8b34b334fa Merge branch 'revert-6a70aaae' into 'master'
Revert "Merge branch 'hoist-argv' into 'master'"

See merge request pycqa/flake8!344
2019-08-28 23:21:04 +00:00
Anthony Sottile
b41d983f04 Revert "Merge branch 'hoist-argv' into 'master'"
This reverts merge request !343
2019-08-28 23:16:20 +00:00
Anthony Sottile
6a70aaae7f Merge branch 'hoist-argv' into 'master'
Hoist passing through sys.argv at the CLI layer

See merge request pycqa/flake8!343
2019-08-28 23:08:45 +00:00
Eric N. Vander Weele
50ac2f7237 Hoist passing through sys.argv at the CLI layer
`flake8.main.cli.main()` is the primary entry point for the command-line
implementation of flake8 (invoked via `__main__` or `console_scripts`).
Therefore, it is reasonable for the entry point to be responsible for
obtaining command line arguments from `sys.argv` there.

Additionally, the contract for various argument parsing methods to be
guaranteed a `List[str]`.
2019-08-28 17:51:33 -04:00
Anthony Sottile
7708e5b4ab Merge branch 'plugin_argparse_groups' into 'master'
Put plugin options into separate argparse groups

Closes #565

See merge request pycqa/flake8!342
2019-08-19 23:13:54 +00:00
Anthony Sottile
8fd36ba15b Put plugin options into separate argparse groups 2019-08-19 15:58:34 -07:00
Anthony Sottile
f265b2275b Merge branch 'argparse' into 'master'
move from optparse to argparse

See merge request pycqa/flake8!341
2019-08-18 22:08:13 +00:00
Anthony Sottile
76515bbb8e Apply suggestion to src/flake8/formatting/base.py 2019-08-18 22:05:00 +00:00
Anthony Sottile
b66ebd7034 move from optparse to argparse 2019-08-17 20:09:45 -07:00
Anthony Sottile
9c18aaedb4 Merge branch 'fix_travis2' into 'master'
Fix travis-ci

See merge request pycqa/flake8!340
2019-08-11 00:08:36 +00:00
Anthony Sottile
554e91fdb0 Fix travis-ci 2019-08-10 13:14:52 -07:00
Anthony Sottile
03cb85f556 Merge branch 'show_source_with_tabs' into 'master'
Fix --show-source when indented with tabs

Closes #563

See merge request pycqa/flake8!339
2019-08-10 18:44:04 +00:00
Anthony Sottile
e8c79dcd33 Fix --show-source when indented with tabs 2019-08-10 11:37:01 -07:00
Anthony Sottile
d43d498d41 Merge branch 'doc_conf_priority' into 'master'
Document priority of configuration files and command line

Closes #560

See merge request pycqa/flake8!336
2019-08-07 13:00:58 +00:00
peterjc
9e97143e49 Document priority of configuration files and command line
Closes issue 560.
2019-08-07 10:31:14 +01:00
Anthony Sottile
d9a4547487 Merge branch 'remove_pydocstyle_workaround' into 'master'
Remove workaround for broken pydocstyle / flake8-docstrings

See merge request pycqa/flake8!335
2019-08-02 18:05:57 +00:00
Anthony Sottile
3d1069a397 Remove workaround for broken pydocstyle / flake8-docstrings 2019-08-02 10:57:15 -07:00
Anthony Sottile
4b7208936a Merge branch 'deprecate_setuptools_command' into 'master'
Deprecate the flake8 setuptools integration

Closes #544

See merge request pycqa/flake8!330
2019-08-01 21:26:24 +00:00
Anthony Sottile
e8de432f8e Merge branch 'simplify-normalize-paths' into 'master'
Hoist comma-separated string parsing out of path normalization

See merge request pycqa/flake8!334
2019-07-28 14:48:47 +00:00
Eric N. Vander Weele
1757bce321 utils: Tighten parse_comma_separated_list() contract further
Now that callers are ensuring that `value` is not `None`, we can further
tighten the contract and remove the conditional to account when `None`
is passed-in for `value`.

Additionally, add a new test vector to account for when an empty string
is passed in, which would fail `if no value`.
2019-07-28 10:43:06 -04:00
Eric N. Vander Weele
f01011a403 Normalize option values additionally by type
Now that the contract has narrowed for `utils.normalize_paths()`
and `utils.parse_comma_separated_list()`, `Option.normalize()` must
handle when the option value is either a singular value or a sequence
(i.e., `list`) of values.

The paths where `Option.normalize()` is called are:

1. options/config.py: `MergedConfigParser.parse_*_config()`
    There are 3 paths wehre eventually `_normalize_value()` is called.
2. options/manager.py: `OptionManager.parse_args()`

For (1), values are coming from the `configparser` module.  For (2),
values are coming from `optparse.OptionParser`.

Rudimentary investigation seems to implicate that
`optparse.OptionParser.parse_args()` always returns values in a `list`
because it accumulates values.  However, for `configparser`, the values
are a string due to the key-value nature of the INI format.

Given that `Option.normalize()` is the convergence point where
normalization of an option occurs, it is acceptable for the method to
also handle the parsing comma-separated values and path normalization by
the option value's type.
2019-07-28 10:43:06 -04:00