Skip to content

Commit

Permalink
Prepare project for further development (#396)
Browse files Browse the repository at this point in the history
* Fix linting and auto formatting
* Refactor settings to use with subobjects
* Fix isort for subfolders
* Refactor logger module
* Bump python requirements to actual versions
* Bump versions angular dependencies
---------

Signed-off-by: Johannes Ott <[email protected]>
  • Loading branch information
DerOetzi authored Aug 7, 2024
1 parent 0942dec commit e9821ca
Show file tree
Hide file tree
Showing 19 changed files with 293 additions and 234 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"ms-python.pylint",
"ms-python.python",
"donjayamanne.python-environment-manager",
"github.vscode-github-actions"
"github.vscode-github-actions",
"ms-python.black-formatter",
"ms-azuretools.vscode-docker"
]
}
}
Expand Down
43 changes: 16 additions & 27 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"search.exclude": {
"**/versioneer.py": true,
"versioneer.py": true,
"**/_version.py": true,
"**/*.po": true
},
Expand All @@ -12,35 +12,24 @@
"**/.DS_Store": true,
"**/__pycache__": true
},
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--enable=W0611",
"--disable=C0111",
"pylint.args": [
"--rcfile=${workspaceFolder}/core/.pylintrc"
],
"python.linting.enabled": true,
"python.pythonPath": "${workspaceFolder}/.venv/bin/python",
"python.linting.pylintPath": "${workspaceFolder}/.venv/bin/pylint",
"pylint.cwd": "${workspaceFolder}/core",
"git.alwaysSignOff": true,
"python.analysis.typeCheckingMode": "off",
"python.analysis.autoImportCompletions": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
},
"isort.args": [
"--src",
"${workspaceFolder}/core",
"--multi-line",
"3",
"--trailing-comma"
"--profile",
"black",
"--settings-file",
"${workspaceFolder}/core/.isort.cfg"
],
"python.envFile": "${workspaceFolder}/core/.env",
"python.formatting.provider": "none",
"colorTabs.config": [
{
"regex": ".*/core/.*",
"color": "#FF0000",
"label": "CORE"
},
{
"regex": ".*/ui/.*",
"color": "#00FF00",
"label": "UI"
}
]
}
2 changes: 2 additions & 0 deletions core/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
known_first_party = learninghouse
2 changes: 1 addition & 1 deletion core/learninghouse/api/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse

from learninghouse.core.logging import logger
from learninghouse.core.logger import logger
from learninghouse.models import (
LearningHouseErrorMessage,
LearningHouseValidationErrorMessage,
Expand Down
2 changes: 1 addition & 1 deletion core/learninghouse/api/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
LearningHouseException,
LearningHouseUnauthorizedException,
)
from learninghouse.core.logging import logger
from learninghouse.core.logger import logger
from learninghouse.core.settings import service_settings
from learninghouse.services.auth import INITIAL_PASSWORD_WARNING, authservice

Expand Down
2 changes: 1 addition & 1 deletion core/learninghouse/api/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from learninghouse.api.errors import LearningHouseSecurityException
from learninghouse.core.settings import service_settings
from learninghouse.core.logging import logger
from learninghouse.core.logger import logger

settings = service_settings()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,7 @@
from loguru import logger
from loguru._defaults import LOGURU_FORMAT

from learninghouse.models.base import EnumModel


class LoggingLevelEnum(EnumModel):
DEBUG = "DEBUG", logging.DEBUG
INFO = "INFO", logging.INFO
WARNING = "WARNING", logging.WARNING
ERROR = "ERROR", logging.ERROR
CRITICAL = "CRITICAL", logging.CRITICAL

def __init__(self, description: str, level: int):
# pylint: disable=super-init-not-called
self._description: str = description
self._level: int = level

@property
def description(self) -> str:
return self._description

@property
def level(self) -> int:
return self._level
from learninghouse.core.logger.models import LoggingLevelEnum


class LoggingHandler(logging.Handler):
Expand Down
24 changes: 24 additions & 0 deletions core/learninghouse/core/logger/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import logging

from learninghouse.models.base import EnumModel


class LoggingLevelEnum(EnumModel):
DEBUG = "DEBUG", logging.DEBUG
INFO = "INFO", logging.INFO
WARNING = "WARNING", logging.WARNING
ERROR = "ERROR", logging.ERROR
CRITICAL = "CRITICAL", logging.CRITICAL

def __init__(self, description: str, level: int):
# pylint: disable=super-init-not-called
self._description: str = description
self._level: int = level

@property
def description(self) -> str:
return self._description

@property
def level(self) -> int:
return self._level
150 changes: 0 additions & 150 deletions core/learninghouse/core/settings.py

This file was deleted.

7 changes: 7 additions & 0 deletions core/learninghouse/core/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from functools import lru_cache

from learninghouse.core.settings.models import ServiceSettings

@lru_cache()
def service_settings() -> ServiceSettings:
return ServiceSettings()
Loading

0 comments on commit e9821ca

Please sign in to comment.