Skip to content

Commit cb17fb5

Browse files
authored
GH action and fix linter (#160)
* Fix lint * Added GH Action
1 parent 2e32e9e commit cb17fb5

File tree

10 files changed

+78
-30
lines changed

10 files changed

+78
-30
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.7, 3.8]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install pipenv
30+
pipenv lock --dev --requirements > requirements.txt
31+
pip install -r requirements.txt
32+
- name: Test with pytest
33+
run: |
34+
python setup.py test
35+
- name: Lint with flake8
36+
run: |
37+
# stop the build if there are Python syntax errors or undefined names
38+
flake8 pyms --show-source --statistics --statistics
39+
- name: Lint with pylint
40+
run: |
41+
pylint --rcfile=pylintrc pyms
42+
- name: Security safety
43+
run: |
44+
safety check
45+
- name: Security bandit
46+
run: |
47+
bandit -r pyms/

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
language: python
22
python:
3-
- "3.6"
4-
- "3.7"
53
- "3.8"
64
install:
7-
- pip install --upgrade setuptools tox tox-travis coveralls
5+
- python -m pip install --upgrade pip
6+
- pip install --upgrade setuptools coveralls pipenv
7+
- pipenv lock --dev --requirements > requirements.txt
8+
- pip install -r requirements.txt
89
script:
910
- coverage erase
10-
- tox
11+
- python setup.py test
1112
after_success:
1213
- coverage combine
1314
- coveralls

Pipfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@ py-ms = {editable = true,extras = ["tests"],path = "."}
88

99
[packages]
1010
py-ms = {editable = true,extras = ["all"],path = "."}
11-
12-
[requires]
13-
python_version = "3.7"

Pipfile.lock

Lines changed: 11 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyms/config/confile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, *args, **kwargs):
5151

5252
config = self.set_config(config)
5353

54-
super(ConfFile, self).__init__(config)
54+
super().__init__(config)
5555

5656
def to_flask(self) -> Dict:
5757
return ConfFile(config={k.upper(): v for k, v in self.items()}, crypt=self._crypt_cls)
@@ -110,10 +110,10 @@ def __getattr__(self, name, *args, **kwargs):
110110
for k in keys:
111111
aux_dict = aux_dict[k]
112112
return aux_dict
113-
except KeyError:
113+
except KeyError as e:
114114
if self._empty_init:
115115
return ConfFile(config={}, empty_init=self._empty_init, crypt=self._crypt_cls)
116-
raise AttrDoesNotExistException("Variable {} not exist in the config file".format(name))
116+
raise AttrDoesNotExistException("Variable {} not exist in the config file".format(name)) from e
117117

118118
def reload(self):
119119
"""
@@ -124,4 +124,4 @@ def reload(self):
124124
self.set_config(config_src)
125125

126126
def __setattr__(self, name, value, *args, **kwargs):
127-
super(ConfFile, self).__setattr__(name, value)
127+
super().__setattr__(name, value)

pyms/flask/services/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class MetricsLogHandler(logging.Handler):
7777
"""A LogHandler that exports logging metrics for Prometheus.io."""
7878

7979
def __init__(self, app_name):
80-
super(MetricsLogHandler, self).__init__()
80+
super().__init__()
8181
self.app_name = app_name
8282

8383
def emit(self, record):

pyms/logger/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CustomJsonFormatter(jsonlogger.JsonFormatter):
1616
tracer = ""
1717

1818
def add_fields(self, log_record, record, message_dict):
19-
super(CustomJsonFormatter, self).add_fields(log_record, record, message_dict)
19+
super().add_fields(log_record, record, message_dict)
2020
if not log_record.get('timestamp'):
2121
# this doesn't use record.created, so it is slightly off
2222
now = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%fZ')

setup.cfg

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
[aliases]
2-
test=pytest
2+
test = pytest
33

44
[tool:pytest]
5-
addopts = --cov=pyms --cov=tests tests/
5+
addopts = --cov=pyms --cov=tests tests/
6+
7+
[flake8]
8+
ignore = E501
9+
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
10+
max-complexity = 12
11+
max-line-length = 120

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright (c) 2018 by Alberto Vara <albertovara@paradigmadigital.com>
32
import codecs
43
import os

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ commands =
3434
[testenv:flake8]
3535
basepython = python3.7
3636
commands =
37-
flake8 --ignore=E501 {toxinidir}/pyms
37+
flake8 {toxinidir}/pyms --show-source --statistics --statistics
3838
[testenv:docs]
3939
basepython = python3.7
4040
skipsdist = True

0 commit comments

Comments
 (0)