From a8744d339ed5075d7ce8fe0854870427716b324e Mon Sep 17 00:00:00 2001 From: Neriya Cohen Date: Thu, 27 Mar 2025 23:07:57 +0200 Subject: [PATCH 1/4] Refactor injector initialization to use type(self) instead of Context --- src/pydom/context/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydom/context/context.py b/src/pydom/context/context.py index 031ad95..627deb0 100644 --- a/src/pydom/context/context.py +++ b/src/pydom/context/context.py @@ -30,7 +30,7 @@ def __init__(self) -> None: self.injector: Injector = Injector( { - Context: self, + type(self): self, RenderState: future_dependency("RenderState is only available during rendering"), } ) From 3761ab0190cd06d5ea4a4a05b7ebdfda48b263a5 Mon Sep 17 00:00:00 2001 From: Neriya Cohen Date: Thu, 27 Mar 2025 23:08:13 +0200 Subject: [PATCH 2/4] Enhance _full_path method to support relative CSS paths starting with "../" --- src/pydom/styling/css_modules.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pydom/styling/css_modules.py b/src/pydom/styling/css_modules.py index 77ace1c..2a5c42e 100644 --- a/src/pydom/styling/css_modules.py +++ b/src/pydom/styling/css_modules.py @@ -136,11 +136,10 @@ def set_root_folder(cls, folder: Union[PathLike, str]): def _full_path(cls, css_path: Union[PathLike, str]) -> Path: if isinstance(css_path, str): - if css_path.startswith("./"): + if css_path.startswith("./") or css_path.startswith("../"): frame = get_frame(2) - module = frame.f_globals["__name__"] - module_path = Path(module.replace(".", "/")) - css_path = module_path.parent / css_path[2:] + module = frame.f_globals["__file__"] + css_path = Path(module).parent / css_path css_path = Path(css_path) From aa404a66ca90bbf96b3b37be518ac9fe37d28fa5 Mon Sep 17 00:00:00 2001 From: Neriya Cohen Date: Thu, 27 Mar 2025 23:08:23 +0200 Subject: [PATCH 3/4] Rename CSS class from cardHeader to card_header for consistency --- tests/css/styles.css | 2 +- tests/test_css_modules.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/css/styles.css b/tests/css/styles.css index a8082fe..452f1f0 100644 --- a/tests/css/styles.css +++ b/tests/css/styles.css @@ -6,7 +6,7 @@ padding: 20px; } -.cardHeader { +.card_header { font-size: 1.5em; font-weight: bold; margin-bottom: 10px; diff --git a/tests/test_css_modules.py b/tests/test_css_modules.py index 30c8d8f..11b7e60 100644 --- a/tests/test_css_modules.py +++ b/tests/test_css_modules.py @@ -8,14 +8,14 @@ class CSSModulesTest(TestCase): def setUpClass(cls) -> None: styles = CSS.module("tests/css/styles.css") cls.card_class = styles.card - cls.card_header_class = styles.cardHeader + cls.card_header_class = styles.card_header def test_class_name(self): styles = CSS.module("tests/css/styles.css") self.assertEqual(self.card_class, styles.card) - self.assertEqual(self.card_header_class, styles.cardHeader) + self.assertEqual(self.card_header_class, styles.card_header) def test_relative_css(self): styles = CSS.module("./css/styles.css") self.assertEqual(styles.card, self.card_class) - self.assertEqual(styles.cardHeader, self.card_header_class) + self.assertEqual(styles.card_header, self.card_header_class) From 1ce49dc7c0bcfaf6cd353bb6e469a21ad0ef0528 Mon Sep 17 00:00:00 2001 From: Neriya Cohen Date: Sun, 30 Mar 2025 01:04:50 +0300 Subject: [PATCH 4/4] Add version bumping step in GitHub Actions workflow --- .github/workflows/python-publish.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 7752965..d49c240 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -5,7 +5,7 @@ on: types: [published] permissions: - contents: read + contents: write jobs: deploy: @@ -23,6 +23,20 @@ jobs: python -m pip install --upgrade pip pip install build + - name: Bump version + run: | + echo "Bumping version..." + echo "version = \"${{ github.event.release.tag_name }}\"\n" > src/pydom/version.py + echo "Version bumped to ${{ github.event.release.tag_name }}" + + - name: Commit version bump + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add src/pydom/version.py + git commit -m "Bump version to ${{ github.event.release.tag_name }}" + git push + - name: Build package run: python -m build