Skip to content

Commit 6b68fc1

Browse files
committed
Codechange: remove dependency on marshmallow-enum
It is now integrated in marshmallow, so also no longer a need.
1 parent de29c21 commit 6b68fc1

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

bananas_api/helpers/api_schema.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
validates_schema,
88
)
99
from marshmallow.exceptions import ValidationError
10-
from marshmallow_enum import EnumField
1110

1211
from .content_storage import get_indexed_package
1312
from .enums import (
@@ -122,7 +121,7 @@ class Authors(OrderedSchema):
122121

123122

124123
class Dependency(OrderedSchema):
125-
content_type = EnumField(ContentType, data_key="content-type", by_value=True)
124+
content_type = fields.Enum(ContentType, data_key="content-type", by_value=True)
126125
unique_id = fields.String(data_key="unique-id", validate=validate.Length(equal=8))
127126
md5sum_partial = fields.String(data_key="md5sum-partial", validate=validate.Length(equal=8))
128127

@@ -150,7 +149,7 @@ def validate_dependency(self, data, **kwargs):
150149

151150

152151
class Compatability(OrderedSchema):
153-
name = EnumField(Branch, by_value=True)
152+
name = fields.Enum(Branch, by_value=True)
154153
conditions = fields.List(fields.String(), validate=validate.Length(min=1, max=2))
155154

156155
@validates("conditions")
@@ -207,36 +206,36 @@ def validate_conditions(self, data, **kwargs):
207206

208207

209208
class Classification(OrderedSchema):
210-
set = EnumField(NewGRFSet, by_value=True)
211-
palette = EnumField(Palette, by_value=True)
209+
set = fields.Enum(NewGRFSet, by_value=True)
210+
palette = fields.Enum(Palette, by_value=True)
212211
has_high_res = fields.Boolean(data_key="has-high-res")
213212
has_sound_effects = fields.Boolean(data_key="has-sound-effects")
214-
shape = EnumField(Shape, by_value=True)
215-
resolution = EnumField(Resolution, by_value=True)
216-
terrain_type = EnumField(TerrainType, by_value=True, data_key="terrain-type")
217-
size = EnumField(Size, by_value=True)
218-
climate = EnumField(Climate, by_value=True)
213+
shape = fields.Enum(Shape, by_value=True)
214+
resolution = fields.Enum(Resolution, by_value=True)
215+
terrain_type = fields.Enum(TerrainType, by_value=True, data_key="terrain-type")
216+
size = fields.Enum(Size, by_value=True)
217+
climate = fields.Enum(Climate, by_value=True)
219218

220219

221220
class VersionMinimized(Global):
222221
read_only = ["upload_date", "md5sum_partial", "classification", "filesize", "license", "availability"]
223222
read_only_for_new = ["upload_date", "md5sum_partial", "classification", "filesize", "availability"]
224223

225224
version = fields.String(validate=ValidateBytesLength(max=15))
226-
license = EnumField(License, by_value=True)
225+
license = fields.Enum(License, by_value=True)
227226
upload_date = fields.DateTime(data_key="upload-date", format="iso")
228227
md5sum_partial = fields.String(data_key="md5sum-partial", validate=validate.Length(equal=8))
229228
classification = fields.Nested(Classification())
230229
filesize = fields.Integer()
231-
availability = EnumField(Availability, by_value=True)
230+
availability = fields.Enum(Availability, by_value=True)
232231
dependencies = fields.List(fields.Nested(Dependency()))
233232
compatibility = fields.List(fields.Nested(Compatability()))
234233

235234

236235
class Package(Global):
237236
read_only = ["content_type", "unique_id", "archived", "replaced_by"]
238237

239-
content_type = EnumField(ContentType, data_key="content-type", by_value=True)
238+
content_type = fields.Enum(ContentType, data_key="content-type", by_value=True)
240239
unique_id = fields.String(data_key="unique-id", validate=validate.Length(equal=8))
241240
authors = fields.List(fields.Nested(Author))
242241
versions = fields.List(fields.Nested(VersionMinimized))
@@ -245,7 +244,7 @@ class Package(Global):
245244
class Version(VersionMinimized):
246245
read_only = ["content_type", "unique_id"]
247246

248-
content_type = EnumField(ContentType, data_key="content-type", by_value=True)
247+
content_type = fields.Enum(ContentType, data_key="content-type", by_value=True)
249248
unique_id = fields.String(data_key="unique-id", validate=validate.Length(equal=8))
250249

251250

@@ -260,7 +259,7 @@ class UploadStatus(Version):
260259
files = fields.List(fields.Nested(UploadStatusFiles))
261260
warnings = fields.List(fields.String)
262261
errors = fields.List(fields.String)
263-
status = EnumField(Status, by_value=True)
262+
status = fields.Enum(Status, by_value=True)
264263

265264

266265
class UploadNew(OrderedSchema):

requirements.base

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ click
55
github3.py
66
gitpython
77
marshmallow
8-
marshmallow-enum
98
openttd-helpers
109
python-dateutil
1110
PyYAML

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ httpx==0.28.1
2121
idna==3.10
2222
jmespath==1.0.1
2323
marshmallow==4.0.0
24-
marshmallow-enum==1.5.1
2524
multidict==6.5.0
2625
openttd-helpers==1.4.0
2726
packaging==25.0

0 commit comments

Comments
 (0)