diff --git a/.vscode/settings.json b/.vscode/settings.json index ea667b8..dacc4d1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,23 +1,23 @@ { "[python]": { - "editor.defaultFormatter": "ms-python.autopep8", "editor.formatOnSave": true, + "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { - "source.organizeImports": true + "source.organizeImports": true, + "source.fixAll": true }, }, - "autopep8.args": [ - "--max-line-length", - "127" + "ruff.lint.args": [ + "--config=./pyproject.toml" ], + "ruff.enable": true, + // "autopep8.args": [ + // "--max-line-length", + // "127" + // ], "flake8.args": [ "--config=setup.cfg" ], - "isort.check": true, - "isort.args": [ - "--line_length", - "127" - ], "mypy-type-checker.args": [ "--config-file=pyproject.toml" ], @@ -26,6 +26,11 @@ "note": "Information" }, "mypy-type-checker.ignorePatterns": [], + "[markdown]": { + "editor.codeActionsOnSave": { + "source.fixAll": true + }, + }, "[toml]": { "editor.formatOnSave": false, "editor.defaultFormatter": "be5invis.toml" @@ -34,5 +39,8 @@ "[properties]": { "editor.formatOnSave": false, }, - "python.analysis.typeCheckingMode": "basic" + "python.analysis.typeCheckingMode": "basic", + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.fontFamily": "\"Geist Mono Medium\", \"LigaSFMonoNerdFont\",\"Hack Nerd Font\", \"Noto Mono\", \"Jetbrains Mono Regular\", Menlo, Monaco, 'Courier New', monospace", + "editor.cursorStyle": "block" } diff --git a/Makefile.venv b/Makefile.venv index 53fbf3f..c3c2014 100644 --- a/Makefile.venv +++ b/Makefile.venv @@ -225,8 +225,8 @@ endif $(VENV): $(PY) -m venv $(VENVDIR) $(VENV)/python -m pip install --upgrade pip setuptools wheel pdm - $(VENV)/pdm config python.use_venv false - $(VENV)/pdm use --venv in-project + $(VENV)/pdm config python.use_venv true + # $(VENV)/pdm use --venv in-project $(VENV)/$(MARKER): $(VENVDEPENDS) | $(VENV) # ifneq ($(strip $(REQUIREMENTS_TXT)),) diff --git a/pyproject.toml b/pyproject.toml index c3f380f..d1d6f6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ use_parentheses = false # plugins = ["pydantic.mypy"] # python_version = "3.11" ignore_missing_imports = true -disallow_any_unimported = true +disallow_any_unimported = false pretty = true [tool.coverage.run] @@ -108,7 +108,6 @@ exclude = [ "dist", ] -# Same as Black. line-length = 127 indent-width = 4 diff --git a/src/app/__main__.py b/src/app/__main__.py index 5a1f7a8..c9469e0 100644 --- a/src/app/__main__.py +++ b/src/app/__main__.py @@ -1,4 +1,3 @@ - import sys import app diff --git a/src/utils/logging.py b/src/utils/logging.py index 7040b46..c99de20 100644 --- a/src/utils/logging.py +++ b/src/utils/logging.py @@ -7,11 +7,10 @@ from typing import cast import structlog +from structlog.stdlib import BoundLogger, LoggerFactory, add_log_level, filter_by_level -def setup_logger( - *, logger_name: str, log_level: int = logging.INFO -) -> structlog.stdlib.BoundLogger: # pragma: no cover +def setup_logger(*, logger_name: str, log_level: int = logging.INFO) -> BoundLogger: """ Set up the logger object to use in your code. @@ -30,17 +29,14 @@ def setup_logger( """ # pylint: disable=protected-access _setup_structlog() - logger = cast(structlog.stdlib.BoundLogger, - structlog.get_logger(logger_name)) + logger = cast(BoundLogger, structlog.get_logger(logger_name)) logger.setLevel(log_level) if not logger.new()._logger.handlers: logger.addHandler(_configure_logger_handlers()) return logger -def set_logger_level( - *, logger: structlog.stdlib.BoundLogger, level: str -) -> None: # pragma: no cover +def set_logger_level(*, logger: BoundLogger, level: str) -> None: """ Allow to set a new logging level by name for an existing logger. @@ -57,10 +53,7 @@ def set_logger_level( clean_level = level.upper() numeric_level = getattr(logging, clean_level) logger.setLevel(numeric_level) - logger.info( - "Log level changed", - new_level=clean_level, - new_level_numeric=numeric_level) + logger.info("Log level changed", new_level=clean_level, new_level_numeric=numeric_level) def _configure_logger_handlers() -> logging.StreamHandler: # pragma: no cover @@ -80,15 +73,15 @@ def _setup_structlog() -> None: structlog.configure( processors=[ - structlog.stdlib.filter_by_level, - structlog.stdlib.add_log_level, + filter_by_level, + add_log_level, structlog.processors.StackInfoRenderer(), structlog.processors.format_exc_info, structlog.processors.UnicodeDecoder(), structlog.processors.TimeStamper(fmt="iso"), structlog.processors.JSONRenderer(sort_keys=False), ], - logger_factory=structlog.stdlib.LoggerFactory(), - wrapper_class=structlog.stdlib.BoundLogger, + logger_factory=LoggerFactory(), + wrapper_class=BoundLogger, cache_logger_on_first_use=True, ) diff --git a/tests/conftest.py b/tests/conftest.py index af63303..4c96775 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,8 +17,7 @@ def __init__(self, *args: Any, **kwargs: Any): def entries(self) -> List[Dict]: # build _entries only once if not self._entries: - self._entries = [json.loads(line) - for line in self.getvalue().splitlines()] + self._entries = [json.loads(line) for line in self.getvalue().splitlines()] return self._entries diff --git a/tests/unit/app/test_some_module.py b/tests/unit/app/test_some_module.py index 2d4fc21..8b4d0af 100644 --- a/tests/unit/app/test_some_module.py +++ b/tests/unit/app/test_some_module.py @@ -15,5 +15,6 @@ # assert client.first_name == "Mark" # assert client.last_name == "New" + def test_app(): assert True