Skip to content

Commit 030ea14

Browse files
Return NotImplemented instead of raising NotImplementedError for special dunder functions
1 parent da400cf commit 030ea14

4 files changed

Lines changed: 49 additions & 49 deletions

File tree

perdoo/models/comic_info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def load(value: str) -> YesNo:
4141

4242
def __lt__(self: YesNo, other) -> int: # noqa: ANN001
4343
if not isinstance(other, type(self)):
44-
raise NotImplementedError
44+
return NotImplemented
4545
return self.value < other.value
4646

4747
def __str__(self: YesNo) -> str:
@@ -63,7 +63,7 @@ def load(value: str) -> Manga:
6363

6464
def __lt__(self: Manga, other) -> int: # noqa: ANN001
6565
if not isinstance(other, type(self)):
66-
raise NotImplementedError
66+
return NotImplemented
6767
return self.value < other.value
6868

6969
def __str__(self: Manga) -> str:
@@ -96,7 +96,7 @@ def load(value: str) -> AgeRating:
9696

9797
def __lt__(self: AgeRating, other) -> int: # noqa: ANN001
9898
if not isinstance(other, type(self)):
99-
raise NotImplementedError
99+
return NotImplemented
100100
return self.value < other.value
101101

102102
def __str__(self: AgeRating) -> str:
@@ -125,7 +125,7 @@ def load(value: str) -> PageType:
125125

126126
def __lt__(self: PageType, other) -> int: # noqa: ANN001
127127
if not isinstance(other, type(self)):
128-
raise NotImplementedError
128+
return NotImplemented
129129
return self.value < other.value
130130

131131
def __str__(self: PageType) -> str:
@@ -144,12 +144,12 @@ class Page(PascalModel):
144144

145145
def __lt__(self: Page, other) -> int: # noqa: ANN001
146146
if not isinstance(other, type(self)):
147-
raise NotImplementedError
147+
return NotImplemented
148148
return self.image < other.image
149149

150150
def __eq__(self: Page, other) -> bool: # noqa: ANN001
151151
if not isinstance(other, type(self)):
152-
raise NotImplementedError
152+
return NotImplemented
153153
return self.image == other.image
154154

155155
def __hash__(self: Page) -> int:

perdoo/models/metadata.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def load(value: str) -> Source:
4545

4646
def __lt__(self: Source, other) -> int: # noqa: ANN001
4747
if not isinstance(other, type(self)):
48-
raise NotImplementedError
48+
return NotImplemented
4949
return self.value < other.value
5050

5151
def __str__(self: Source) -> str:
@@ -58,12 +58,12 @@ class Resource(PascalModel):
5858

5959
def __lt__(self: Resource, other) -> int: # noqa: ANN001
6060
if not isinstance(other, type(self)):
61-
raise NotImplementedError
61+
return NotImplemented
6262
return self.source < other.source
6363

6464
def __eq__(self: Resource, other) -> bool: # noqa: ANN001
6565
if not isinstance(other, type(self)):
66-
raise NotImplementedError
66+
return NotImplemented
6767
return self.source == other.source
6868

6969
def __hash__(self: Resource) -> int:
@@ -82,12 +82,12 @@ def __init__(self: TitledResource, **data: Any):
8282

8383
def __lt__(self: TitledResource, other) -> int: # noqa: ANN001
8484
if not isinstance(other, type(self)):
85-
raise NotImplementedError
85+
return NotImplemented
8686
return self.title.casefold() < other.title.casefold()
8787

8888
def __eq__(self: TitledResource, other) -> bool: # noqa: ANN001
8989
if not isinstance(other, type(self)):
90-
raise NotImplementedError
90+
return NotImplemented
9191
return self.title.casefold() == other.title.casefold()
9292

9393
def __hash__(self: TitledResource) -> int:
@@ -106,12 +106,12 @@ def __init__(self: Credit, **data: Any):
106106

107107
def __lt__(self: Credit, other) -> int: # noqa: ANN001
108108
if not isinstance(other, type(self)):
109-
raise NotImplementedError
109+
return NotImplemented
110110
return self.creator < other.creator
111111

112112
def __eq__(self: Credit, other) -> bool: # noqa: ANN001
113113
if not isinstance(other, type(self)):
114-
raise NotImplementedError
114+
return NotImplemented
115115
return self.creator == other.creator
116116

117117
def __hash__(self: Credit) -> int:
@@ -135,7 +135,7 @@ def load(value: str) -> Format:
135135

136136
def __lt__(self: Format, other) -> int: # noqa: ANN001
137137
if not isinstance(other, type(self)):
138-
raise NotImplementedError
138+
return NotImplemented
139139
return self.value < other.value
140140

141141
def __str__(self: Format) -> str:
@@ -156,7 +156,7 @@ def __init__(self: Series, **data: Any):
156156

157157
def __lt__(self: Series, other) -> int: # noqa: ANN001
158158
if not isinstance(other, type(self)):
159-
raise NotImplementedError
159+
return NotImplemented
160160
if self.publisher != other.publisher:
161161
return self.publisher < other.publisher
162162
if self.title.casefold() != other.title.casefold():
@@ -165,7 +165,7 @@ def __lt__(self: Series, other) -> int: # noqa: ANN001
165165

166166
def __eq__(self: Series, other) -> bool: # noqa: ANN001
167167
if not isinstance(other, type(self)):
168-
raise NotImplementedError
168+
return NotImplemented
169169
return (self.publisher, self.title.casefold(), self.volume) == (
170170
other.publisher,
171171
other.title.casefold(),
@@ -216,7 +216,7 @@ def __init__(self: Issue, **data: Any):
216216

217217
def __lt__(self: Issue, other) -> int: # noqa: ANN001
218218
if not isinstance(other, type(self)):
219-
raise NotImplementedError
219+
return NotImplemented
220220
if self.series != other.series:
221221
return self.series < other.series
222222
if self.number.casefold() != other.number.casefold():
@@ -225,7 +225,7 @@ def __lt__(self: Issue, other) -> int: # noqa: ANN001
225225

226226
def __eq__(self: Issue, other) -> bool: # noqa: ANN001
227227
if not isinstance(other, type(self)):
228-
raise NotImplementedError
228+
return NotImplemented
229229
return (self.series, self.number.casefold(), self.format) == (
230230
other.series,
231231
other.number.casefold(),
@@ -267,7 +267,7 @@ def load(value: str) -> PageType:
267267

268268
def __lt__(self: PageType, other) -> int: # noqa: ANN001
269269
if not isinstance(other, type(self)):
270-
raise NotImplementedError
270+
return NotImplemented
271271
return self.value < other.value
272272

273273
def __str__(self: PageType) -> str:
@@ -285,12 +285,12 @@ class Page(PascalModel):
285285

286286
def __lt__(self: Page, other) -> int: # noqa: ANN001
287287
if not isinstance(other, type(self)):
288-
raise NotImplementedError
288+
return NotImplemented
289289
return self.index < other.index
290290

291291
def __eq__(self: Page, other) -> bool: # noqa: ANN001
292292
if not isinstance(other, type(self)):
293-
raise NotImplementedError
293+
return NotImplemented
294294
return self.filename == other.filename
295295

296296
def __hash__(self: Page) -> int:
@@ -333,12 +333,12 @@ def __init__(self: Metadata, **data: Any):
333333

334334
def __lt__(self: Metadata, other) -> int: # noqa: ANN001
335335
if not isinstance(other, type(self)):
336-
raise NotImplementedError
336+
return NotImplemented
337337
return self.issue < other.issue
338338

339339
def __eq__(self: Metadata, other) -> bool: # noqa: ANN001
340340
if not isinstance(other, type(self)):
341-
raise NotImplementedError
341+
return NotImplemented
342342
return self.issue == other.issue
343343

344344
def __hash__(self: Metadata) -> int:

perdoo/models/metron_info.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def load(value: str) -> InformationSource:
5151

5252
def __lt__(self: InformationSource, other) -> int: # noqa: ANN001
5353
if not isinstance(other, type(self)):
54-
raise NotImplementedError
54+
return NotImplemented
5555
return self.value < other.value
5656

5757
def __str__(self: InformationSource) -> str:
@@ -64,12 +64,12 @@ class Source(PascalModel):
6464

6565
def __lt__(self: Source, other) -> int: # noqa: ANN001
6666
if not isinstance(other, type(self)):
67-
raise NotImplementedError
67+
return NotImplemented
6868
return self.source < other.source
6969

7070
def __eq__(self: Source, other) -> bool: # noqa: ANN001
7171
if not isinstance(other, type(self)):
72-
raise NotImplementedError
72+
return NotImplemented
7373
return self.source == other.source
7474

7575
def __hash__(self: Source) -> int:
@@ -87,12 +87,12 @@ class Resource(PascalModel):
8787

8888
def __lt__(self: Resource, other) -> int: # noqa: ANN001
8989
if not isinstance(other, type(self)):
90-
raise NotImplementedError
90+
return NotImplemented
9191
return self.value < other.value
9292

9393
def __eq__(self: Resource, other) -> bool: # noqa: ANN001
9494
if not isinstance(other, type(self)):
95-
raise NotImplementedError
95+
return NotImplemented
9696
return self.value == other.value
9797

9898
def __hash__(self: Resource) -> int:
@@ -121,7 +121,7 @@ def load(value: str) -> Format:
121121

122122
def __lt__(self: Format, other) -> int: # noqa: ANN001
123123
if not isinstance(other, type(self)):
124-
raise NotImplementedError
124+
return NotImplemented
125125
return self.value < other.value
126126

127127
def __str__(self: Format) -> str:
@@ -143,12 +143,12 @@ class Price(PascalModel):
143143

144144
def __lt__(self: Price, other) -> int: # noqa: ANN001
145145
if not isinstance(other, type(self)):
146-
raise NotImplementedError
146+
return NotImplemented
147147
return self.country < other.country
148148

149149
def __eq__(self: Price, other) -> bool: # noqa: ANN001
150150
if not isinstance(other, type(self)):
151-
raise NotImplementedError
151+
return NotImplemented
152152
return self.country == other.country
153153

154154
def __hash__(self: Price) -> int:
@@ -181,7 +181,7 @@ def load(value: str) -> Genre:
181181

182182
def __lt__(self: Genre, other) -> int: # noqa: ANN001
183183
if not isinstance(other, type(self)):
184-
raise NotImplementedError
184+
return NotImplemented
185185
return self.value < other.value
186186

187187
def __str__(self: Genre) -> str:
@@ -194,12 +194,12 @@ class GenreResource(PascalModel):
194194

195195
def __lt__(self: GenreResource, other) -> int: # noqa: ANN001
196196
if not isinstance(other, type(self)):
197-
raise NotImplementedError
197+
return NotImplemented
198198
return self.value < other.value
199199

200200
def __eq__(self: GenreResource, other) -> bool: # noqa: ANN001
201201
if not isinstance(other, type(self)):
202-
raise NotImplementedError
202+
return NotImplemented
203203
return self.value == other.value
204204

205205
def __hash__(self: GenreResource) -> int:
@@ -213,12 +213,12 @@ class Arc(PascalModel):
213213

214214
def __lt__(self: Arc, other) -> int: # noqa: ANN001
215215
if not isinstance(other, type(self)):
216-
raise NotImplementedError
216+
return NotImplemented
217217
return self.name < other.name
218218

219219
def __eq__(self: Arc, other) -> bool: # noqa: ANN001
220220
if not isinstance(other, type(self)):
221-
raise NotImplementedError
221+
return NotImplemented
222222
return self.name == other.name
223223

224224
def __hash__(self: Arc) -> int:
@@ -232,12 +232,12 @@ class Universe(PascalModel):
232232

233233
def __lt__(self: Universe, other) -> int: # noqa: ANN001
234234
if not isinstance(other, type(self)):
235-
raise NotImplementedError
235+
return NotImplemented
236236
return self.name < other.name
237237

238238
def __eq__(self: Universe, other) -> bool: # noqa: ANN001
239239
if not isinstance(other, type(self)):
240-
raise NotImplementedError
240+
return NotImplemented
241241
return self.name == other.name
242242

243243
def __hash__(self: Universe) -> int:
@@ -265,7 +265,7 @@ def load(value: str) -> AgeRating:
265265

266266
def __lt__(self: AgeRating, other) -> int: # noqa: ANN001
267267
if not isinstance(other, type(self)):
268-
raise NotImplementedError
268+
return NotImplemented
269269
return self.value < other.value
270270

271271
def __str__(self: AgeRating) -> str:
@@ -325,7 +325,7 @@ def load(value: str) -> Role:
325325

326326
def __lt__(self: Role, other) -> int: # noqa: ANN001
327327
if not isinstance(other, type(self)):
328-
raise NotImplementedError
328+
return NotImplemented
329329
return self.value < other.value
330330

331331
def __str__(self: Role) -> str:
@@ -338,12 +338,12 @@ class RoleResource(PascalModel):
338338

339339
def __lt__(self: RoleResource, other) -> int: # noqa: ANN001
340340
if not isinstance(other, type(self)):
341-
raise NotImplementedError
341+
return NotImplemented
342342
return self.value < other.value
343343

344344
def __eq__(self: RoleResource, other) -> bool: # noqa: ANN001
345345
if not isinstance(other, type(self)):
346-
raise NotImplementedError
346+
return NotImplemented
347347
return self.value == other.value
348348

349349
def __hash__(self: RoleResource) -> int:
@@ -364,12 +364,12 @@ def __init__(self: Credit, **data: Any):
364364

365365
def __lt__(self: Credit, other) -> int: # noqa: ANN001
366366
if not isinstance(other, type(self)):
367-
raise NotImplementedError
367+
return NotImplemented
368368
return self.creator < other.creator
369369

370370
def __eq__(self: Credit, other) -> bool: # noqa: ANN001
371371
if not isinstance(other, type(self)):
372-
raise NotImplementedError
372+
return NotImplemented
373373
return self.creator == other.creator
374374

375375
def __hash__(self: Credit) -> int:
@@ -398,7 +398,7 @@ def load(value: str) -> PageType:
398398

399399
def __lt__(self: PageType, other) -> int: # noqa: ANN001
400400
if not isinstance(other, type(self)):
401-
raise NotImplementedError
401+
return NotImplemented
402402
return self.value < other.value
403403

404404
def __str__(self: PageType) -> str:
@@ -417,12 +417,12 @@ class Page(PascalModel):
417417

418418
def __lt__(self: Page, other) -> int: # noqa: ANN001
419419
if not isinstance(other, type(self)):
420-
raise NotImplementedError
420+
return NotImplemented
421421
return self.image < other.image
422422

423423
def __eq__(self: Page, other) -> bool: # noqa: ANN001
424424
if not isinstance(other, type(self)):
425-
raise NotImplementedError
425+
return NotImplemented
426426
return self.image == other.image
427427

428428
def __hash__(self: Page) -> int:

perdoo/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def load(value: str) -> OutputFormat:
7171

7272
def __lt__(self: OutputFormat, other) -> int: # noqa: ANN001
7373
if not isinstance(other, type(self)):
74-
raise NotImplementedError
74+
return NotImplemented
7575
return self.value < other.value
7676

7777
def __str__(self: OutputFormat) -> str:
@@ -93,7 +93,7 @@ def load(value: str) -> Service:
9393

9494
def __lt__(self: Service, other) -> int: # noqa: ANN001
9595
if not isinstance(other, type(self)):
96-
raise NotImplementedError
96+
return NotImplemented
9797
return self.value < other.value
9898

9999
def __str__(self: Service) -> str:

0 commit comments

Comments
 (0)