diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ea5d9d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,20 @@ +# Copyright 2024 yu-iskw +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/contributors-list.yml b/.github/workflows/contributors-list.yml index 932e5eb..8efbaa0 100644 --- a/.github/workflows/contributors-list.yml +++ b/.github/workflows/contributors-list.yml @@ -12,6 +12,6 @@ jobs: name: A job to automate contrib in readme steps: - name: Contribute List - uses: akhilmhdh/contributors-readme-action@v2.3.6 + uses: akhilmhdh/contributors-readme-action@v2.3.10 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad5be36..10704c7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,12 +27,17 @@ repos: rev: v1.7.1 hooks: - id: actionlint-docker - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) - repo: https://github.com/shellcheck-py/shellcheck-py rev: v0.10.0.1 hooks: - id: shellcheck + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.2 + hooks: + - id: ruff + always_run: true + # SEE https://docs.astral.sh/ruff/formatter/#sorting-imports + args: [--select, I, --fix, --config=ruff.toml] + - id: ruff-format + always_run: true + args: [--config=ruff.toml] diff --git a/Makefile b/Makefile index a7a7653..5ba4d20 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ setup: setup-python setup-pre-commit .PHONE: setup-python setup-python: - pip install -U pip==23.1.0 + pip install -U pip==24.3.1 bash ./dev/setup.sh .PHONE: setup-pre-commit diff --git a/dev/generate_clients.sh b/dev/generate_clients.sh index f17c745..e4fecee 100644 --- a/dev/generate_clients.sh +++ b/dev/generate_clients.sh @@ -19,7 +19,7 @@ # Constants SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" -PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +PROJECT_DIR="$(dirname "${SCRIPT_DIR}")" # Arguments schema_json="${PROJECT_DIR}/dev/schemas/rebuilt-swagger.json" @@ -46,9 +46,6 @@ while (($# > 0)); do done options=() -if [[ "${skip_validate_spec:?}" == "1" ]]; then - options+=("--skip-validate-spec") -fi # Generate the client in the temporary directory. temp_dir="$(mktemp -d -t openapi-python-client-XXXXXXXXXX)" @@ -56,12 +53,20 @@ cd "${temp_dir:?}" || exit 1 openapi-python-client generate \ --path "${schema_json:?}" \ --config "${config_yaml:?}" \ - --meta "${meta:?}" + --meta "${meta:?}" \ + "${options[@]}" -ls -la "${temp_dir:?}/lightdash-client-python" +# Check the generated project +generated_project_dir="${temp_dir:?}/lightdash-client-python" +ls -la "${generated_project_dir:?}" + +# Replace the default auth method from Bearer to ApiKey +sed -i -e "s/Bearer/ApiKey/" "${generated_project_dir:?}/lightdash_client/client.py" # Copy the files -cp -apR "${temp_dir:?}/lightdash-client-python/"* "${output_dir:?}" +rsync -a -r --delete-after "${generated_project_dir:?}/lightdash_client/models/" "${output_dir:?}/lightdash_client/models/" +rsync -a -r --delete-after "${generated_project_dir:?}/lightdash_client/api/" "${output_dir:?}/lightdash_client/api/" +rsync -a -r --delete-after "${generated_project_dir:?}/lightdash_client/client.py" "${output_dir:?}/lightdash_client/client.py" # Remove the temporary directory rm -fr "${temp_dir:?}" diff --git a/dev/generate_openapi_schema.py b/dev/generate_openapi_schema.py index 6813ed3..61420c6 100644 --- a/dev/generate_openapi_schema.py +++ b/dev/generate_openapi_schema.py @@ -21,7 +21,11 @@ @click.command() -@click.option("--reference", type=str, default="https://raw.githubusercontent.com/lightdash/lightdash/main/packages/backend/src/generated/swagger.json") +@click.option( + "--reference", + type=str, + default="https://raw.githubusercontent.com/lightdash/lightdash/main/packages/backend/src/generated/swagger.json", +) # @click.option("--output", type=str, required=True) def main(reference: str): print(f"Reference URL: {reference}") diff --git a/dev/openapi-python-client.yml b/dev/openapi-python-client.yml index 53fc838..22ded12 100644 --- a/dev/openapi-python-client.yml +++ b/dev/openapi-python-client.yml @@ -3,6 +3,10 @@ project_name_override: lightdash-client-python package_name_override: lightdash_client -package_version_override: "0.2.0" +package_version_override: 0.2.0 http_timeout: 30 + +# Format code using the pre-commit hooks of ruff +# SEE https://github.com/openapi-generators/openapi-python-client +post_hooks: [] diff --git a/pyproject.toml b/pyproject.toml index a307416..f9eabbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ exclude = [ ".github/", ".gitignore", ".pre-commit-config.yaml", - ".style.yapf", + "ruff.toml", ".pylintrc", ".pypirc", "Makefile", @@ -24,7 +24,7 @@ name = "lightdash-client-python" authors = [{name = "yu-iskw"}] readme = "README.md" license = {file = "LICENSE"} -requires-python = ">=3.8.0,<4" +requires-python = ">=3.9,<3.13" classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Information Technology", @@ -36,10 +36,10 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Typing :: Typed", ] dynamic = ["version", "description"] @@ -54,18 +54,17 @@ Home = "https://github.com/yu-iskw/lightdash-client-python" [project.optional-dependencies] test = [ - "pytest >=6.2.4,<7.0.0", + "pytest >=8.0,<9.0", +] +dev = [ "pylint >=2.12.0", - "mypy >=0.910,<1.0", "flake8 >=3.8.3,<4.0.0", + "mypy >=0.910,<1.0", "black >=20.0", "isort >=5.0.6,<6.0.0", - "yapf >=0.29.0", -] -dev = [ - "flit ==3.7.1", + "flit ==3.10.1", "build ==0.7.0", - "yapf >=0.29.0", + "ruff >=0.8,<1.0", "pyyaml >=5.3", "pdoc3 >=0.9.2", "pre-commit >=2.15.0", diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..e642384 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,6 @@ +# Start of Selection +line-length = 120 +indent-width = 4 + +[format] +quote-style = "double"