Skip to content

Commit

Permalink
Drop Python2 build, test, and install
Browse files Browse the repository at this point in the history
This commit drops building of Python 2.7 in our build matrix. It
also changes the testing of pylint and pep8 from 2.7 to 3.5. And
no longer should the binary be installable on Py2.7 via the change
to setup.py.

Partially-Fixes: #584

Signed-off-by: Eric Brown <browne@vmware.com>
  • Loading branch information
ericwb committed May 18, 2020
1 parent 59cd94e commit b78c938
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 36 deletions.
24 changes: 2 additions & 22 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7]
python-version: [3.5]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7]
python-version: [3.5]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -43,26 +43,6 @@ jobs:
- name: Run tox
run: tox -e pep8

py27:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r test-requirements.txt
pip install tox
- name: Run tox
run: tox -e py27

py35:
runs-on: ubuntu-latest
strategy:
Expand Down
6 changes: 3 additions & 3 deletions bandit/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ def _parse_file(self, fname, fdata, new_files_list):
lineno for toktype, tokval, (lineno, _), _, _ in tokens
if toktype == tokenize.COMMENT and
'#nosec' in tokval or '# nosec' in tokval)
except tokenize.TokenError as e:
except tokenize.TokenError:
nosec_lines = set()
score = self._execute_ast_visitor(fname, data, nosec_lines)
self.scores.append(score)
self.metrics.count_issues([score, ])
except KeyboardInterrupt as e:
except KeyboardInterrupt:
sys.exit(2)
except SyntaxError as e:
except SyntaxError:
self.skipped.append((fname,
"syntax error while parsing AST from file"))
new_files_list.remove(fname)
Expand Down
2 changes: 1 addition & 1 deletion bandit/formatters/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _output_issue_str(issue, indent, show_lineno=True, show_code=True,
indent, docs_utils.get_url(issue.test_id), COLOR['DEFAULT']))

if show_code:
bits.extend([indent + l for l in
bits.extend([indent + line for line in
issue.get_code(lines, True).split('\n')])

return '\n'.join([bit for bit in bits])
Expand Down
2 changes: 1 addition & 1 deletion bandit/formatters/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _output_issue_str(issue, indent, show_lineno=True, show_code=True,
indent, docs_utils.get_url(issue.test_id)))

if show_code:
bits.extend([indent + l for l in
bits.extend([indent + line for line in
issue.get_code(lines, True).split('\n')])

return '\n'.join([bit for bit in bits])
Expand Down
3 changes: 2 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
# W0621: redefined-outer-name
# W0703: broad-except
# W1201: logging-not-lazy
disable=C0111,C0201,C0301,C0325,C1801,F0401,W0511,W0142,W0622,C0103,E1101,E1111,R0902,R0912,R0913,R0914,R0915,R1702,R1705,R1710,W0110,W0141,W0201,W0401,W0603,W0212,W0613,W0621,W0703,W1201
# W1505: deprecated-method
disable=C0111,C0201,C0301,C0325,C1801,F0401,W0511,W0142,W0622,C0103,E1101,E1111,R0902,R0912,R0913,R0914,R0915,R1702,R1705,R1710,W0110,W0141,W0201,W0401,W0603,W0212,W0613,W0621,W0703,W1201,W1505

[Basic]
# Variable names can be 1 to 31 characters long, with lowercase and underscores
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ classifier =
Operating System :: POSIX :: Linux
Operating System :: MacOS :: MacOS X
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
pass

setuptools.setup(
python_requires='>=3.5',
setup_requires=['pbr>=2.0.0'],
pbr=True)
4 changes: 2 additions & 2 deletions tests/unit/core/test_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_issue_as_dict(self):

def test_issue_filter_severity(self):
levels = [bandit.LOW, bandit.MEDIUM, bandit.HIGH]
issues = [_get_issue_instance(l, bandit.HIGH) for l in levels]
issues = [_get_issue_instance(level, bandit.HIGH) for level in levels]

for level in levels:
rank = constants.RANKING.index(level)
Expand All @@ -52,7 +52,7 @@ def test_issue_filter_severity(self):

def test_issue_filter_confidence(self):
levels = [bandit.LOW, bandit.MEDIUM, bandit.HIGH]
issues = [_get_issue_instance(bandit.HIGH, l) for l in levels]
issues = [_get_issue_instance(bandit.HIGH, level) for level in levels]

for level in levels:
rank = constants.RANKING.index(level)
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/core/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ def test_populate_baseline_invalid_json(self, mock_logger_warning):
def test_results_count(self):
levels = [constants.LOW, constants.MEDIUM, constants.HIGH]
self.manager.results = (
[issue.Issue(severity=l, confidence=l) for l in levels])
[issue.Issue(severity=level, confidence=level)
for level in levels])

r = [self.manager.results_count(sev_filter=l, conf_filter=l)
for l in levels]
r = [self.manager.results_count(sev_filter=level, conf_filter=level)
for level in levels]

self.assertEqual([3, 2, 1], r)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 2.0
envlist = py35,py27,pep8
envlist = py35,pep8
skipsdist = True

[testenv]
Expand Down

0 comments on commit b78c938

Please sign in to comment.