From cd548f595edbde19511789d7c486eb35dc36ec56 Mon Sep 17 00:00:00 2001 From: snowykami Date: Wed, 2 Oct 2024 12:47:32 +0800 Subject: [PATCH] :sparkles: first comm --- .github/workflows/pypi-publish.yml | 21 +++++++++++++++++++++ pyproject.toml | 9 +++++++-- server_status/api.py | 6 ++---- 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pypi-publish.yml diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 0000000..8e40ff9 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,21 @@ +name: Publish + +on: + push: + tags: + - '*' + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v3 + + - uses: pdm-project/setup-pdm@v3 + + - name: Publish package distributions to PyPI + run: pdm publish diff --git a/pyproject.toml b/pyproject.toml index e6df650..dcd8cf1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] -name = "server-status-cv-py" -version = "0.1.0" +name = "server-status" +dynamic = ["version"] description = "Server status client" authors = [ {name = "snowykami", email = "snowykami@outlook.com"}, @@ -21,3 +21,8 @@ build-backend = "pdm.backend" [tool.pdm] distribution = true + +[tool.pdm.version] +source = "scm" +tag_filter = "test/*" +tag_regex = '^test/(?:\D*)?(?P([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|c|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$)$' \ No newline at end of file diff --git a/server_status/api.py b/server_status/api.py index f664785..bc21e04 100644 --- a/server_status/api.py +++ b/server_status/api.py @@ -106,17 +106,15 @@ class Api: """ self.headers.update(self.format(headers)) - def format(self, obj: str | tuple[str, ...] | dict[str, Any]): + def format(self, obj: str | list[str] | dict[str, Any]) -> str | list[str] | dict[str, Any]: if isinstance(obj, str): obj = obj.format(**self.variables) elif isinstance(obj, dict): for key in obj: obj[key] = self.format(obj[key]) - elif isinstance(obj, (list, tuple)): + elif isinstance(obj, list): for i in range(len(obj)): obj[i] = self.format(obj[i]) - else: - pass return obj