From 1ed875e24ac7a81ba516491f8304d556d105417e Mon Sep 17 00:00:00 2001 From: EspenAlbert Date: Sun, 20 Aug 2023 09:24:45 +0100 Subject: [PATCH 1/4] ci: add pre-commit ruff and check build files --- .pre-commit-config.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c1086f..09c55f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,8 +4,21 @@ repos: hooks: - id: no-commit-to-branch +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.0.285 + hooks: + - id: ruff + - repo: local hooks: + - id: build_files_check + name: build_files_check + entry: "pants tailor --check update-build-files --check ::" + language: system + files: BUILD$ + types: [file] + pass_filenames: false - id: lint name: Lint entry: pants --changed-since=HEAD --changed-dependents=transitive lint From 139d790a855b1c21f2cca9dae1c41fdde1cd6f43 Mon Sep 17 00:00:00 2001 From: EspenAlbert Date: Sun, 20 Aug 2023 09:29:53 +0100 Subject: [PATCH 2/4] feat: support testing with python 3.11 --- _pants/py_package.py | 1 + _pants/py_test_versions.py | 1 + compose_chart_export/tests/test_chart_export/BUILD | 2 +- model_lib/test/test_model_lib/BUILD | 2 +- pants.toml | 2 +- zero_3rdparty/tests/test_zero_3rdparty/BUILD | 2 +- 6 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 _pants/py_test_versions.py diff --git a/_pants/py_package.py b/_pants/py_package.py index cafb67e..9320d92 100644 --- a/_pants/py_package.py +++ b/_pants/py_package.py @@ -38,6 +38,7 @@ def py_package( classifiers=[ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], extras_require=extras_require or {}, long_description_content_type="text/markdown", diff --git a/_pants/py_test_versions.py b/_pants/py_test_versions.py new file mode 100644 index 0000000..d99a910 --- /dev/null +++ b/_pants/py_test_versions.py @@ -0,0 +1 @@ +test_versions = parametrize(py39=["==3.9.*"], py310=["==3.10.*"], py311=["==3.11.*"]) diff --git a/compose_chart_export/tests/test_chart_export/BUILD b/compose_chart_export/tests/test_chart_export/BUILD index f5c13b4..9a2b33b 100644 --- a/compose_chart_export/tests/test_chart_export/BUILD +++ b/compose_chart_export/tests/test_chart_export/BUILD @@ -1,5 +1,5 @@ resources(name="reg", sources=["charts/*", "compose_files/*"]) python_tests( dependencies=[":reg"], - interpreter_constraints=parametrize(py39=["==3.9.*"], py310=["==3.10.*"]), + interpreter_constraints=test_versions, ) diff --git a/model_lib/test/test_model_lib/BUILD b/model_lib/test/test_model_lib/BUILD index 1a7aa5b..162605c 100644 --- a/model_lib/test/test_model_lib/BUILD +++ b/model_lib/test/test_model_lib/BUILD @@ -2,6 +2,6 @@ resources(name="json", sources=["test_dump_functions/*.json"]) python_test_utils(name="conftest", resolve=parametrize("python-default", "pydantic-v1")) python_tests( dependencies=[":json"], - interpreter_constraints=parametrize(py39=["==3.9.*"], py310=["==3.10.*"]), + interpreter_constraints=test_versions, # resolve=parametrize("python-default", "pydantic-v1") ) diff --git a/pants.toml b/pants.toml index 04e8ec8..ace8d38 100644 --- a/pants.toml +++ b/pants.toml @@ -2,7 +2,7 @@ pants_version = "2.17.0rc3" print_stacktrace = true level = "warn" -build_file_prelude_globs = ["_pants/py_deploy.py", "_pants/py_package.py"] +build_file_prelude_globs = ["_pants/*.py"] # for plugin development pythonpath = ["%(buildroot)s/_pants/pants_py_deploy/src", "%(buildroot)s/compose_chart_export/src", "%(buildroot)s/docker_compose_parser/src", "%(buildroot)s/model_lib/src", "%(buildroot)s/zero_3rdparty/src"] diff --git a/zero_3rdparty/tests/test_zero_3rdparty/BUILD b/zero_3rdparty/tests/test_zero_3rdparty/BUILD index cc0d645..c849ac0 100644 --- a/zero_3rdparty/tests/test_zero_3rdparty/BUILD +++ b/zero_3rdparty/tests/test_zero_3rdparty/BUILD @@ -1 +1 @@ -python_tests(interpreter_constraints=parametrize(py39=["==3.9.*"], py310=["==3.10.*"])) +python_tests(interpreter_constraints=test_versions) From 57d743649247ec5c0f005e0160c967f15fc9d106 Mon Sep 17 00:00:00 2001 From: EspenAlbert Date: Sun, 20 Aug 2023 09:36:51 +0100 Subject: [PATCH 3/4] ci: add python 3.11 to ci job --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3d603b1..c7a1a14 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,6 +9,9 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.9' + - uses: actions/setup-python@v4 + with: + python-version: '3.11' - name: Initialize Pants uses: pantsbuild/actions/init-pants@main with: From 64db9dde238a9cfffdc1a1b1cb935d3e17df0cfb Mon Sep 17 00:00:00 2001 From: EspenAlbert Date: Sun, 20 Aug 2023 09:40:55 +0100 Subject: [PATCH 4/4] ci: use only 3.11 for mypy checks and avoid pants warning --- pants.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pants.toml b/pants.toml index ace8d38..c6e02b2 100644 --- a/pants.toml +++ b/pants.toml @@ -39,6 +39,9 @@ root_patterns = ["/*/src", "/*/", "/*/tests", "/*/test", "/_pants/*/src", "/_pan interpreter_constraints=[">=3.9"] enable_resolves = true +[python-infer] +use_rust_parser = true + [python.resolves] pants-plugins = "_pants/3rdparty/lock.txt" pydantic-v1 = "3rdparty/python/pydantic-v1.lock" @@ -55,7 +58,7 @@ config = "pyproject.toml" [mypy] config = "pyproject.toml" install_from_resolve="python-default" -interpreter_constraints=[">=3.10"] +interpreter_constraints=[">=3.11"] [ruff] config ="pyproject.toml"