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

flake8 not showing fatal erros in vscode

Vscode is not showing fatal erros in vscode. It is only highlighting warnings in the code. Example: I have vscode running flake8 from a virtualenv with python 2.7. The settings is as following: "python.linting.flake8Enabled": true, I'm comparing…
Raphael Philipe
  • 171
  • 2
  • 5
8
votes
1 answer

Is there any linter that detects blocking calls in an async function?

https://www.aeracode.org/2018/02/19/python-async-simplified/ It's not going to ruin your day if you call a non-blocking synchronous function, like this: def get_chat_id(name): return "chat-%s" % name async def main(): result =…
Anentropic
  • 32,188
  • 12
  • 99
  • 147
8
votes
1 answer

Running flake8 gives - AttributeError: 'OptionManager' object has no attribute 'config_options'

I installed flake8 using the following command. pip3 install flake8 Executing flake8 from terminal gives the following error. Traceback (most recent call last): File "/home/bilesh/.local/bin/flake8", line 11, in sys.exit(main()) …
Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
8
votes
4 answers

How to format Django setting file for flake8

I am kinda obsessed with formating my python code with flake8. However, I cannot find a good way to solve E501 (line too long x > 79 characters) in settings file of Django. First it was like this (4xE501): AUTH_PASSWORD_VALIDATORS = [ { …
mdegis
  • 2,078
  • 2
  • 21
  • 39
7
votes
1 answer

How to satisfy "[FLAKE8 W605] invalid escape sequence '\.'" and string format in the mean time?

I have an issue in python. My original regex expression is: f"regex(metrics_api_failure\.prod\.[\w_]+\.{method_name}\.\d+\.\d+\.[\w_]+\.[\w_]+\.sum\.60)" (method_name is a local variable) and I got a lint warning: "[FLAKE8 W605] invalid escape…
Aurora
  • 423
  • 2
  • 5
  • 12
7
votes
2 answers

Mypy + flake8: Is there any way to surpress warning of `F821 undefined name`

In the following code, flake8 say F821 undefined name 'B'. But for mypy, type hint for f is neccesary. How to ignore such warnings by flake8? def f(b: B) -> None: pass class B(): pass This example can be solved trivially: change the…
nomaddo
  • 416
  • 3
  • 12
7
votes
2 answers

Is it possible to ignore only certain error codes for entire files in Flake8?

I'm editing a Django settings file that looks similar to the following: # flake8: noqa from lucy.settings.base import * from lucy.settings.staging_production import * # This ensures that errors from staging are tagged accordingly in Airbrake's…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
7
votes
2 answers

Flake8 reports E999 SyntaxError

I am unable to solve the flake8 SyntaxError and although the code executes just fine. Code without comments import math def answer(str_n): sume = ((str_n * (str_n + 1)) / 2) * math.sqrt(2) sume = int(sume) return sume def…
Omi Harjani
  • 737
  • 1
  • 8
  • 20
7
votes
2 answers

How to directly use Axes3D from matplotlib in standard plot to avoid flake8 error

When using the typical 3D plot like so: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax = fig.gca(projection='3d') flake8 reports the expected error: ./tools.py:62:9: F401 'mpl_toolkits.mplot3d.Axes3D'…
dsalaj
  • 2,857
  • 4
  • 34
  • 43
7
votes
1 answer

flake8 not reporting on lines that are too long

If I create a file test.py with the following poorly-formatted contents: import re long_string = "foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" class Foo(): pass and run flake8 on the file from the…
elethan
  • 16,408
  • 8
  • 64
  • 87
6
votes
2 answers

How to suppress a warning in one line for pylint and Flake8 at the same time

I would like to ignore a specific line in static code analysis. For Flake8, I'd use the syntax # noqa: F401. For pylint, I'd use the syntax # pylint: disable=unused-import. As I am working on a code generation framework, I would like the code to…
jraufeisen
  • 3,005
  • 7
  • 27
  • 43
6
votes
2 answers

Can a class attribute shadow a built-in in Python?

If have some code like this: class Foo(): def open(self, bar): # Doing some fancy stuff here, i.e. opening "bar" pass When I run flake8 with the flake8-builtins plug-in I get the error A003 class attribute "open" is shadowing a…
SebDieBln
  • 3,303
  • 1
  • 7
  • 21
6
votes
1 answer

How to format this code so that flake8 is happy?

This code was created by black: def test_schema_org_script_from_list(): assert ( schema_org_script_from_list([1, 2]) == '\n' ) But now…
guettli
  • 25,042
  • 81
  • 346
  • 663
6
votes
1 answer

Docstring invalid escape sequence triggered by a display equation in latex

I put a latex math expression in the docstring for a function in Python. It triggers a error "W605 invalid escape sequence" which breaks flake8 checking. How to fix it? """ The test function is defined as: \sin(\pi x)/x """ I solved this by using…
susanna
  • 1,395
  • 3
  • 20
  • 32
6
votes
1 answer

Does flake8 require any installation of my Python project's dependencies?

Is Flake8 a pure static code analyser or should I run pip install -r requirements.txt first? Or, is there any use case where Flake8 can use the installed dependencies?
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168