Skip to content

Commit

Permalink
Master fixes take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoucheiron committed Jun 11, 2024
1 parent 0ef033a commit 2f50ddb
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ formats: all
build:
os: ubuntu-22.04
tools:
python: "3.7"
python: "3.8"

python:
install:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 11 additions & 11 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
#
# 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
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:
Expand Down
16 changes: 8 additions & 8 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/properties/test_principal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
8 changes: 4 additions & 4 deletions tests/resources/properties/test_statement_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
Expand Down Expand Up @@ -669,13 +669,13 @@ 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"})


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
8 changes: 4 additions & 4 deletions tests/resources/test_generic_resoure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def test_generic_resource():
resource = GenericResource.parse_obj(
resource = GenericResource.model_validate(
{
"Type": "AWS::ECR::RegistryPolicy",
"Properties": {
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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"
2 changes: 1 addition & 1 deletion tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 2f50ddb

Please sign in to comment.