flake8 plugin to run black for checking Python coding style

Overview

flake8-black

Released on the Python Package Index (PyPI) Released on Conda Testing with TravisCI PyPI downloads Code style: black

Introduction

This is an MIT licensed flake8 plugin for validating Python code style with the command line code formatting tool black. It is available to install from the Python Package Index (PyPI).

Black, "The Uncompromising Code Formatter", is normally run to edit your Python code in place to match their coding style, a strict subset of the PEP 8 style guide.

The point of this plugin is to be able to run black --check ... from within the flake8 plugin ecosystem. You might use this via a git pre-commit hook, or as part of your continuous integration testing.

If you are using pre-commit configure it to call black and/or flake8 directly - you do not need flake8-black at all.

Flake8 Validation codes

Early versions of flake8 assumed a single character prefix for the validation codes, which became problematic with collisions in the plugin ecosystem. Since v3.0, flake8 has supported longer prefixes, therefore this plugin uses BLK as its prefix.

Code Description (and notes)
BLK100 Black would make changes.
BLK9## Internal error (various, listed below):
BLK900 Failed to load file: ...
BLK901 Invalid input.
BLK997 Invalid TOML file: ...
BLK998 Could not access flake8 line length setting (no longer used).
BLK999 Unexpected exception.

Note that if your Python code has a syntax error, black --check ... would report this as an error. Likewise flake8 ... will by default report the syntax error, but importantly it does not seem to then call the plugins, so you will not get an additional BLK error.

Installation

Python 3.6 or later is required to run black, so that is recommended, but black can be used on Python code written for older versions of Python.

You can install flake8-black using pip, which should install flake8 and black as well if not already present:

$ pip install flake8-black

Alternatively, if you are using the Anaconda packaging system, the following command will install the plugin with its dependencies:

$ conda install -c conda-forge flake8-black

The new validator should be automatically included when using flake8 which may now report additional validation codes starting with BLK (as defined above). For example:

$ flake8 example.py

You can request only the BLK codes be shown using:

$ flake8 --select BLK example.py

Python package management

We covered using pip or conda by hand above. If you are using a PyPI based Python dependency system like pipenv or poetry, you may run into complications because at the time of writing all the black releases to PyPI have been tagged as pre-releases (beta code). PEP440 Handling of pre-releases could be more explicit here.

For pipenv, flake8-black v0.2.0 onwards should just work.

For poetry, include this in your pyproject.toml configuration file:

[tool.poetry.dev-dependencies]
...
black = { version = "*", allow-prereleases = true }
...

In either case, for large projects you should consider pinning the exact version of black you want to use as their updates do sometimes introduce changes which would show up as new BLK100 violations via flake8.

Configuration

We assume you are familiar with flake8 configuration and black configuration.

We recommend using the following settings in your flake8 configuration, for example in your .flake8, setup.cfg, or tox.ini file:

[flake8]
# Recommend matching the black line length (default 88),
# rather than using the flake8 default of 79:
max-line-length = 88
extend-ignore =
    # See https://github.com/PyCQA/pycodestyle/issues/373
    E203,

Note currently pycodestyle gives false positives on the spaces black uses for slices, which flake8 reports as E203: whitespace before ':'. Until pyflakes issue 373 is fixed, and flake8 is updated, we suggest disabling this style check.

Separately pyproject.toml is used for black configuration - if this file is found, the plugin will look at the following black settings:

  • target_version
  • skip_string_normalization
  • line_length

You can specify a particular path for the pyproject.toml file (e.g. global development settings) using --black-config FILENAME at the command line, or using black-config = FILENAME in your flake8 configuration file.

Ignoring validation codes

Using the flake8 no-quality-assurance pragma comment is not recommended (e.g. adding # noqa: BLK100 to the first line black would change). Instead use the black pragma comments # fmt: off at the start, and # fmt: on at the end, of any region of your code which should not be changed. Or, exlude the entire file by name (see below).

Ignoring files

The plugin does NOT currently consider the black settings include and exclude, so if you have certain Python files which you do not use with black and have told it to ignore, you will also need to tell flake8 to ignore them (e.g. using exclude or per-file-ignores).

Version History

Version Release date Changes
v0.2.1 2020-07-25
  • Detect *.pyi files via extension.
v0.2.0 2020-05-20
  • Minimum requirement on black 19.3b0 or later is now implicit. This is a workaround for pipenv issue 3928. Upgrade black if running flake8 gives an error like this: Flake8 failed to load plugin "BLK" due to __call__() got an unexpected keyword argument 'target_versions'.
v0.1.2 2020-05-18
  • Removed test broken by flake8 v3.8 change to resolve configuration files relative to current directory.
v0.1.1 2019-08-26
  • Option to use a (global) black configuration file, contribution from Tomasz Grining.
  • New BLK997 if can't parse pyproject.toml file.
  • Logs configuration files, use -v or --verbose.
  • Fixed flake8 "builtins" parameter warning.
  • Now requires black 19.3b0 or later.
v0.1.0 2019-06-03
  • Uses main black settings from pyproject.toml, contribution from Alex.
  • WARNING: Now ignores flake8 max-line-length setting.
v0.0.4 2019-03-15
  • Supports black 19.3b0 which changed a function call.
v0.0.3 2019-02-21
  • Bug fix when W292 no newline at end of file applies, contribution from Sapphire Becker.
v0.0.2 2019-02-15
  • Document syntax error behaviour (no BLK error reported).
v0.0.1 2019-01-10
  • Initial public release.
  • Passes flake8 max-line-length setting to black.

Developers

This plugin is on GitHub at https://github.com/peterjc/flake8-black

To make a new release once tested locally and on TravisCI:

$ git tag vX.Y.Z
$ python setup.py sdist --formats=gztar
$ twine upload dist/flake8-black-X.Y.Z.tar.gz
$ git push origin master --tags

The PyPI upload should trigger an automated pull request updating the flake8-black conda-forge recipe.

Comments
  • CPU usage at 100% on all cores

    CPU usage at 100% on all cores

    Hi, I added flake8-black to poetry, it's been running for over a 5 minutes on my small project and 8 workers on 100% CPU - I'm guess this is not expected behaviour ?

    So - I guess my config is wrong and it's stuck in a loop - this is probably something that still shouldn't be possible though ?

    image

    opened by stuaxo 15
  • feature/BLACK_CONFIG: Black configuration file configurable

    feature/BLACK_CONFIG: Black configuration file configurable

    Added flake8-black-config parameter to be set in flake8 configuration file, which points to the .toml file that should be used instead of the default black pyptoject.toml.

    opened by 098799 13
  • BLK999 for shebang

    BLK999 for shebang

    $ cat test.py
    #!/usr/bin/env python3
    
    print("test")
    $ flake8 -v test.py
    flake8.plugins.manager    MainProcess     49 INFO     Loading entry-points for "flake8.extension".
    flake8.plugins.manager    MainProcess     76 INFO     Loading entry-points for "flake8.report".
    flake8.plugins.manager    MainProcess    103 INFO     Loading plugin "BLK" from entry-point.
    flake8.plugins.manager    MainProcess    162 INFO     Loading plugin "C90" from entry-point.
    flake8.plugins.manager    MainProcess    164 INFO     Loading plugin "F" from entry-point.
    flake8.plugins.manager    MainProcess    175 INFO     Loading plugin "pycodestyle.ambiguous_identifier" from entry-point.
    flake8.plugins.manager    MainProcess    179 INFO     Loading plugin "pycodestyle.bare_except" from entry-point.
    flake8.plugins.manager    MainProcess    179 INFO     Loading plugin "pycodestyle.blank_lines" from entry-point.
    flake8.plugins.manager    MainProcess    179 INFO     Loading plugin "pycodestyle.break_after_binary_operator" from entry-point.
    flake8.plugins.manager    MainProcess    179 INFO     Loading plugin "pycodestyle.break_before_binary_operator" from entry-point.
    flake8.plugins.manager    MainProcess    179 INFO     Loading plugin "pycodestyle.comparison_negative" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.comparison_to_singleton" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.comparison_type" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.compound_statements" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.continued_indentation" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.explicit_line_join" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.extraneous_whitespace" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.imports_on_separate_lines" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.indentation" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.maximum_doc_length" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.maximum_line_length" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.missing_whitespace" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.missing_whitespace_after_import_keyword" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.missing_whitespace_around_operator" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.module_imports_on_top_of_file" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.python_3000_async_await_keywords" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.python_3000_backticks" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.python_3000_has_key" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.python_3000_invalid_escape_sequence" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.python_3000_not_equal" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.python_3000_raise_comma" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.tabs_obsolete" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.tabs_or_spaces" from entry-point.
    flake8.plugins.manager    MainProcess    180 INFO     Loading plugin "pycodestyle.trailing_blank_lines" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.trailing_whitespace" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.whitespace_around_comma" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.whitespace_around_keywords" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.whitespace_around_named_parameter_equals" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.whitespace_around_operator" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.whitespace_before_comment" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pycodestyle.whitespace_before_parameters" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "default" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "pylint" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "quiet-filename" from entry-point.
    flake8.plugins.manager    MainProcess    181 INFO     Loading plugin "quiet-nothing" from entry-point.
    flake8.options.manager    MainProcess    181 WARNING  option --max-complexity: please update from optparse string `type=` to argparse callable `type=` -- this will be an error in the future
    flake8                    MainProcess    182 INFO     flake8-black: No black configuration set
    flake8.checker            MainProcess    183 WARNING  The multiprocessing module is not available. Ignoring --jobs arguments.
    flake8.checker            MainProcess    183 INFO     Making checkers
    flake8.checker            MainProcess    184 INFO     Checking 1 files
    flake8.main.application   MainProcess    189 INFO     Finished running
    flake8.main.application   MainProcess    189 INFO     Reporting errors
    flake8.main.application   MainProcess    189 INFO     Found a total of 1 violations and reported 1
    _.py:0:1: BLK999 Unexpected exception: unsupported operand type(s) for /: 'tuple' and 'str'
    
    opened by eggplants 12
  • flake8-black, pipenv, black dependency hell

    flake8-black, pipenv, black dependency hell

    Some slight problems with the 0.1.1 release when using with pipenv. Because black does not yet have a "stable" release (unbelievably, its been coming "in a few weeks" for about 18 months now!), every single release of black must be installed with --pre flag with pipenv, unless an exact version match is specified.

    However, with the 0.1.1 release of flake8-black, we've got two specifiers for black specified - "==19.3b0" from the project, and ">=19.3b0" from flake8-black. This makes pipenv look for the latest released version of black to install... except there is no latest release that is not a pre-release!

    This is then double complicated by pipenv. There is no "--pre" flag for pipenv that applies just to a single package, so now in order to get a lock, we must allow all pre-release packages to be considered by pipenv. This is not ideal!

    [pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches black==19.3b0,>=19.3b0
    [pipenv.exceptions.ResolutionFailure]:       Skipped pre-versions: 18.3a0, 18.3a0, 18.3a0, 18.3a0, 18.3a1, 18.3a1, 18.3a1, 18.3a1, 18.3a2, 18.3a2, 18.3a2, 18.3a2, 18.3a3, 18.3a3, 18.3a3, 18.3a3, 18.3a4, 18.3a4, 18.3a4, 18.3a4, 18.4a0, 18.4a0, 18.4a0, 18.4a0, 18.4a1, 18.4a1, 18.4a1, 18.4a1, 18.4a2, 18.4a2, 18.4a2, 18.4a2, 18.4a3, 18.4a3, 18.4a3, 18.4a3, 18.4a4, 18.4a4, 18.4a4, 18.4a4, 18.5b0, 18.5b0, 18.5b0, 18.5b0, 18.5b1, 18.5b1, 18.5b1, 18.5b1, 18.6b0, 18.6b0, 18.6b0, 18.6b0, 18.6b1, 18.6b1, 18.6b1, 18.6b1, 18.6b2, 18.6b2, 18.6b2, 18.6b2, 18.6b3, 18.6b3, 18.6b3, 18.6b3, 18.6b4, 18.6b4, 18.6b4, 18.6b4, 18.9b0, 18.9b0, 18.9b0, 18.9b0, 19.3b0, 19.3b0, 19.3b0, 19.3b0
    
    opened by tevansuk 9
  • Catch bad TOML files; allow using no TOML file

    Catch bad TOML files; allow using no TOML file

    (Re-submission of #14)

    Builds on #11, adds new BLK997 if a pyproject.toml file is invalid, allows using flake8 --black-config '-' ... to mean ignore any pyproject.toml file.

    Adds explicit failure during configuration parsing for specified TOML file missing (#12) or invalid, although currently an ugly traceback.

    enhancement 
    opened by peterjc 9
  • feature/GLOBAL_CONFIG: Added global black configuration option

    feature/GLOBAL_CONFIG: Added global black configuration option

    If no pyproject.toml file is found, flake8-black will fallback on the global configuration for black found in $HOME/.config/flake8-black/pyproject.toml. Syntax stays the same.

    opened by 098799 9
  • Allow  setting the location of `pyproject.toml` file

    Allow setting the location of `pyproject.toml` file

    It would be great to be able to specify the location of the pyproject.toml file for more advanced setups.

    black currently allows setting the location of the pyproject.toml file with the --config option.

    opened by AngellusMortis 9
  • 0.3.1 is not able to open files

    0.3.1 is not able to open files

    Hi, looks like last release as an issue with opening files.

    For all files flake8-black reports:

    `BLK999` Unexpected exception: File must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`
    
    opened by sileht 8
  • Update black.find_project_root signature for black >= 22.1.0

    Update black.find_project_root signature for black >= 22.1.0

    New black 22.1.0 breaks flake8-black with

    BLK999 Unexpected exception: unsupported operand type(s) for /: 'tuple' and 'str'
    

    Because it update find_project_root return values: from Path to Tuple[Path, str] (https://github.com/psf/black/commit/521d1b8129c2d83b4ab49270fe7473802259c2a2)

    opened by rsalmaso 8
  • Broken with Pipenv due to inexact version pin on black

    Broken with Pipenv due to inexact version pin on black

    3bfa2df was introduced to specify a minimum version of black upon which flake8-black depends. Unfortunately, this commit also breaks usage with pipenv, as we can no longer specify an exact version pin in our Pipfile.

    It seems that pipenv simply takes the union of all version strings specified by the Pipfile and its dependency chain and applies logic to that union. Therefore, if I specify the version to be EXACTLY black==19.10b0, I end up with a union which is black==19.10b0,>19.3b0. Logically, this resolves to 19.10b0, but this is not what pipenv sees. Because black is still pre-release, pipenv must have a single version pin (or multiple of the same statement) that resolves to a single version. black==19.10b0 would work, black==19.10b0,black==19.10b0 would work, but (as mentioned) black==19.10b0,>=19.3b0 does not. I do not know but also believe that black==19.10b0,>=19.10b0 would fail.

    I don't necessarily expect action in regards to code within this repository, but a simple mention of the incompatibility in the README (despite this problem being 100% NOT flake8-black's fault) might've saved me 30 or so minutes this afternoon.

    Feel free to close it or address this issue as you see fit. The existence of this ticket will at least serve to document the incompatibility in the future (though more aggressive action - either changing the pin or updating the readme) would help more.

    Either way - thank you for the time reading over this :)

    opened by bbenne10 8
  • Version 0.2.5 is breaking compatibility with flake8<4

    Version 0.2.5 is breaking compatibility with flake8<4

    Hey,

    I have noticed that with flake8==3.9.2 the linter is failing with: flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "BLK" due to __init__() got an unexpected keyword argument 'preview'.

    The problem doesn't exist with flake8-black==0.2.3. I haven't tested it with flake8-black==0.2.4 and flake>=4

    Best regards, Maciej

    opened by maciej-lech 6
  • Parallel use of `flake8_rst_docstrings` and `flake8_black` broken.

    Parallel use of `flake8_rst_docstrings` and `flake8_black` broken.

    Problem:

    When I run pflake8 with both flake8_rst_docstrings and flake8_black plugins active I get a Python exception

        add_options(optmanager)
      File ".../.nox/lint_flake8/lib/python3.9/site-packages/flake8_rst_docstrings.py", line 140, in add_options
        parser.add_option(
      File ".../.nox/lint_flake8/lib/python3.9/site-packages/flake8/options/manager.py", line 415, in add_option
        self._current_group.add_argument(*option_args, **option_kwargs)
      File "/usr/lib/python3.9/argparse.py", line 1446, in add_argument
        return self._add_action(action)
      File "/usr/lib/python3.9/argparse.py", line 1648, in _add_action
        action = super(_ArgumentGroup, self)._add_action(action)
      File "/usr/lib/python3.9/argparse.py", line 1460, in _add_action
        self._check_conflict(action)
      File "/usr/lib/python3.9/argparse.py", line 1597, in _check_conflict
        conflict_handler(action, confl_optionals)
      File "/usr/lib/python3.9/argparse.py", line 1606, in _handle_conflict_error
        raise ArgumentError(action, message % conflict_string)
    argparse.ArgumentError: argument --rst-directives: conflicting option string: --rst-directives
    

    Running with -vv I can see from the log that both plugins try to register under the same name RST:

    ...
    flake8.plugins.manager    MainProcess     95 DEBUG    Loaded Plugin(name="RST", entry_point="flake8_black:BlackStyleChecker") for plugin "RST".
    flake8.plugins.manager    MainProcess     95 DEBUG    Loaded Plugin(name="RST", entry_point="flake8_rst_docstrings:reStructuredTextChecker") for plugin "RST".
    ...
    

    Solution:

    Looking at your pyproject.toml, it looks like you have copy-pasted the wrong name (wasn't it BLK before?):

    [project.entry-points]
    'flake8.extension' = {RST = 'flake8_black:BlackStyleChecker'}
    
    opened by tom65536 3
  • Problems with line length

    Problems with line length

    Hi, I have a problem, I haven't pyproject.toml file, at all. I had everything in .flake8 and now for configure flake8 plugin I need to use strange file. Nothing worked. Please help, how should I create this file I've made this one `

    cat pyproject.toml

    [tool.poetry.dev-dependencies] black = { line_length = 120, version = "*", allow-prereleases = true } ` but this doesn't work

    I even add file to flake8 config but still no hope ╰─ cat .flake8 [flake8] max-line-length = 120 exclude=alembic per-file-ignores=__init__.py:F401 extend-ignore=B008 black-config = pyproject.toml

    I have 2 suggestions:

    1. please add to documentation how to do it for a teapot
    2. add option to plugin line "--use-flake8-config" because I have small config and I don't really need second one with only 1 line
    opened by proggga 2
  • flake8-black error 'BLK100 Black would make changes' when formatted with Black --line-length=120

    flake8-black error 'BLK100 Black would make changes' when formatted with Black --line-length=120

    Hello, Getting error 'BLK100 Black would make changes' while running flake8-black after formatting the code with black src --line-length=120.

    Example: Code after black src --line-length=120 (getting BLK100 error from flake8-black) target_df_add_guid = df_writable.transform(self._addGuid_id).drop("IVV_ATV_GUID_NO_BKEY")

    Code with default black line line length which is 88, flake8-black does not complain for below code. target_df_add_guid = df_writable.transform(self._addGuid_id).drop( "IVV_ATV_GUID_NO_BKEY" )

    Please advise how can we proceed with black formatting with line-length as 120 and flake8 doesn't complain about it?

    opened by jfo1925 3
  • Performance overhead

    Performance overhead

    Testing with Biopython (which recently finished applying black to the entire code base), numbers on a multi-core Mac:

    Black alone (best of three)

    $ time black --check Bio/ BioSQL/ Tests/ Scripts/ Doc/
    All done! ✨ 🍰 ✨
    559 files would be left unchanged.
    
    real	0m0.618s
    user	0m0.484s
    sys	0m0.129s
    

    Using flake8 with assorted plugins, but without flake8-black (best of three)

    $ time flake8 Bio/ BioSQL/ Tests/ Scripts/ Doc/
    
    real	0m56.956s
    user	4m1.520s
    sys	0m3.470s
    

    Adding the above together gives us an expected run time for running black via flake8.

    So, same setup, but with flake8-black (best of three)

    $ time flake8 Bio/ BioSQL/ Tests/ Scripts/ Doc/
    
    real	1m36.095s
    user	6m51.635s
    sys	0m5.928s
    

    That's an overhead of about 40s real and well over 2m user time - not good!

    opened by peterjc 3
  • Relative paths for --black-config setting

    Relative paths for --black-config setting

    Consider we have a user's "global" black configuration in ~/repositories/black.toml and multiple projects under this folder, where ~/repositories/project/.flake8 contains:

    [flake8]
    black_config=../black.toml
    

    Then, you might run:

    cd ~/repositories/project/
    flake8 tests/
    cd tests/
    flake8 .
    

    Both the above should find the ~/repositories/project/.flake8 file, which will load ../black.toml as the location of the black configuration file, which should be converted relative to ~/repositories/project/.flake8 giving ~/repositories/black.toml.

    However, now suppose the users does the following, where the command line setting will override any values set via the flake8 configuration files (see https://gitlab.com/pycqa/flake8/issues/560 for clarifying this):

    cd ~/repositories/project/
    flake8 --black-config ../black.toml tests/
    cd tests/
    flake8 --black-config ../../black.toml .
    

    Here the relative paths ../black.toml and ../../black.toml should both be interpreted relative to the current directory, and both give ~/repositories/black.toml.

    However, if the plugin just gets a string ../black.toml or ../../black.toml, how is it to infer the starting path (a config file location or the present directory)? i.e. How was the setting given (which config file, or was it the command line)?

    Cross reference https://gitlab.com/pycqa/flake8/issues/561

    If we can't tell, we could be pragmatic and just try both, and maybe give an error if both interpretations exist but are different paths?

    bug question 
    opened by peterjc 2
  • Graceful handling of missing black config (if set)

    Graceful handling of missing black config (if set)

    For #9, pull request #11 added flake8 --black-config /path/to/black.toml support (also possible via your flake8 configuration file).

    If this configuration is not set, the current behaviour is fine (follow black in looking for pyproject.toml and failing that, use black's defaults).

    If this path is set, but the file does not exist, we should error explicitly and as early as possible:

    We could introduce a validation code and raise this on every file checked instead of calling black (perhaps reuse BLK998) - but I think there ought to be a way to tell flake8 to abort gracefully:

    https://gitlab.com/pycqa/flake8/issues/559

    bug enhancement 
    opened by peterjc 2
Owner
Peter Cock
Peter Cock
Flake8 extension for checking quotes in python

Flake8 Extension to lint for quotes. Major update in 2.0.0 We automatically encourage avoiding escaping quotes as per PEP 8. To disable this, use --no

Zachary Heller 157 Dec 13, 2022
Utilities for pycharm code formatting (flake8 and black)

Pycharm External Tools Extentions to Pycharm code formatting tools. Currently supported are flake8 and black on a selected code block. Usage Flake8 [P

Haim Daniel 13 Nov 3, 2022
A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

flake8-bugbear A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycode

Python Code Quality Authority 869 Dec 30, 2022
❄️ A flake8 plugin to help you write better list/set/dict comprehensions.

flake8-comprehensions A flake8 plugin that helps you write better list/set/dict comprehensions. Requirements Python 3.6 to 3.9 supported. Installation

Adam Johnson 398 Dec 23, 2022
flake8 plugin that integrates isort

Flake8 meet isort Use isort to check if the imports on your python files are sorted the way you expect. Add an .isort.cfg to define how you want your

Gil Forcada Codinachs 139 Nov 8, 2022
Flake8 plugin to find commented out or dead code

flake8-eradicate flake8 plugin to find commented out (or so called "dead") code. This is quite important for the project in a long run. Based on eradi

wemake.services 277 Dec 27, 2022
A plugin for flake8 integrating Mypy.

flake8-mypy NOTE: THIS PROJECT IS DEAD It was created in early 2017 when Mypy performance was often insufficient for in-editor linting. The Flake8 plu

Łukasz Langa 103 Jun 23, 2022
A plugin for Flake8 that checks pandas code

pandas-vet pandas-vet is a plugin for flake8 that provides opinionated linting for pandas code. It began as a project during the PyCascades 2019 sprin

Jacob Deppen 146 Dec 28, 2022
flake8 plugin to catch useless `assert` statements

flake8-useless-assert flake8 plugin to catch useless assert statements Download or install on the PyPI page Violations Code Description Example ULA001

null 1 Feb 12, 2022
Flake8 extension for enforcing trailing commas in python

Flake8 Extension to enforce better comma placement. Usage If you are using flake8 it's as easy as: pip install flake8-commas Now you can avoid those a

Python Code Quality Authority 127 Sep 3, 2022
The official GitHub mirror of https://gitlab.com/pycqa/flake8

Flake8 Flake8 is a wrapper around these tools: PyFlakes pycodestyle Ned Batchelder's McCabe script Flake8 runs all the tools by launching the single f

Python Code Quality Authority 2.6k Jan 3, 2023
Flake8 wrapper to make it nice, legacy-friendly, configurable.

THE PROJECT IS ARCHIVED Forks: https://github.com/orsinium/forks It's a Flake8 wrapper to make it cool. Lint md, rst, ipynb, and more. Shareable and r

Life4 232 Dec 16, 2022
Automated security testing using bandit and flake8.

flake8-bandit Automated security testing built right into your workflow! You already use flake8 to lint all your code for errors, ensure docstrings ar

Tyler Wince 96 Jan 1, 2023
Tool to automatically fix some issues reported by flake8 (forked from autoflake).

autoflake8 Introduction autoflake8 removes unused imports and unused variables from Python code. It makes use of pyflakes to do this. autoflake8 also

francisco souza 27 Sep 8, 2022
Flake8 extension to provide force-check option

flake8-force Flake8 extension to provide force-check option. When this option is enabled, flake8 performs all checks even if the target file cannot be

Kenichi Maehashi 9 Oct 29, 2022
Performant type-checking for python.

Pyre is a performant type checker for Python compliant with PEP 484. Pyre can analyze codebases with millions of lines of code incrementally – providi

Facebook 6.2k Jan 4, 2023
Unbearably fast O(1) runtime type-checking in pure Python.

Look for the bare necessities, the simple bare necessities. Forget about your worries and your strife. — The Jungle Book.

beartype 1.4k Jan 1, 2023
Simple Python style checker in one Python file

pycodestyle (formerly called pep8) - Python style guide checker pycodestyle is a tool to check your Python code against some of the style conventions

Python Code Quality Authority 4.7k Jan 1, 2023
docstring style checker

pydocstyle - docstring style checker pydocstyle is a static analysis tool for checking compliance with Python docstring conventions. pydocstyle suppor

Python Code Quality Authority 982 Jan 3, 2023