Skip to content

Commit 05548a3

Browse files
authored
Switch to flake8 for static code analysis (#1328)
flake8 catches a wider net of mistakes than pycodestyle and is more commonly used by the larger community. For example, it catches unused imports, a few of which existed. These have since been removed. Two "noqa" comments were added. One ignores the _compat.py file as it has a large amount of Python version specific code. The second is in utils.py which intentionally does not use an import.
1 parent ae173f0 commit 05548a3

File tree

8 files changed

+9
-12
lines changed

8 files changed

+9
-12
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: python
22
cache: pip
33
matrix:
44
include:
5-
- env: TOXENV=pycodestyle
5+
- env: TOXENV=flake8
66
- python: 2.7
77
env: TOXENV=py27-plain
88
- python: 2.7
@@ -39,4 +39,4 @@ install:
3939
script:
4040
- tox
4141
after_success:
42-
- "if [[ $TOXENV != 'pycodestyle' ]]; then codecov; fi"
42+
- "if [[ $TOXENV != 'flake8' ]]; then codecov; fi"

benchmarks/command_packer_benchmark.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import socket
2-
import sys
32
from redis.connection import (Connection, SYM_STAR, SYM_DOLLAR, SYM_EMPTY,
43
SYM_CRLF)
54
from redis._compat import imap

redis/_compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Internal module for Python 2 backwards compatibility."""
2+
# flake8: noqa
23
import errno
34
import socket
45
import sys

redis/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import unicode_literals
22
from itertools import chain
33
import datetime
4-
import sys
54
import warnings
65
import time
76
import threading

redis/connection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import io
77
import os
88
import socket
9-
import sys
109
import threading
1110
import warnings
1211

redis/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
try:
5-
import hiredis
5+
import hiredis # noqa
66
HIREDIS_AVAILABLE = True
77
except ImportError:
88
HIREDIS_AVAILABLE = False

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
3535
[options.extras_require]
3636
hiredis = hiredis>=0.1.3
3737

38-
[pycodestyle]
39-
show-source = 1
38+
[flake8]
4039
exclude = .venv,.tox,dist,docs,build,*.egg,redis_install
4140

4241
[bdist_wheel]

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 2.4
3-
envlist = {py27,py35,py36,py37,py38,py,py3}-{plain,hiredis}, pycodestyle
3+
envlist = {py27,py35,py36,py37,py38,py,py3}-{plain,hiredis}, flake8
44

55
[testenv]
66
deps =
@@ -11,9 +11,9 @@ extras =
1111
hiredis: hiredis
1212
commands = {envpython} -b -m coverage run -m pytest -W always {posargs}
1313

14-
[testenv:pycodestyle]
14+
[testenv:flake8]
1515
basepython = python3.6
16-
deps = pycodestyle
17-
commands = pycodestyle
16+
deps = flake8
17+
commands = flake8
1818
skipsdist = true
1919
skip_install = true

0 commit comments

Comments
 (0)