Skip to content

Commit

Permalink
add ruff and fix format and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed May 12, 2024
1 parent 38a0f2c commit 5c301d9
Show file tree
Hide file tree
Showing 23 changed files with 2,845 additions and 2,504 deletions.
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
PYTHON_CMD := $(shell command -v python3 2> /dev/null)
BUILDAH_CMD := $(shell command -v buildah 2> /dev/null)
DOCKER_CMD := $(shell command -v docker 2> /dev/null)
POETRY_CMD := $(shell command -v poetry 2> /dev/null)
ELIXIR_CLOUD_REGISTRY := docker.io/elixircloud
DOCKER_FILE_PATH := deployment/containers

Expand All @@ -25,6 +26,8 @@ help:
@echo " \033[36mRemove virtual environment\033[0m"
@echo " \033[1minstall \033[37m(i\033[0m)"
@echo " \033[36mInstall dependencies\033[0m"
@echo " \033[1mformat-lint \033[37m(fl\033[0m)"
@echo " \033[36mFormats and lints python files\033[0m"
@echo " \033[1mbuild-service-image \033[37m(bsi\033[0m)"
@echo " \033[36mBuild image for service (tesk_core)\033[0m"
@echo " \033[36mEg: make bsi IMAGE=filer TAG=1.1.0\033[0m"
Expand Down Expand Up @@ -65,15 +68,27 @@ cv: clean-venv

.PHONY: install
install:
@if [ -f .venv/bin/activate ]; then \
pip install .; \
@if [ -x "$(POETRY_CMD)" ]; then \
poetry install; \
else \
echo "🐍 Virtual environment not found. Please create it first using 'make venv'."; \
echo "🔏 Install poetry."; \
fi

.PHONY: i
i: install

.PHONY: format-lint
format-lint:
@if [ -f .venv/bin/ruff ]; then \
ruff format; \
ruff check; \
else \
echo "⬇️ Install deps, create venv using 'make v' and install using `make i`."; \
fi

.PHONY: fl
fl: format-lint

.PHONY: build-service-image
build-service-image:
@if [ -x "$(BUILDAH_CMD)" ]; then \
Expand Down
28 changes: 27 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ kubernetes = "9.0.0"
requests = ">=2.20.0"
urllib3 = "1.26.18"
boto3 = "1.16.18"
ruff = "^0.4.4"

[tool.poetry.dev-dependencies]
pytest = "*"
Expand All @@ -39,6 +40,29 @@ fs = "*"
moto = "*"
pytest-localftpserver = "*"

[tool.ruff.lint]
select = [
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
# pylint
"PL"
]

[tool.ruff.format]
quote-style = "single"
indent-style = "tab"
docstring-code-format = true

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 1 addition & 3 deletions tesk/service/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@


def pprint(data):

return json.dumps(data, indent=4)

return json.dumps(data, indent=4)
24 changes: 21 additions & 3 deletions tesk/service/exception.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
class ServiceStatusCodes:
OK = 200
CREATED = 201
CONFLICT = 409
NOT_FOUND = 404
BAD_REQUEST = 400
UNAUTHORIZED = 401
FORBIDDEN = 403
INTERNAL_SERVER_ERROR = 500
NOT_IMPLEMENTED = 501
SERVICE_UNAVAILABLE = 503
GATEWAY_TIMEOUT = 504

@classmethod
def get(cls, status_name):
return getattr(cls, status_name.upper(), None)


class UnknownProtocol(Exception):
pass
pass


class FileProtocolDisabled(Exception):
pass
pass


class InvalidHostPath(Exception):
pass
pass
Loading

0 comments on commit 5c301d9

Please sign in to comment.