Questions tagged [pyflakes]

Pyflakes analyzes Python source code non-intrusively to check for errors.

Pyflakes analyzes Python source code non-intrusively to check for errors.

Similar to the C language source code analyzer lint, Pyflakes performs similar function on Python source code. It can be used to check for simple errors like misplaced quotes, code indentation inconsistencies, syntax errors, referenced but undeclared variables, unused imported modules, etc. A very useful tool for any Python developer's toolkit!

See also:

83 questions
406
votes
2 answers

Pylint, PyChecker or PyFlakes?

I would like to get some feedback on these tools on: features; adaptability; ease of use and learning curve.
Bite code
  • 578,959
  • 113
  • 301
  • 329
151
votes
9 answers

How do I get Pyflakes to ignore a statement?

A lot of our modules start with: try: import json except ImportError: from django.utils import simplejson as json # Python 2.4 fallback. ...and it's the only Pyflakes warning in the entire file: foo/bar.py:14: redefinition of unused 'json'…
a paid nerd
  • 30,702
  • 30
  • 134
  • 179
62
votes
6 answers

How to ignore Pyflakes errors ‘imported but unused’ in ‘__init__.py’ files?

I split my tests across multiple Python files: tests ├── __init__.py ├── test_apples.py └── test_bananas.py.py I import the tests in the ‘__init__.py’ file: from test_apples import ApplesTest from test_bananas import BananasTest However running…
Venkatesh Bachu
  • 2,348
  • 1
  • 18
  • 28
39
votes
1 answer

Set pyflake AND mypy ignore same line

I write a module for Salt. By the documentation it adds __salt__ object into builtins. So, pyflake warn me that __salt__ is undefined when I run prospector and mypy says the same, that __salt__ is undefined! I can ignore either for pyflake with #…
senior_pimiento
  • 702
  • 1
  • 5
  • 15
28
votes
2 answers

Excluding directory

I am working on a django project and am trying to run pyflakes on an app in it. I need to exclude the "migrations" directory from pyflakes. For pep8 I can do pep8 --exclude=migrations app_name Is there any similar way for pyflakes? I couldn't…
user3148949
  • 578
  • 1
  • 9
  • 22
23
votes
4 answers

How can I use Emacs Flymake mode for python with pyflakes and pylint checking code?

For checking code in python mode I use flymake with pyflakes Also I want check code style (pep8) with pylint (description on the same page with pyflakes) This solutions work. But I can't configure flymake for work with pyflakes and pylint…
dixon
  • 1,265
  • 2
  • 9
  • 10
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
17
votes
1 answer

How can I disable flake8 for a multiline import?

With flake8, to disable a certain error on a line you do this: example = lambda: 'example' # noqa: E731,E123 However, if I have multiline a statement, flake8 fails to parse the noqa statment at the end: from detect_fixtures import…
M.R.
  • 1,053
  • 2
  • 13
  • 30
17
votes
2 answers

Running pyflakes remotely with flymake and tramp in emacs?

I'm trying to use flymake to run pyflakes, as suggested here This works fine for local files, and almost works with remote files with a bit of tweaking, but I'm left with a problem where flymake/pyflakes 'modifies' the buffer when it runs (although…
phils
  • 71,335
  • 11
  • 153
  • 198
11
votes
3 answers

fix pyflakes dealing with @property setter decorator

Pyflakes does not deal very well with the following code: @property def nodes(self): return self._nodes @nodes.setter def nodes(self, nodes): """ set the nodes on this object. """ assert nodes != [] # without nodes no route.. …
Stephan
  • 3,679
  • 3
  • 25
  • 42
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
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
8
votes
1 answer

How do I follow python PEP8 regarding line breaks, and how important is it?

I am writing in python 3.5.1 and I am a programming novice. I use gedit with a pep8 and pyflakes plugins showing style mistakes according to the python style guide. I do not know whether to follow the style recommendation to the letter or not. I…
Til Hund
  • 1,543
  • 5
  • 21
  • 37
8
votes
2 answers

How to let pyflakes ignore some errors?

I am using SublimePythonIDE which is using pyflakes. There are some errors that I would like it to ignore like: (E501) line too long (E101) indentation contains mixed spaces and tabs What is the easiest way to do that?
user3571278
  • 721
  • 5
  • 15
1
2 3 4 5 6