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
10
votes
2 answers

Ignoring a specific flake8 rule for a folder

I am using flake8, flake8-docstrings and many other flake8 plugins in our project I want to disable flake8-docstrings only for our test folder. I want to avoid running flake8 twice because it would mean that running flake8 wouldn't be the straight…
tibo
  • 5,326
  • 4
  • 37
  • 53
10
votes
3 answers

How can I fix `flake8 D100 — Missing docstring` error in atom editor

I installed atom for python programming and also installed Linter and flake8 packages but everything I write in text editor I get this warning : D100 — Missing docstring in public module I already tried pip uninstall flake8-docstrings pip…
Sami Soheili
  • 123
  • 1
  • 1
  • 10
9
votes
1 answer

Pre-commit suddenly fails to install Flake8

The pre-commit run suddenly fails without changes being made to the pre-commit configuration file. The log shows the following error message when attempting to initialise the environment for Flake8: ... [INFO] Initializing environment for…
Roald Nefs
  • 1,302
  • 10
  • 29
9
votes
2 answers

Auto format flake8 linting errors in VSCode

I'm using the flake8 linter for Python and I have many code formats issues like blank line contains whitespace flake8(W293) I'm trying to auto fix these linting issues. I have these settings: "python.linting.enabled": true, …
nrofis
  • 8,975
  • 14
  • 58
  • 113
9
votes
4 answers

Getting flake8 returned a non none zero code : 1 in docker

I was following this article. https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/#production-dockerfile In the Production Dockerfile section, the Dockerfile.prod file has these lines. # lint RUN pip install --upgrade…
Aashay Amballi
  • 1,321
  • 3
  • 17
  • 39
9
votes
1 answer

flake8: import statements are in the wrong order

PEP8 suggests that: Imports should be grouped in the following order: standard library imports related third party imports local application/library specific imports You should put a blank line between each group of imports. I am using…
pangpang
  • 8,581
  • 11
  • 60
  • 96
9
votes
3 answers

how to fix the "W293 blank line contains whitespace"

my python code produce the following warning message: (1) \dir\file.py:8:1 W293 blank lines contains whitespace this comes after commands[0] flake8 XXX how do you fix the issue?
PChao
  • 417
  • 2
  • 5
  • 17
9
votes
1 answer

Indentation configuration in flake8

My project uses a width of 4 spaces for indentation. However, running flake8 on it yields warnings that say that expected tab/indentation width was 2 spaces. How do I configure flake8 to correctly accept 4 spaces for indentation? class…
Amey
  • 2,214
  • 2
  • 19
  • 28
8
votes
1 answer

Why does flake8 give the warning F821 -- undefined name 'match' when using match.group(0) with Python 3

Please consider the following example, which finds the first String in a list that contains the Substring "OH": list = ["STEVE", "JOHN", "YOANN"] pattern = re.compile(".*%s.*" % "OH") word = "" if any((match := pattern.match(item)) for item in…
Paul Lemarchand
  • 2,068
  • 1
  • 15
  • 27
8
votes
2 answers

How can I make flake8 only detect errors?

I use flake8 as python linter in vscode. I want flake8 to ignore all warning, but I can't find any option to detect error-only after searching flake8 documentation. So, how can I achieve this? Any help?
Spaceship222
  • 759
  • 10
  • 20
8
votes
4 answers

flake8 linting for databricks python code in github using workflows

I have my databricks python code in github. I setup a basic workflow to lint the python code using flake8. This fails because the names that are implicitly available to my script (like spark, sc, dbutils, getArgument etc) when it runs on databricks…
Kashyap
  • 15,354
  • 13
  • 64
  • 103
8
votes
1 answer

Flake8 not giving errors/warnings on missing docstring or code not following PEP8 naming convention

I am trying to run Flake8 for my python code however I'm noticing it's not giving me any of the PyDocStyle errors on a simple class with missing docstrings or warning about my class name cars which should be Cars according to PEP8 style…
alex
  • 1,905
  • 26
  • 51
8
votes
2 answers

Where to place __all__ in a Python file?

I am wondering, what the standard placement in a Python file for __all__? My assumption is directly below the import statements. However, I could not find this explicitly stated/asked anywhere. So, in general, where should one place __all__? Where…
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
8
votes
5 answers

VS Code > Preferences > User Settings > Extensions > Python > Linting > Flake8 Args Added Item stopped working

Please don't treat this as an "asked and answered" question. I sincerely have been clobbering to try to figure out why this has stopped working, if it's a VS Code problem, or a Flake8 one, or if I'm just crazy and should find another way around…
user258081
  • 301
  • 2
  • 8
8
votes
2 answers

Python flake8 py reporting W391 (no newline at end of file) incorrectly

W391 says that there should be one (and only one) blank line at the end of file. However, flake8 reports the error when there is at least one newline at the end of the file: $ cat /tmp/test.py def hello(): print('hello') hello() $ hexdump…
Ben Davis
  • 13,112
  • 10
  • 50
  • 65