From 5e381da26e6c1a45be48ad5abd4872b4ed51e8ef Mon Sep 17 00:00:00 2001 From: a5chin Date: Fri, 24 Jan 2025 12:40:13 +0000 Subject: [PATCH 1/6] fix: devcontainer extentions --- .devcontainer/devcontainer.json | 1 + .vscode/extensions.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index df62af4..f6aa589 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,6 +20,7 @@ "mosapride.zenkaku", "ms-azuretools.vscode-docker", "ms-python.python", + "ms-python.vscode-pylance", "njpwerner.autodocstring", "redhat.vscode-yaml", "shardulm94.trailing-spaces", diff --git a/.vscode/extensions.json b/.vscode/extensions.json index a4ca668..e45d391 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -8,6 +8,7 @@ "mosapride.zenkaku", "ms-azuretools.vscode-docker", "ms-python.python", + "ms-python.vscode-pylance", "ms-vscode-remote.remote-containers", "njpwerner.autodocstring", "oderwat.indent-rainbow", From 3d8d316f2b031c578a62e7c348ac57912f4eba3b Mon Sep 17 00:00:00 2001 From: a5chin Date: Fri, 24 Jan 2025 12:40:46 +0000 Subject: [PATCH 2/6] fix: tools import --- tools/__init__.py | 6 ++++++ tools/config/settings.py | 2 +- tools/trace/timer.py | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/__init__.py b/tools/__init__.py index 688ed87..2dbd3da 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -1 +1,7 @@ """Tools.""" + +from tools.logger import Logger + +__all__ = [ + "Logger", +] diff --git a/tools/config/settings.py b/tools/config/settings.py index 4848087..62617d1 100644 --- a/tools/config/settings.py +++ b/tools/config/settings.py @@ -10,7 +10,7 @@ class Settings(BaseSettings): Examples: >>> from tools.config import Settings - >>> from tools.logger import Logger, LogType + >>> from tools import Logger, LogType >>> >>> settings = Settings() >>> logger = Logger( diff --git a/tools/trace/timer.py b/tools/trace/timer.py index 2ab220c..a4953dc 100644 --- a/tools/trace/timer.py +++ b/tools/trace/timer.py @@ -43,9 +43,9 @@ def __enter__(self) -> None: def __exit__(self, *exc: object) -> None: """Run when exit ContextManager or Decoraotr.""" - self.end = time.time() + from tools import Logger - from tools.logger import Logger + self.end = time.time() logger = Logger(self.name) logger.debug("executed in %f ms", self._duration * 1_000) From f088bda18d8aaa8c446b5e5d7768203b1255535d Mon Sep 17 00:00:00 2001 From: a5chin Date: Fri, 24 Jan 2025 12:41:16 +0000 Subject: [PATCH 3/6] fix: docs --- README.md | 2 +- docs/guides/tools/config.md | 2 +- docs/guides/tools/logger.md | 2 +- docs/index.md | 5 +++-- pyproject.toml | 7 +++++++ uv.lock | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8355bfc..59d1bdf 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ uv add {libraries} │ │ └── type.py │ ├── trace/ │ │ ├── __init__.py -│ │ └── time.py +│ │ └── timer.py │ └── __init__.py ├── .dockerignore ├── .env.local diff --git a/docs/guides/tools/config.md b/docs/guides/tools/config.md index c947bd8..f2b3dde 100644 --- a/docs/guides/tools/config.md +++ b/docs/guides/tools/config.md @@ -11,7 +11,7 @@ class Settings(BaseSettings): Examples: >>> from tools.config import Settings - >>> from tools.logger import Logger, LogType + >>> from tools import Logger, LogType >>> >>> settings = Settings() >>> logger = Logger( diff --git a/docs/guides/tools/logger.md b/docs/guides/tools/logger.md index 081e83f..9ba5f56 100644 --- a/docs/guides/tools/logger.md +++ b/docs/guides/tools/logger.md @@ -1,5 +1,5 @@ ```python -from tools.logger import Logger +from tools import Logger def main() -> None: diff --git a/docs/index.md b/docs/index.md index 76d0367..2597768 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,8 @@ # Welcome to python-uv ## What is python-uv? -This repository contains configurations to set up a Python development environment using VSCode's Dev Container feature. The environment includes uv and Ruff. +This repository contains configurations to set up a Python development environment using VSCode's Dev Container feature. +The environment includes uv and Ruff. @@ -45,7 +46,7 @@ This repository contains configurations to set up a Python development environme │ │ └── type.py │ ├── trace/ │ │ ├── __init__.py - │ │ └── time.py + │ │ └── timer.py │ └── __init__.py ├── .dockerignore ├── .env.local diff --git a/pyproject.toml b/pyproject.toml index 6f7b192..1c6edf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,3 +25,10 @@ dev-dependencies = [ "pytest-cov>=6.0.0", "ruff>=0.9.2", ] + +[tool.hatch.build.targets.wheel] +packages = ["tools"] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" diff --git a/uv.lock b/uv.lock index 52359da..882bd84 100644 --- a/uv.lock +++ b/uv.lock @@ -245,7 +245,7 @@ toml = [ [[package]] name = "default" version = "0.1.0" -source = { virtual = "." } +source = { editable = "." } dependencies = [ { name = "google-cloud-logging" }, { name = "pydantic" }, From bc6bc9b64fd5c029b6413425f0df798f2055edc9 Mon Sep 17 00:00:00 2001 From: a5chin Date: Fri, 24 Jan 2025 14:10:29 +0000 Subject: [PATCH 4/6] fix: update import path for Logger and LogType in settings.py --- tools/config/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config/settings.py b/tools/config/settings.py index 62617d1..4848087 100644 --- a/tools/config/settings.py +++ b/tools/config/settings.py @@ -10,7 +10,7 @@ class Settings(BaseSettings): Examples: >>> from tools.config import Settings - >>> from tools import Logger, LogType + >>> from tools.logger import Logger, LogType >>> >>> settings = Settings() >>> logger = Logger( From 9c572bbe130cd75830c158332c6600248027dbfa Mon Sep 17 00:00:00 2001 From: a5chin Date: Fri, 24 Jan 2025 14:15:14 +0000 Subject: [PATCH 5/6] fix: update import path for Logger and LogType in config.md --- docs/guides/tools/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/tools/config.md b/docs/guides/tools/config.md index f2b3dde..c947bd8 100644 --- a/docs/guides/tools/config.md +++ b/docs/guides/tools/config.md @@ -11,7 +11,7 @@ class Settings(BaseSettings): Examples: >>> from tools.config import Settings - >>> from tools import Logger, LogType + >>> from tools.logger import Logger, LogType >>> >>> settings = Settings() >>> logger = Logger( From d3630cde600834e2664c4c828c3f7a5f6aaa29db Mon Sep 17 00:00:00 2001 From: a5chin Date: Fri, 24 Jan 2025 14:23:18 +0000 Subject: [PATCH 6/6] fix: reorder import statement for Logger in timer.py --- tools/trace/timer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/trace/timer.py b/tools/trace/timer.py index a4953dc..50ad710 100644 --- a/tools/trace/timer.py +++ b/tools/trace/timer.py @@ -43,10 +43,10 @@ def __enter__(self) -> None: def __exit__(self, *exc: object) -> None: """Run when exit ContextManager or Decoraotr.""" - from tools import Logger - self.end = time.time() + from tools import Logger + logger = Logger(self.name) logger.debug("executed in %f ms", self._duration * 1_000)