Skip to content

Commit 45de4b2

Browse files
authored
Upgrade pydantic 1.10 (#20)
1 parent 5793486 commit 45de4b2

File tree

6 files changed

+402
-563
lines changed

6 files changed

+402
-563
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: fix-byte-order-marker
1717

1818
- repo: https://github.com/asottile/pyupgrade
19-
rev: v3.3.1
19+
rev: v3.8.0
2020
hooks:
2121
- id: pyupgrade
2222
args: [ "--py38-plus" ]

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ COPY ecs_files_composer /opt/ecs_files_composer
1010
COPY poetry.lock pyproject.toml MANIFEST.in README.rst LICENSE /opt/
1111
RUN yum install gcc -y
1212
RUN python -m pip install pip -U; python -m pip install poetry; poetry build
13-
RUN #pip install wheel --no-cache-dir && pip install dist/*.whl --no-cache-dir -t /opt/venv
14-
#RUN find /opt/venv -type d -name "*pycache*" | xargs -i -P10 rm -rf {}
13+
1514

1615
FROM $BASE_IMAGE
1716

@@ -20,7 +19,7 @@ RUN apt-get update; apt-get install gcc -y; \
2019
python -m pip install pip -U --no-cache-dir; \
2120
python -m pip install /app/dist/*.whl ;\
2221
apt-get purge gcc -y; \
23-
sudo apt-get --purge autoremove;\
22+
apt-get --purge autoremove;\
2423
apt-get autoremove --yes ; \
2524
apt-get clean autoclean ; \
2625
rm -rf /var/lib/{apt,dpkg,cache,log}/

ecs_files_composer/files_mgmt.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,33 +150,31 @@ def handle_s3_source(self, iam_override=None, session_override=None) -> bool:
150150
:param boto3.session.Session session_override:
151151
:return: bool, result of the download from S3.
152152
"""
153-
from ecs_files_composer.input import S3Def1
153+
from ecs_files_composer.input import S3Def
154154

155-
if not isinstance(self.source.s3.__root__, S3Def1):
156-
raise TypeError(
157-
"S3 source is not of type S3Def1", type(self.source.s3.__root__)
158-
)
155+
if not isinstance(self.source.s3, S3Def):
156+
raise TypeError("S3 source is not of type S3Def", type(self.source.s3))
159157

160-
if self.source.s3.__root__.iam_override:
161-
fetcher = S3Fetcher(iam_config_object=self.source.s3.__root__.iam_override)
158+
if self.source.s3.iam_override:
159+
fetcher = S3Fetcher(iam_config_object=self.source.s3.iam_override)
162160
elif iam_override:
163161
fetcher = S3Fetcher(iam_config_object=iam_override)
164162
elif session_override:
165163
fetcher = S3Fetcher(client_session_override=session_override)
166164
else:
167165
fetcher = S3Fetcher()
168166
try:
169-
if self.source.s3.__root__.s3_uri:
167+
if self.source.s3.s3_uri:
170168
self.content = fetcher.get_content(
171-
s3_uri=self.source.s3.__root__.s3_uri.__root__,
169+
s3_uri=self.source.s3.s3_uri.__root__,
172170
)
173-
elif self.source.s3.__root__.compose_x_uri:
171+
elif self.source.s3.compose_x_uri:
174172
self.content = fetcher.get_content(
175-
composex_uri=self.source.s3.__root__.compose_x_uri.__root__,
173+
composex_uri=self.source.s3.compose_x_uri.__root__,
176174
)
177175
else:
178-
bucket_name = expandvars(self.source.s3.__root__.bucket_name)
179-
key = expandvars(self.source.s3.__root__.key)
176+
bucket_name = expandvars(self.source.s3.bucket_name)
177+
key = expandvars(self.source.s3.key)
180178
self.content = fetcher.get_content(
181179
s3_bucket=bucket_name,
182180
s3_key=key,

ecs_files_composer/input.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# generated by datamodel-codegen:
22
# filename: ecs-files-input.json
3-
# timestamp: 2023-04-03T09:06:05+00:00
3+
# timestamp: 2023-07-03T22:45:29+00:00
44

55
from __future__ import annotations
66

77
from enum import Enum
8-
from typing import Any, Dict, List, Optional, Union
8+
from typing import Dict, List, Optional, Union
99

1010
from pydantic import AnyUrl, BaseModel, EmailStr, Extra, Field, constr
1111

@@ -154,7 +154,7 @@ class SecretDef(BaseModel):
154154
iam_override: Optional[IamOverrideDef] = Field(None, alias="IamOverride")
155155

156156

157-
class S3Def1(BaseModel):
157+
class S3Def(BaseModel):
158158
s3_uri: Optional[S3Uri] = Field(None, alias="S3Uri")
159159
compose_x_uri: Optional[ComposeXUri] = Field(None, alias="ComposeXUri")
160160
bucket_name: Optional[str] = Field(
@@ -171,10 +171,6 @@ class S3Def1(BaseModel):
171171
iam_override: Optional[IamOverrideDef] = Field(None, alias="IamOverride")
172172

173173

174-
class S3Def(BaseModel):
175-
__root__: Union[S3Def1, Any, Any, Any]
176-
177-
178174
class X509CertDef(BaseModel):
179175
class Config:
180176
extra = Extra.allow

0 commit comments

Comments
 (0)