Questions tagged [flake8]

Automatic syntax checker for Python, bundled with pycodestyle, pyflakes and mccabe.

Automatic syntax checker for Python programming language, bundled with pycodestyle, pyflakes, mccabe for easy installation and use.

410 questions
28
votes
3 answers

How do I enable auto code formatting for flake8 in PyCharm

I use Tox to run unit tests, with a flake8 command that checks for code formatting errors. Each time I code in PyCharm, I run tox then realise I have a bunch of annoying formatting errors I have to back and manually fix. I would like PyCharm to…
Ryu S.
  • 1,538
  • 2
  • 22
  • 41
26
votes
5 answers

Using Pylint in Ipython (Jupyter-Notebook)

I want to run Pylint or any equivalent while using Jupyter-Notebook. Is there a way to install and run Pylint this way?
mccurcio
  • 1,294
  • 5
  • 25
  • 44
23
votes
5 answers

flake8 not picking up config file

I have my flake8 config file in ~/.config/flake8 [flake8] max-line-length = 100 However when I run flake8 the config file is not picked up. I know that because i still get warnings over lines longer than 79 char. I'm on redhat, but the same happens…
evolution
  • 4,332
  • 5
  • 29
  • 34
23
votes
3 answers

Flake8 Not Recognizing built-in exception

I have a strict pre-commit hook set up with flake8, so I can't commit until its happy. This is normally a good thing, but it is causing some problems with what seems like no problem at all. I can't get Flake8 to recognize a…
Lily Mara
  • 3,859
  • 4
  • 29
  • 48
22
votes
1 answer

Flake8 Error code '#' supplied to 'ignore' option does not match '^[A-Z]{1,3}[0-9]{0,3}$'

I met this issue while running git push. $ flake8 --config setup.cfg Traceback (most recent call last): File "/usr/local/bin/flake8", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/site-packages/flake8/main/cli.py", line…
taichi_tiger
  • 809
  • 1
  • 7
  • 18
22
votes
3 answers

Exclude .env directory from flake8 tests?

Problem I'm getting thousands of flake8 errors stemming from my local .env. An example of some of the error messages: ./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3848:80: E501 line too long (85 > 79…
Toms Code
  • 1,439
  • 3
  • 15
  • 34
22
votes
0 answers

Which atom python linting packages are stable?

It seems that there are too many Python linting packages and I am wonder which one should we use. I suspect installing two will provide a confusing experience, if not even triggering weird bugs. python-autopep8 - 20+ linter-python-flaks -…
sorin
  • 161,544
  • 178
  • 535
  • 806
21
votes
1 answer

How to fix issues with E402?

We are trying to fix issues with PEP8 E402. Mostly our code is broken on: import os os.environ['LIB_CAN_THROW_ERROR_ON_IMPORT'] = 2 import lib os.environ['LIB_CAN_THROW_ERROR_ON_IMPORT'] = 0 # back - if sys.version_info[0] > 2: import…
aleskva
  • 1,644
  • 2
  • 21
  • 40
20
votes
2 answers

Specify per-file-ignores with pyproject.toml and flake8

I am using flake8 (with flakehell but that should not interfere) and keep its configuration in a pyproject.toml file. I want to add a per-file-ignores config but nothing works and there is no documentation on how it is supposed to be formatted in a…
Piotr Zakrzewski
  • 3,591
  • 6
  • 26
  • 28
19
votes
3 answers

Python AutoPep8 formatting not working with max line length parameter

I noticed one strange thing that autopep8 autoformatting in VSCode doesn't work when we set "python.formatting.autopep8Args": [ "--line-length 119" ], But if this setting is in a default mode that is line length 79 then it works…
Mohit Kumar
  • 533
  • 1
  • 4
  • 11
19
votes
1 answer

How to avoid flake8's "F821 undefined name '_'" when _ has been installed by gettext?

Problem overview: In my project's main script, gettext installs the function _() that is used in other modules for translations (like in print(_('Something to translate'))). As stated by the doc: the _() function [is] installed in Python’s builtins…
zezollo
  • 4,606
  • 5
  • 28
  • 59
19
votes
6 answers

vim-flake8 is not working

I installed vim-flake8 by git cloning it on my Pathogen bundle folder as usual, but when I tried to run the plugin pressing F7 or using :call Flake8() in one Python file I receive the following message: Error detected while processing function…
Jonatas Eduardo
  • 655
  • 2
  • 9
  • 17
18
votes
3 answers

Syntax Error with flake8 and Pydantic Constrained Types: constr(regex=)

I use in Python the package pydantic and the linker Flake8. I want to use constr from pydantic with a regular Experssion. Only certain Characters should be passed. (a-z, A-Z, 0-9 and _) The regular Experssion "^[a-zA-Z0-9_]*$" works, but flake8…
Phil997
  • 575
  • 5
  • 15
18
votes
2 answers

flake8/pylint fails in Tox testing environment, raises InvocationError

I've been learning about how to do testing in tox for my python project. I have (what should be) a fairly standard tox initialization file that looks like the following: [tox] envlist=py27,flake8 ... [testenv:flake8] deps=flake8 commands=flake8…
kazimir.r
  • 387
  • 1
  • 3
  • 9
17
votes
2 answers

Flake8 disable all formatting rules

I use flake8 for linting and black for formatting. flake8 produces warnings on execution rules and formatting rules: I only want to see execution rules. I don't care about formatting rules because they'll automatically get fixed by black…
Brian Malehorn
  • 2,627
  • 14
  • 15
1
2
3
27 28