ci: added flake8
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index c67c0e8..ff73e69 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -41,3 +41,24 @@
uses: psf/black@stable
with:
src: ./atmosphere
+
+ flake8:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout project
+ uses: actions/checkout@v3.0.2
+
+ - name: Install Poetry
+ run: pipx install poetry
+
+ - name: Setup Python
+ uses: actions/setup-python@v4.2.0
+ with:
+ cache: poetry
+
+ - name: Install dependencies
+ run: poetry install --no-interaction
+
+ - name: Run Flake8
+ run: poetry run flake8 ./atmosphere
+
diff --git a/atmosphere/models/conf.py b/atmosphere/models/conf.py
index 856148a..73d4f6f 100644
--- a/atmosphere/models/conf.py
+++ b/atmosphere/models/conf.py
@@ -1,5 +1,4 @@
import tomli
-
from schematics import types
from atmosphere.models import base
diff --git a/atmosphere/models/openstack_helm/values.py b/atmosphere/models/openstack_helm/values.py
index a123b6a..7bd81da 100644
--- a/atmosphere/models/openstack_helm/values.py
+++ b/atmosphere/models/openstack_helm/values.py
@@ -1,14 +1,12 @@
import base64
+import pykube
+import yaml
from schematics import types
from schematics.transforms import blacklist
-import yaml
-import pykube
from atmosphere.models import base
-from atmosphere.models.openstack_helm import endpoints
-from atmosphere.models.openstack_helm import images
-from atmosphere.models.openstack_helm import monitoring
+from atmosphere.models.openstack_helm import endpoints, images, monitoring
class Values(base.Model):
@@ -51,7 +49,7 @@
resource = self.secret()
secret = pykube.Secret(api, resource)
- if secret.exists() != True:
+ if not secret.exists():
secret.create()
if secret.obj["data"] != resource["data"]:
diff --git a/atmosphere/shell.py b/atmosphere/shell.py
index ebfc23f..35ee45e 100644
--- a/atmosphere/shell.py
+++ b/atmosphere/shell.py
@@ -1,13 +1,13 @@
import click
import pykube
-from atmosphere.models import conf
from atmosphere import deploy
+from atmosphere.models import conf
@click.command()
@click.option("--config", help="Path to Atmosphere config file", required=True)
-def deploy(config):
+def run(config):
config = conf.from_file(config)
kube_config = pykube.KubeConfig.from_env()
@@ -17,4 +17,4 @@
if __name__ == "__main__":
- deploy()
+ run()
diff --git a/atmosphere/tests/unit/models/openstack_helm/test_endpoints.py b/atmosphere/tests/unit/models/openstack_helm/test_endpoints.py
index 93516ba..488bc7e 100644
--- a/atmosphere/tests/unit/models/openstack_helm/test_endpoints.py
+++ b/atmosphere/tests/unit/models/openstack_helm/test_endpoints.py
@@ -1,6 +1,4 @@
-import uuid
import pytest
-
from schematics import exceptions
from atmosphere.models import conf
diff --git a/atmosphere/tests/unit/models/openstack_helm/test_images.py b/atmosphere/tests/unit/models/openstack_helm/test_images.py
index fb5caf2..3f315d3 100644
--- a/atmosphere/tests/unit/models/openstack_helm/test_images.py
+++ b/atmosphere/tests/unit/models/openstack_helm/test_images.py
@@ -1,5 +1,3 @@
-import uuid
-
from atmosphere.models import conf
from atmosphere.models.openstack_helm import images as osh_images
diff --git a/atmosphere/tests/unit/models/openstack_helm/test_values.py b/atmosphere/tests/unit/models/openstack_helm/test_values.py
index 0223ae5..c33615b 100644
--- a/atmosphere/tests/unit/models/openstack_helm/test_values.py
+++ b/atmosphere/tests/unit/models/openstack_helm/test_values.py
@@ -1,5 +1,5 @@
-import pytest
import pykube
+import pytest
from atmosphere.models import conf
from atmosphere.models.openstack_helm import values as osh_values
diff --git a/atmosphere/tests/unit/models/test_config.py b/atmosphere/tests/unit/models/test_config.py
index dff8510..c1aa2cf 100644
--- a/atmosphere/tests/unit/models/test_config.py
+++ b/atmosphere/tests/unit/models/test_config.py
@@ -1,6 +1,6 @@
-import pytest
import uuid
+import pytest
from schematics import exceptions
from atmosphere.models import conf
@@ -16,7 +16,7 @@
def test_from_toml_with_valid_configuration():
try:
data = conf.from_toml(VALID_CONFIG)
- except:
+ except exceptions.DataError:
pytest.fail("Failed to parse valid configuration")
assert data.memcached.secret_key == MEMCACHE_SECRET_KEY
@@ -24,7 +24,7 @@
def test_from_toml_with_invalid_configuration():
with pytest.raises(exceptions.DataError):
- data = conf.from_toml("")
+ conf.from_toml("")
def test_from_file_with_valid_configuration(tmp_path):
@@ -33,7 +33,7 @@
try:
data = conf.from_file(path)
- except:
+ except exceptions.DataError:
pytest.fail("Failed to parse valid configuration")
assert data.memcached.secret_key == MEMCACHE_SECRET_KEY
@@ -44,11 +44,11 @@
path.write_text("")
with pytest.raises(exceptions.DataError):
- data = conf.from_file(path)
+ conf.from_file(path)
def test_from_file_with_missing_file(tmp_path):
path = tmp_path / "config.toml"
with pytest.raises(FileNotFoundError):
- data = conf.from_file(path)
+ conf.from_file(path)
diff --git a/poetry.lock b/poetry.lock
index 380be36..128a29c 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -54,6 +54,34 @@
toml = ["tomli"]
[[package]]
+name = "flake8"
+version = "5.0.4"
+description = "the modular source code checker: pep8 pyflakes and co"
+category = "dev"
+optional = false
+python-versions = ">=3.6.1"
+
+[package.dependencies]
+mccabe = ">=0.7.0,<0.8.0"
+pycodestyle = ">=2.9.0,<2.10.0"
+pyflakes = ">=2.5.0,<2.6.0"
+
+[[package]]
+name = "flake8-isort"
+version = "4.2.0"
+description = "flake8 plugin that integrates isort ."
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+flake8 = ">=3.2.1,<6"
+isort = ">=4.3.5,<6"
+
+[package.extras]
+test = ["pytest-cov"]
+
+[[package]]
name = "idna"
version = "3.4"
description = "Internationalized Domain Names in Applications (IDNA)"
@@ -70,6 +98,28 @@
python-versions = "*"
[[package]]
+name = "isort"
+version = "5.10.1"
+description = "A Python utility / library to sort Python imports."
+category = "dev"
+optional = false
+python-versions = ">=3.6.1,<4.0"
+
+[package.extras]
+colors = ["colorama (>=0.4.3,<0.5.0)"]
+pipfile_deprecated_finder = ["pipreqs", "requirementslib"]
+plugins = ["setuptools"]
+requirements_deprecated_finder = ["pip-api", "pipreqs"]
+
+[[package]]
+name = "mccabe"
+version = "0.7.0"
+description = "McCabe checker, plugin for flake8"
+category = "dev"
+optional = false
+python-versions = ">=3.6"
+
+[[package]]
name = "packaging"
version = "21.3"
description = "Core utilities for Python packages"
@@ -101,6 +151,22 @@
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
+name = "pycodestyle"
+version = "2.9.1"
+description = "Python style guide checker"
+category = "dev"
+optional = false
+python-versions = ">=3.6"
+
+[[package]]
+name = "pyflakes"
+version = "2.5.0"
+description = "passive checker of Python programs"
+category = "dev"
+optional = false
+python-versions = ">=3.6"
+
+[[package]]
name = "pykube-ng"
version = "22.7.0"
description = "Python client library for Kubernetes"
@@ -246,7 +312,7 @@
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
-content-hash = "5c1cfa45619c49a96407337026b89fe242627373afde440cc3633bb679acc566"
+content-hash = "878e26cc2b4158be9e89c5f00f83895dc93e9fd180fb44c739afdaa87d0a3430"
[metadata.files]
attrs = [
@@ -317,6 +383,14 @@
{file = "coverage-6.4.4-pp36.pp37.pp38-none-any.whl", hash = "sha256:f67cf9f406cf0d2f08a3515ce2db5b82625a7257f88aad87904674def6ddaec1"},
{file = "coverage-6.4.4.tar.gz", hash = "sha256:e16c45b726acb780e1e6f88b286d3c10b3914ab03438f32117c4aa52d7f30d58"},
]
+flake8 = [
+ {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"},
+ {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"},
+]
+flake8-isort = [
+ {file = "flake8-isort-4.2.0.tar.gz", hash = "sha256:26571500cd54976bbc0cf1006ffbcd1a68dd102f816b7a1051b219616ba9fee0"},
+ {file = "flake8_isort-4.2.0-py3-none-any.whl", hash = "sha256:5b87630fb3719bf4c1833fd11e0d9534f43efdeba524863e15d8f14a7ef6adbf"},
+]
idna = [
{file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"},
{file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
@@ -325,6 +399,14 @@
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
]
+isort = [
+ {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"},
+ {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"},
+]
+mccabe = [
+ {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},
+ {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
+]
packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
@@ -337,6 +419,14 @@
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
]
+pycodestyle = [
+ {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"},
+ {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"},
+]
+pyflakes = [
+ {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"},
+ {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"},
+]
pykube-ng = [
{file = "pykube-ng-22.7.0.tar.gz", hash = "sha256:1d59564485eea86677c695cc0724b4998bc5ff0b69e37d21fa8bf36379b683ce"},
{file = "pykube_ng-22.7.0-py3-none-any.whl", hash = "sha256:b804e1f1ded3ec202b97837517a40f4f0a13278236452fa09b9186a447187c8a"},
diff --git a/pyproject.toml b/pyproject.toml
index cbadbca..1c7be9a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,6 +17,8 @@
pytest-mock = "^3.8.2"
pytest-cov = "^3.0.0"
pytest-kind = "^22.9.0"
+flake8 = "^5.0.4"
+flake8-isort = "^4.2.0"
[build-system]
requires = ["poetry-core"]