Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PyCQA/flake8
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.7.9
Choose a base ref
...
head repository: PyCQA/flake8
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.8.0
Choose a head ref

Commits on Mar 19, 2019

  1. Copy the full SHA
    6fb49b2 View commit details

Commits on Jul 8, 2019

  1. Merge branch 'master' into 'master'

    Remove filter by filename in utils.filenames_from
    
    Closes #382
    
    See merge request pycqa/flake8!311
    asottile committed Jul 8, 2019
    Copy the full SHA
    0d72470 View commit details
  2. support extend-exclude Fixes #535

    graingert authored and asottile committed Jul 8, 2019
    Copy the full SHA
    9ba6677 View commit details
  3. Merge branch 'extend-exclude' into 'master'

    support extend-exclude Fixes #535
    
    Closes #535
    
    See merge request pycqa/flake8!315
    asottile committed Jul 8, 2019
    Copy the full SHA
    65262dc View commit details
  4. Move setup metadata to setup.cfg

    suryasr007 authored and asottile committed Jul 8, 2019
    Copy the full SHA
    3397a94 View commit details
  5. Merge branch 'dev' into 'master'

    Move setup metadata to setup.cfg
    
    Closes #487
    
    See merge request pycqa/flake8!325
    asottile committed Jul 8, 2019
    Copy the full SHA
    f00d483 View commit details
  6. Copy the full SHA
    d4b0073 View commit details
  7. Merge branch 'fix_appveyor' into 'master'

    Fix / improve recently merged patches + CI
    
    See merge request pycqa/flake8!329
    asottile committed Jul 8, 2019
    Copy the full SHA
    4a52c99 View commit details
  8. Copy the full SHA
    77abc11 View commit details

Commits on Jul 19, 2019

  1. Fix incorrect error string in documentation

    In merge request !300 the description of F631 was accidentally used for
    F633.
    Anthchirp committed Jul 19, 2019
    Copy the full SHA
    ce26d89 View commit details
  2. Merge branch 'F633' into 'master'

    Fix incorrect error string in documentation
    
    See merge request pycqa/flake8!332
    asottile committed Jul 19, 2019
    Copy the full SHA
    ace069c View commit details

Commits on Jul 23, 2019

  1. Push down extra config file path normalization into main config handling

    Move the path normalization for extra configuration file paths down into
    the main `config` module where other path normalization occurs.
    
    This also guarantees that the call to `utils.normalize_paths()` is given
    a sequence, instead of a potential `None` value.
    ericvw committed Jul 23, 2019
    Copy the full SHA
    95f26d7 View commit details
  2. Merge branch 'extra-config-normalization' into 'master'

    Push down extra config file path normalization into main config handling
    
    See merge request pycqa/flake8!333
    asottile committed Jul 23, 2019
    Copy the full SHA
    862b17d View commit details

Commits on Jul 28, 2019

  1. utils: Assert desired contract for parse_comma_separated_list()

    This is a separate commit so it can be dropped during a rebase or
    reverted independently.
    ericvw committed Jul 28, 2019
    Copy the full SHA
    9fbaf2d View commit details
  2. utils: Change parse_comma_separated_list() contract

    This is the initial incision point to only accept `str` (or `None`) for
    parsing out comma/whitespace/regexp separated values.
    ericvw committed Jul 28, 2019
    Copy the full SHA
    9283f2f View commit details
  3. utils: Assert desired contract for normalize_paths()

    This is a separate commit so it can be dropped during a rebase or revert
    independently.
    ericvw committed Jul 28, 2019
    Copy the full SHA
    a0cd55f View commit details
  4. utils: Change normalize_paths() contract

    The `normalize_paths()` utility was doing too much — parsing
    unstructured configuration path data and dispatching the scrubbed paths
    to be normalized.
    
    Towards moving the parsing of unstructured configuration path data
    closer towards were configuration occurs, have the utility accept only
    structured input for normalizing paths.
    ericvw committed Jul 28, 2019
    Copy the full SHA
    1ba56b9 View commit details
  5. 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.
    ericvw committed Jul 28, 2019
    Copy the full SHA
    f01011a View commit details
  6. 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`.
    ericvw committed Jul 28, 2019
    Copy the full SHA
    1757bce View commit details
  7. Merge branch 'simplify-normalize-paths' into 'master'

    Hoist comma-separated string parsing out of path normalization
    
    See merge request pycqa/flake8!334
    asottile committed Jul 28, 2019
    Copy the full SHA
    e8de432 View commit details

Commits on Aug 1, 2019

  1. Merge branch 'deprecate_setuptools_command' into 'master'

    Deprecate the flake8 setuptools integration
    
    Closes #544
    
    See merge request pycqa/flake8!330
    asottile committed Aug 1, 2019
    Copy the full SHA
    4b72089 View commit details

Commits on Aug 2, 2019

  1. Copy the full SHA
    3d1069a View commit details
  2. Merge branch 'remove_pydocstyle_workaround' into 'master'

    Remove workaround for broken pydocstyle / flake8-docstrings
    
    See merge request pycqa/flake8!335
    asottile committed Aug 2, 2019
    Copy the full SHA
    d9a4547 View commit details

Commits on Aug 7, 2019

  1. Document priority of configuration files and command line

    Closes issue 560.
    peterjc committed Aug 7, 2019
    Copy the full SHA
    9e97143 View commit details
  2. Merge branch 'doc_conf_priority' into 'master'

    Document priority of configuration files and command line
    
    Closes #560
    
    See merge request pycqa/flake8!336
    asottile committed Aug 7, 2019
    Copy the full SHA
    d43d498 View commit details

Commits on Aug 10, 2019

  1. Copy the full SHA
    e8c79dc View commit details
  2. Merge branch 'show_source_with_tabs' into 'master'

    Fix --show-source when indented with tabs
    
    Closes #563
    
    See merge request pycqa/flake8!339
    asottile committed Aug 10, 2019
    Copy the full SHA
    03cb85f View commit details
  3. Fix travis-ci

    asottile committed Aug 10, 2019
    Copy the full SHA
    554e91f View commit details

Commits on Aug 11, 2019

  1. Merge branch 'fix_travis2' into 'master'

    Fix travis-ci
    
    See merge request pycqa/flake8!340
    asottile committed Aug 11, 2019
    Copy the full SHA
    9c18aae View commit details

Commits on Aug 18, 2019

  1. Copy the full SHA
    b66ebd7 View commit details
  2. Copy the full SHA
    76515bb View commit details
  3. Merge branch 'argparse' into 'master'

    move from optparse to argparse
    
    See merge request pycqa/flake8!341
    asottile committed Aug 18, 2019
    Copy the full SHA
    f265b22 View commit details

Commits on Aug 19, 2019

  1. Copy the full SHA
    8fd36ba View commit details
  2. Merge branch 'plugin_argparse_groups' into 'master'

    Put plugin options into separate argparse groups
    
    Closes #565
    
    See merge request pycqa/flake8!342
    asottile committed Aug 19, 2019
    Copy the full SHA
    7708e5b View commit details

Commits on Aug 28, 2019

  1. 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]`.
    ericvw committed Aug 28, 2019
    Copy the full SHA
    50ac2f7 View commit details
  2. Merge branch 'hoist-argv' into 'master'

    Hoist passing through sys.argv at the CLI layer
    
    See merge request pycqa/flake8!343
    asottile committed Aug 28, 2019
    Copy the full SHA
    6a70aaa View commit details
  3. Revert "Merge branch 'hoist-argv' into 'master'"

    This reverts merge request !343
    asottile committed Aug 28, 2019
    Copy the full SHA
    b41d983 View commit details
  4. Merge branch 'revert-6a70aaae' into 'master'

    Revert "Merge branch 'hoist-argv' into 'master'"
    
    See merge request pycqa/flake8!344
    asottile committed Aug 28, 2019
    Copy the full SHA
    8b34b33 View commit details

Commits on Aug 29, 2019

  1. 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]`.
    ericvw committed Aug 29, 2019
    Copy the full SHA
    cf4bc53 View commit details
  2. Merge branch 'hoist-argv' into 'master'

    Hoist passing through sys.argv at the CLI layer
    
    See merge request pycqa/flake8!345
    asottile committed Aug 29, 2019
    Copy the full SHA
    45ad2fa View commit details
  3. Copy the full SHA
    5144196 View commit details
  4. Add typings to ConfigFileFinder constructor

    `OptionManager.parse_known_args()` is guaranteed to return a list of
    remaining argument strings.
    ericvw committed Aug 29, 2019
    Copy the full SHA
    c2216c0 View commit details
  5. Merge branch 'type-config-file-finder' into 'master'

    Add typings to ConfigFileFinder constructor
    
    See merge request pycqa/flake8!346
    asottile committed Aug 29, 2019
    Copy the full SHA
    a649019 View commit details

Commits on Aug 30, 2019

  1. Remove unused parameter from OptionManager.parse_known_args()

    The `values` parameter is not utilized anywhere and can be safely
    removed.
    ericvw committed Aug 30, 2019
    Copy the full SHA
    220a928 View commit details
  2. Merge branch 'remove-parse-known-args-value' into 'master'

    Remove unused parameter from `OptionManager.parse_known_args()`
    
    See merge request pycqa/flake8!347
    asottile committed Aug 30, 2019
    Copy the full SHA
    c185a2f View commit details
  3. Add typing to OptionManager.parse_known_args()

    Note that type casting is necessary given that `self.parser` is
    annotated as a `Union`.
    ericvw committed Aug 30, 2019
    Copy the full SHA
    8ea3c63 View commit details
  4. Merge branch 'type-parse-known-args' into 'master'

    Add typing to `OptionManager.parse_known_args()`
    
    See merge request pycqa/flake8!348
    asottile committed Aug 30, 2019
    Copy the full SHA
    eee53d9 View commit details

Commits on Aug 31, 2019

  1. Add typing to OptionManager.parse_args()

    Note that the `assert` is necessary to "cast" `self.parser` since it is
    specified as a `Union`.
    ericvw committed Aug 31, 2019
    Copy the full SHA
    ec8fcfc View commit details
  2. 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.
    ericvw committed Aug 31, 2019
    Copy the full SHA
    b231c10 View commit details
  3. 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.
    ericvw committed Aug 31, 2019
    Copy the full SHA
    aadd09d View commit details
Showing with 2,106 additions and 1,348 deletions.
  1. +2 −2 .appveyor.yml
  2. +1 −80 .bandit.yml
  3. +22 −1 .coveragerc
  4. +18 −3 .gitlab-ci.yml
  5. +7 −1 .pre-commit-config.yaml
  6. +0 −4 .pylintrc
  7. +3 −2 .travis.yml
  8. +0 −1 codecov.yml
  9. +1 −1 docs/source/glossary.rst
  10. +3 −3 docs/source/internal/option_handling.rst
  11. +5 −10 docs/source/internal/utils.rst
  12. +11 −11 docs/source/plugin-development/plugin-parameters.rst
  13. +0 −1 docs/source/release-notes/3.7.0.rst
  14. +225 −0 docs/source/release-notes/3.8.0.rst
  15. +1 −0 docs/source/release-notes/index.rst
  16. +5 −0 docs/source/user/configuration.rst
  17. +36 −3 docs/source/user/error-codes.rst
  18. +33 −7 docs/source/user/options.rst
  19. +3 −3 docs/source/user/using-hooks.rst
  20. +11 −0 docs/source/user/violations.rst
  21. +98 −5 setup.cfg
  22. +1 −141 setup.py
  23. +1 −1 src/flake8/__init__.py
  24. +14 −0 src/flake8/_compat.py
  25. +16 −8 src/flake8/api/legacy.py
  26. +33 −29 src/flake8/checker.py
  27. +5 −10 src/flake8/exceptions.py
  28. +10 −5 src/flake8/formatting/base.py
  29. +80 −118 src/flake8/main/application.py
  30. +4 −0 src/flake8/main/cli.py
  31. +24 −28 src/flake8/main/debug.py
  32. +84 −68 src/flake8/main/options.py
  33. +8 −0 src/flake8/main/setuptools_command.py
  34. +30 −18 src/flake8/main/vcs.py
  35. +15 −16 src/flake8/options/aggregator.py
  36. +64 −91 src/flake8/options/config.py
  37. +306 −149 src/flake8/options/manager.py
  38. +22 −17 src/flake8/plugins/manager.py
  39. +16 −2 src/flake8/plugins/pyflakes.py
  40. +91 −48 src/flake8/processor.py
  41. +37 −24 src/flake8/style_guide.py
  42. +34 −35 src/flake8/utils.py
  43. +0 −1 tests/fixtures/config_files/cli-specified.ini
  44. +0 −2 tests/integration/subdir/aplugin.py
  45. +11 −6 tests/integration/test_aggregator.py
  46. +34 −9 tests/integration/test_checker.py
  47. +160 −13 tests/integration/test_main.py
  48. +0 −4 tests/integration/test_plugins.py
  49. +3 −2 tests/unit/conftest.py
  50. +24 −27 tests/unit/test_application.py
  51. +23 −13 tests/unit/test_base_formatter.py
  52. +8 −7 tests/unit/test_checker_manager.py
  53. +57 −84 tests/unit/test_config_file_finder.py
  54. +10 −12 tests/unit/test_debug.py
  55. +3 −3 tests/unit/test_decision_engine.py
  56. +1 −7 tests/unit/test_exceptions.py
  57. +63 −40 tests/unit/test_file_processor.py
  58. +3 −3 tests/unit/test_filenameonly_formatter.py
  59. +8 −4 tests/unit/test_get_local_plugins.py
  60. +24 −10 tests/unit/test_legacy_api.py
  61. +17 −24 tests/unit/test_merged_config_parser.py
  62. +3 −3 tests/unit/test_nothing_formatter.py
  63. +20 −37 tests/unit/test_option.py
  64. +139 −18 tests/unit/test_option_manager.py
  65. +4 −3 tests/unit/test_plugin.py
  66. +27 −31 tests/unit/test_plugin_manager.py
  67. +1 −1 tests/unit/test_plugin_type_manager.py
  68. +9 −7 tests/unit/test_style_guide.py
  69. +64 −22 tests/unit/test_utils.py
  70. +10 −9 tox.ini
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# To activate, change the Appveyor settings to use `.appveyor.yml`.
install:
- python -m pip install --upgrade tox virtualenv
- python -m pip install --upgrade setuptools tox virtualenv

build: off

test_script:
- python -m tox -e py27,py34,py35,dogfood
- python -m tox -e py27,py36,py37,dogfood
81 changes: 1 addition & 80 deletions .bandit.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,5 @@
tests:
skips:
- B101 # Ignore defensive `assert`s (especially useful for mypy)
- B404 # Ignore warnings about importing subprocess
- B603 # Ignore warnings about calling subprocess.Popen without shell=True
- B607 # Ignore warnings about calling subprocess.Popen without a full path to executable

### (optional) plugin settings - some test plugins require configuration data
### that may be given here, per-plugin. All bandit test plugins have a built in
### set of sensible defaults and these will be used if no configuration is
### provided. It is not necessary to provide settings for every (or any) plugin
### if the defaults are acceptable.

any_other_function_with_shell_equals_true:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
execute_with_run_as_root_equals_true:
function_names: [ceilometer.utils.execute, cinder.utils.execute, neutron.agent.linux.utils.execute,
nova.utils.execute, nova.utils.trycmd]
hardcoded_tmp_directory:
tmp_dirs: [/tmp, /var/tmp, /dev/shm]
linux_commands_wildcard_injection:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
password_config_option_not_marked_secret:
function_names: [oslo.config.cfg.StrOpt, oslo_config.cfg.StrOpt]
ssl_with_bad_defaults:
bad_protocol_versions: [PROTOCOL_SSLv2, SSLv2_METHOD, SSLv23_METHOD, PROTOCOL_SSLv3,
PROTOCOL_TLSv1, SSLv3_METHOD, TLSv1_METHOD]
ssl_with_bad_version:
bad_protocol_versions: [PROTOCOL_SSLv2, SSLv2_METHOD, SSLv23_METHOD, PROTOCOL_SSLv3,
PROTOCOL_TLSv1, SSLv3_METHOD, TLSv1_METHOD]
start_process_with_a_shell:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
start_process_with_no_shell:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
start_process_with_partial_path:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
subprocess_popen_with_shell_equals_true:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
subprocess_without_shell_equals_true:
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv, os.execve, os.execvp,
os.execvpe, os.spawnl, os.spawnle, os.spawnlp, os.spawnlpe, os.spawnv, os.spawnve,
os.spawnvp, os.spawnvpe, os.startfile]
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4, popen2.popen2, popen2.popen3,
popen2.popen4, popen2.Popen3, popen2.Popen4, commands.getoutput, commands.getstatusoutput]
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call, subprocess.check_output,
utils.execute, utils.execute_with_timeout]
try_except_continue: {check_typed_exception: false}
try_except_pass: {check_typed_exception: false}

23 changes: 22 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
[run]
parallel = True
branch = True
source =
flake8

tests
omit =
# Don't complain if non-runnable code isn't run
*/__main__.py

[paths]
source =
src/flake8
.tox/*/lib/python*/site-packages/flake8
.tox/pypy/site-packages/flake8

[report]
show_missing = True
skip_covered = True
exclude_lines =
# Have to re-enable the standard pragma
\#\s*pragma: no cover

# Don't complain if tests don't hit defensive assertion code:
^\s*raise AssertionError\b
^\s*raise NotImplementedError\b
^\s*return NotImplemented\b
^\s*raise$

# Don't complain if non-runnable code isn't run:
^if __name__ == ['"]__main__['"]:$
^\s*if False:
21 changes: 18 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -6,14 +6,23 @@ stages:
- release

before_script:
- curl -O https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
- pip install pip --upgrade
- pip install -r dev-requirements.txt

after_script:
- pip install codecov
- codecov --token=7d117e6b-aab6-4283-ab19-166dafc38cf5

pypy2:
image: pypy:2.7-7.2.0
stage: test
script: tox -e pypy

pypy3:
image: pypy:3.6-7.2.0
stage: test
script: tox -e pypy3

python2:
image: python:2.7
stage: test
@@ -39,8 +48,13 @@ python37:
stage: test
script: tox -e py37

python38:
image: python:3.8
stage: test
script: tox -e py38

linters:
image: python:3.6
image: python:3.7
stage: test
script: tox -e linters

@@ -54,6 +68,7 @@ docs:
script: tox -e docs

dogfood:
image: python:3.7
stage: test
script: tox -e dogfood

8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: ^tests/fixtures/diffs/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.701
rev: v0.720
hooks:
- id: mypy
exclude: ^(docs/|example-plugin/|tests/fixtures)
4 changes: 0 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -354,10 +354,6 @@ max-bool-expr=5


[IMPORTS]

# Deprecated modules which should not be used, separated by a comma
deprecated-modules=optparse

# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dist: xenial
language: python
cache: pip
before_script:
@@ -22,9 +21,11 @@ matrix:
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
- python: 3.8
env: TOXENV=py38
- python: pypy
env: TOXENV=pypy
- python: 2.7
- python: 3.7
env: TOXENV=readme
- python: 3.7
env: TOXENV=flake8
1 change: 0 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -40,4 +40,3 @@ comment:
layout: "header, diff, changes, sunburst, uncovered, tree"
branches: null
behavior: default

2 changes: 1 addition & 1 deletion docs/source/glossary.rst
Original file line number Diff line number Diff line change
@@ -54,4 +54,4 @@
mccabe
The project |Flake8| depends on to calculate the McCabe complexity
of a unit of code (e.g., a function). This uses the ``C``
:term:`class` of :term`error code`\ s.
:term:`class` of :term:`error code`\ s.
6 changes: 3 additions & 3 deletions docs/source/internal/option_handling.rst
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ undocumented attribute that pep8 looks for, |Flake8| 3 now accepts a parameter
to ``add_option``, specifically ``parse_from_config`` which is a boolean
value.

|Flake8| does this by creating its own abstractions on top of :mod:`optparse`.
|Flake8| does this by creating its own abstractions on top of :mod:`argparse`.
The first abstraction is the :class:`flake8.options.manager.Option` class. The
second is the :class:`flake8.options.manager.OptionManager`. In fact, we add
three new parameters:
@@ -67,7 +67,7 @@ example, let's consider a user's list of ignored error codes for a project:
E251
It makes sense here to allow users to specify the value this way, but, the
standard libary's :class:`configparser.RawConfigParser` class does returns a
standard library's :class:`configparser.RawConfigParser` class does returns a
string that looks like

.. code-block:: python
@@ -219,7 +219,7 @@ API Documentation
.. autofunction:: flake8.options.aggregator.aggregate_options

.. autoclass:: flake8.options.manager.Option
:members: __init__, normalize, to_optparse
:members: __init__, normalize, to_argparse

.. autoclass:: flake8.options.manager.OptionManager
:members:
15 changes: 5 additions & 10 deletions docs/source/internal/utils.rst
Original file line number Diff line number Diff line change
@@ -25,13 +25,8 @@
"E121,W123,F904"
"E121,\nW123,\nF804"
"E121,\n\tW123,\n\tF804"
Or it will take a list of strings (potentially with whitespace) such as

.. code-block:: python
[" E121\n", "\t\nW123 ", "\n\tF904\n "]
" E121,\n\tW123,\n\tF804 "
" E121\n\tW123 \n\tF804"
And converts it to a list that looks as follows

@@ -50,9 +45,9 @@ path if the string has a ``/`` in it. It also removes trailing ``/``\ s.

.. autofunction:: flake8.utils.normalize_paths

This function utilizes :func:`~flake8.utils.parse_comma_separated_list` and
:func:`~flake8.utils.normalize_path` to normalize its input to a list of
strings that should be paths.
This function utilizes :func:`~flake8.utils.normalize_path` to normalize a
sequence of paths. See :func:`~flake8.utils.normalize_path` for what defines a
normalized path.

.. autofunction:: flake8.utils.stdin_get_value

22 changes: 11 additions & 11 deletions docs/source/plugin-development/plugin-parameters.rst
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ Any plugin that has callable attributes ``add_options`` and
Your ``add_options`` function should expect to receive an instance of
|OptionManager|. An |OptionManager| instance behaves very similarly to
:class:`optparse.OptionParser`. It, however, uses the layer that |Flake8| has
developed on top of :mod:`optparse` to also handle configuration file parsing.
developed on top of :mod:`argparse` to also handle configuration file parsing.
:meth:`~flake8.options.manager.OptionManager.add_option` creates an |Option|
which accepts the same parameters as :mod:`optparse` as well as three extra
boolean parameters:
@@ -115,21 +115,21 @@ couple examples from |Flake8|. In each example, we will have
'--max-line-length', type='int', metavar='n',
default=defaults.MAX_LINE_LENGTH, parse_from_config=True,
help='Maximum allowed line length for the entirety of this run. '
'(Default: %default)',
'(Default: %(default)s)',
)
Here we are adding the ``--max-line-length`` command-line option which is
always an integer and will be parsed from the configuration file. Since we
provide a default, we take advantage of :mod:`optparse`\ 's willingness to
display that in the help text with ``%default``.
provide a default, we take advantage of :mod:`argparse`\ 's willingness to
display that in the help text with ``%(default)s``.

.. code-block:: python
option_manager.add_option(
'--select', metavar='errors', default='',
parse_from_config=True, comma_separated_list=True,
help='Comma-separated list of errors and warnings to enable.'
' For example, ``--select=E4,E51,W234``. (Default: %default)',
' For example, ``--select=E4,E51,W234``. (Default: %(default)s)',
)
In adding the ``--select`` command-line option, we're also indicating to the
@@ -143,7 +143,7 @@ as a comma-separated list.
comma_separated_list=True, parse_from_config=True,
normalize_paths=True,
help='Comma-separated list of files or directories to exclude.'
'(Default: %default)',
'(Default: %(default)s)',
)
Finally, we show an option that uses all three extra flags. Values from
@@ -152,18 +152,18 @@ list, and then each item will be normalized.

For information about other parameters to
:meth:`~flake8.options.manager.OptionManager.add_option` refer to the
documentation of :mod:`optparse`.
documentation of :mod:`argparse`.


Accessing Parsed Options
========================

When a plugin has a callable ``parse_options`` attribute, |Flake8| will call
it and attempt to provide the |OptionManager| instance, the parsed options
which will be an instance of :class:`optparse.Values`, and the extra arguments
that were not parsed by the |OptionManager|. If that fails, we will just pass
the :class:`optparse.Values`. In other words, your ``parse_options``
callable will have one of the following signatures:
which will be an instance of :class:`argparse.Namespace`, and the extra
arguments that were not parsed by the |OptionManager|. If that fails, we will
just pass the :class:`argparse.Namespace`. In other words, your
``parse_options`` callable will have one of the following signatures:

.. code-block:: python
1 change: 0 additions & 1 deletion docs/source/release-notes/3.7.0.rst
Original file line number Diff line number Diff line change
@@ -83,4 +83,3 @@ Features
https://gitlab.com/pycqa/flake8/merge_requests/287
.. _GitLab!288:
https://gitlab.com/pycqa/flake8/merge_requests/288

Loading