Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install black isort

- name: Check formatting with black
run: black --check configurize/

- name: Check imports with isort
run: isort --check-only --profile black configurize/

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install package
run: pip install .

- name: Test import
run: python -c "from configurize import Config, DataClass, Ref; print('Import successful')"
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish to PyPI

on:
push:
tags:
- 'v*' # Triggers on tags like v0.1.0, v1.0.0, etc.

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install build dependencies
run: pip install build

- name: Build package
run: python -m build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 2 additions & 3 deletions configurize/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from configurize.utils import compare_in_vscode, get_object_from_file, show_or_compare


def cfshow(
ref: str | Config, exp: str | Config = None, key=None, query=None
):
def cfshow(ref: str | Config, exp: str | Config = None, key=None, query=None):
"""Show an Exp or compare two Exps

Usage:
Expand Down Expand Up @@ -86,6 +84,7 @@ def has_repetition(sequence):

def main():
import fire

fire.Fire(cfshow)


Expand Down
4 changes: 3 additions & 1 deletion configurize/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import ast
import inspect
import weakref
Expand Down Expand Up @@ -43,7 +45,7 @@ class Config(DataClass):
_modify_stack = []
"""store modification in stack, enable push & pop"""

_allow_set_new_attr = None
_allow_set_new_attr = False
"""if set True, `cfg.aaa = 1` is allowed even if 'aaa' does not exists. None for allowed now."""

_buildin_functions = [
Expand Down
2 changes: 2 additions & 0 deletions configurize/data_class.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from functools import cached_property


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "configurize"
version = "0.1.0"
description = "Hierarchical configuration management with inheritance, cross-references, and diffing"
readme = "README.md"
license = "MIT"
license = {text = "MIT"}
authors = [
{name = "Zhou Hongyu", email = "rndj@outlook.com"}
]
Expand Down