From 2f50ddb0d90f7ec06a83729a5225f71892ad13e4 Mon Sep 17 00:00:00 2001 From: Jordi Soucheiron Date: Tue, 11 Jun 2024 12:08:50 +0200 Subject: [PATCH] Master fixes take 2 --- .github/workflows/lint-and-test.yml | 2 +- .github/workflows/pypi-release.yml | 2 +- .readthedocs.yaml | 2 +- pyproject.toml | 4 ++-- requirements-dev.txt | 22 +++++++++---------- requirements-docs.txt | 16 +++++++------- requirements.txt | 8 +++---- setup.py | 2 +- tests/resources/properties/test_principal.py | 2 +- .../properties/test_statement_condition.py | 8 +++---- tests/resources/test_generic_resoure.py | 8 +++---- tests/test_generic.py | 2 +- tests/test_types.py | 4 ++-- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index d059ebea..e1792758 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] name: Python ${{ matrix.python-version }} diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 45436b99..02c5a1e3 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -14,7 +14,7 @@ jobs: - name: Setup python uses: actions/setup-python@v4 with: - python-version: '3.7' + python-version: '3.8' - run: pip install setuptools wheel diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9499ff84..e34a9ff0 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,7 +8,7 @@ formats: all build: os: ubuntu-22.04 tools: - python: "3.7" + python: "3.8" python: install: diff --git a/pyproject.toml b/pyproject.toml index e0c5865e..283f2982 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,8 +44,8 @@ exclude = [ line-length = 120 indent-width = 4 -# Assume Python 3.7 -target-version = "py37" +# Assume Python 3.8 +target-version = "py38" [tool.ruff.lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. diff --git a/requirements-dev.txt b/requirements-dev.txt index 78e7773c..cd6333f6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,13 +4,13 @@ # # make freeze # -annotated-types==0.6.0 -anyio==4.3.0 +annotated-types==0.7.0 +anyio==4.4.0 black==24.4.2 build==1.2.1 -certifi==2024.2.2 +certifi==2024.6.2 click==8.1.7 -coverage[toml]==7.5.1 +coverage[toml]==7.5.3 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 @@ -18,20 +18,20 @@ idna==3.7 iniconfig==2.0.0 isort==5.13.2 mypy-extensions==1.0.0 -packaging==24.0 +packaging==24.1 pathspec==0.12.1 pip-tools==7.4.1 -platformdirs==4.2.1 +platformdirs==4.2.2 pluggy==1.5.0 -pydantic==2.7.1 -pydantic-core==2.18.2 +pydantic==2.7.3 +pydantic-core==2.18.4 pyproject-hooks==1.1.0 -pytest==8.2.0 +pytest==8.2.2 pytest-cov==5.0.0 pytest-repeat==0.9.3 -ruff==0.4.4 +ruff==0.4.8 sniffio==1.3.1 -typing-extensions==4.11.0 +typing-extensions==4.12.2 wheel==0.43.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements-docs.txt b/requirements-docs.txt index 334da457..6055e5a4 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -4,7 +4,7 @@ # # make freeze # -annotated-types==0.6.0 +annotated-types==0.7.0 automacdoc==0.3 beautifulsoup4==4.12.3 click==8.1.7 @@ -18,9 +18,9 @@ mergedeep==1.3.4 mkdocs==1.3.0 mkdocs-material==4.6.3 mkdocstrings==0.10.0 -packaging==24.0 -pydantic==2.7.1 -pydantic-core==2.18.2 +packaging==24.1 +pydantic==2.7.3 +pydantic-core==2.18.4 pygments==2.18.0 pymdown-extensions==10.8.1 python-dateutil==2.9.0.post0 @@ -29,7 +29,7 @@ pyyaml==6.0.1 pyyaml-env-tag==0.1 six==1.16.0 soupsieve==2.5 -tornado==6.4 -typing-extensions==4.11.0 -watchdog==4.0.0 -zipp==3.18.1 +tornado==6.4.1 +typing-extensions==4.12.2 +watchdog==4.0.1 +zipp==3.19.2 diff --git a/requirements.txt b/requirements.txt index ff137b9d..57011765 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ # # make freeze # -annotated-types==0.6.0 -pydantic==2.7.1 -pydantic-core==2.18.2 -typing-extensions==4.11.0 +annotated-types==0.7.0 +pydantic==2.7.3 +pydantic-core==2.18.4 +typing-extensions==4.12.2 diff --git a/setup.py b/setup.py index e0b4dc8c..0b503e62 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ long_description_content_type="text/markdown", url="https://github.com/Skyscanner/pycfmodel", packages=find_namespace_packages(exclude=("tests", "docs")), - python_requires=">=3.7", + python_requires=">=3.8", install_requires=install_requires, tests_require=dev_requires, extras_require={ diff --git a/tests/resources/properties/test_principal.py b/tests/resources/properties/test_principal.py index a53c4733..f88d9dcc 100644 --- a/tests/resources/properties/test_principal.py +++ b/tests/resources/properties/test_principal.py @@ -26,6 +26,6 @@ ) def test_principal(principal): try: - Principal.parse_obj(principal) + Principal.model_validate(principal) except ValidationError as exc: assert False, f"{principal} raised an exception {exc}" diff --git a/tests/resources/properties/test_statement_condition.py b/tests/resources/properties/test_statement_condition.py index 4bba5918..34e15864 100644 --- a/tests/resources/properties/test_statement_condition.py +++ b/tests/resources/properties/test_statement_condition.py @@ -68,12 +68,12 @@ def test_all_possible_conditions(): all_operators.add(f"ForAllValues{operator}") all_operators.add(f"ForAnyValue{operator}") - implemented_operators = sorted(StatementCondition.schema()["properties"].keys()) + implemented_operators = sorted(StatementCondition.model_json_schema()["properties"].keys()) assert implemented_operators == sorted(all_operators) def test_statement_condition_remove_colon(): - assert StatementCondition.parse_obj( + assert StatementCondition.model_validate( { "ForAllValues:ArnEqualsIfExists": {"patata_1": "test_1"}, "ForAnyValue:ArnEquals": {"patata_2": ["test_2", "test_3"]}, @@ -669,7 +669,7 @@ def test_statement_condition_eval_all_conditions_are_true( def test_statement_condition_without_resolving_raises_error(): statement_condition_raw = {"StringLike": {"patata": {"Fn::Sub": "${ClusterId}*"}}} - statement_condition = StatementCondition.parse_obj(statement_condition_raw) + statement_condition = StatementCondition.model_validate(statement_condition_raw) with pytest.raises(StatementConditionBuildEvaluatorError): statement_condition.eval({"patata": "test_cluster"}) @@ -677,5 +677,5 @@ def test_statement_condition_without_resolving_raises_error(): def test_statement_condition_with_resolver_works_fine(): statement_condition_raw = {"StringLike": {"patata": {"Fn::Sub": "${ClusterId}*"}}} resolved_statement_condition_raw = resolve(statement_condition_raw, {"ClusterId": "test_cluster"}, {}, {}) - resolved_statement_condition = StatementCondition.parse_obj(resolved_statement_condition_raw) + resolved_statement_condition = StatementCondition.model_validate(resolved_statement_condition_raw) assert resolved_statement_condition.eval({"patata": "test_cluster"}) is True diff --git a/tests/resources/test_generic_resoure.py b/tests/resources/test_generic_resoure.py index b8a3bd58..6662dec5 100644 --- a/tests/resources/test_generic_resoure.py +++ b/tests/resources/test_generic_resoure.py @@ -5,7 +5,7 @@ def test_generic_resource(): - resource = GenericResource.parse_obj( + resource = GenericResource.model_validate( { "Type": "AWS::ECR::RegistryPolicy", "Properties": { @@ -42,7 +42,7 @@ def test_generic_resource(): def test_generic_resource_with_policy_document_in_a_string_property(): - resource = GenericResource.parse_obj( + resource = GenericResource.model_validate( { "Type": "AWS::Logs::ResourcePolicy", "Properties": { @@ -67,7 +67,7 @@ def test_generic_resource_with_policy_document_in_a_string_property(): def test_generic_resource_with_bad_json_as_string_is_converted_to_a_string_property(): - resource = GenericResource.parse_obj( + resource = GenericResource.model_validate( { "Type": "AWS::Logs::ResourcePolicy", "Properties": { @@ -82,7 +82,7 @@ def test_generic_resource_with_bad_json_as_string_is_converted_to_a_string_prope def test_parse_generic_resource_without_properties(): - resource = GenericResource.parse_obj({"Type": "AWS::SNS::Topic"}) + resource = GenericResource.model_validate({"Type": "AWS::SNS::Topic"}) assert isinstance(resource, GenericResource) assert resource.Properties is None assert resource.Type == "AWS::SNS::Topic" diff --git a/tests/test_generic.py b/tests/test_generic.py index 9fff5359..8163ade9 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -10,7 +10,7 @@ def test_recursive(): value = {"a": {"b": {"c": 1}}} - generic_value = Generic.parse_obj(value) + generic_value = Generic.model_validate(value) assert generic_value == Generic(a=Generic(b=Generic(c=1))) assert generic_value.model_dump() == value diff --git a/tests/test_types.py b/tests/test_types.py index 76d4cff6..390a3d76 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -11,7 +11,7 @@ def test_loose_ip_v4_network_type(): class Model(BaseModel): ip_network: LooseIPv4Network - model_schema = Model.schema() + model_schema = Model.model_json_schema() assert model_schema == { "title": "Model", "type": "object", @@ -24,7 +24,7 @@ def test_loose_ip_v6_network_type(): class Model(BaseModel): ip_network: LooseIPv6Network - model_schema = Model.schema() + model_schema = Model.model_json_schema() assert model_schema == { "title": "Model", "type": "object",