Skip to content

Commit e545371

Browse files
committed
fix many ruff issues
1 parent 1aee357 commit e545371

37 files changed

+231
-212
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ ignore = [
171171
"RUF012",
172172
# PEP 484 prohibits implicit `Optional`
173173
"RUF013",
174+
174175
# Missing type annotation for {name} in method
175176
"ANN101",
176177
# Missing type annotation for {name} in classmethod
@@ -179,6 +180,8 @@ ignore = [
179180
"ANN202",
180181
# Missing return type annotation for special method {name}
181182
"ANN204",
183+
# Dynamically typed expressions ({name}) are disallowed in `other`
184+
"ANN401",
182185
]
183186

184187

tibiapy/builders/bazaar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def filters(self, filters: AuctionFilters) -> Self:
5151
self._filters = filters
5252
return self
5353

54-
def build(self):
54+
def build(self) -> CharacterBazaar:
5555
return CharacterBazaar(
5656
current_page=self._current_page,
5757
total_pages=self._total_pages,
@@ -143,7 +143,7 @@ def status(self, status: AuctionStatus) -> Self:
143143
self._status = status
144144
return self
145145

146-
def build(self):
146+
def build(self) -> Auction:
147147
return Auction(
148148
auction_id=self._auction_id,
149149
name=self._name,
@@ -399,7 +399,7 @@ def add_revealed_gem(self, gem: RevealedGem) -> Self:
399399
self._revealed_gems.append(gem)
400400
return self
401401

402-
def build(self):
402+
def build(self) -> AuctionDetails:
403403
return AuctionDetails(
404404
hit_points=self._hit_points,
405405
mana=self._mana,

tibiapy/builders/character.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def other_characters(self, other_characters: List[OtherCharacter]) -> Self:
166166
self._other_characters = other_characters
167167
return self
168168

169-
def build(self):
169+
def build(self) -> Character:
170170
return Character(
171171
name=self._name,
172172
is_traded=self._traded,

tibiapy/builders/creature.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def identifier(self, identifier: str) -> Self:
2121
self._identifier = identifier
2222
return self
2323

24-
def build(self):
24+
def build(self) -> CreatureEntry:
2525
return CreatureEntry(
2626
name=self._name,
2727
identifier=self._identifier,
@@ -91,7 +91,7 @@ def convinceable(self, convinceable: bool) -> Self:
9191
self._convinceable = convinceable
9292
return self
9393

94-
def build(self):
94+
def build(self) -> Creature:
9595
return Creature(
9696
name=self._name,
9797
identifier=self._identifier,

tibiapy/builders/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def add_event(self, event: EventEntry) -> Self:
3232
self._events.append(event)
3333
return self
3434

35-
def build(self):
35+
def build(self) -> EventSchedule:
3636
return EventSchedule(
3737
month=self._month,
3838
year=self._year,

tibiapy/builders/forum.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_entry(self, entry) -> Self:
4545
self._entries.append(entry)
4646
return self
4747

48-
def build(self):
48+
def build(self) -> CMPostArchive:
4949
return CMPostArchive(
5050
from_date=self._from_date,
5151
to_date=self._to_date,
@@ -79,7 +79,7 @@ def thread_title(self, thread_title) -> Self:
7979
self._thread_title = thread_title
8080
return self
8181

82-
def build(self):
82+
def build(self) -> CMPost:
8383
return CMPost(
8484
post_id=self._post_id,
8585
posted_on=self._posted_on,
@@ -141,7 +141,7 @@ def to_date(self, to_date) -> Self:
141141
self._to_date = to_date
142142
return self
143143

144-
def build(self):
144+
def build(self) -> ForumAnnouncement:
145145
return ForumAnnouncement(
146146
announcement_id=self._announcement_id,
147147
board=self._board,
@@ -217,7 +217,7 @@ def add_entry(self, entry) -> Self:
217217
self._entries.append(entry)
218218
return self
219219

220-
def build(self):
220+
def build(self) -> ForumBoard:
221221
return ForumBoard(
222222
board_id=self._board_id,
223223
name=self._name,
@@ -303,7 +303,7 @@ def add_entry(self, entry) -> Self:
303303
self._entries.append(entry)
304304
return self
305305

306-
def build(self):
306+
def build(self) -> ForumThread:
307307
return ForumThread(
308308
title=self._title,
309309
thread_id=self._thread_id,

tibiapy/builders/guild.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def active(self, active: bool) -> Self:
4848
self._active = active
4949
return self
5050

51-
def build(self):
51+
def build(self) -> GuildEntry:
5252
return GuildEntry(
5353
name=self._name,
5454
logo_url=self._logo_url,
@@ -128,7 +128,7 @@ def add_invite(self, invite: GuildInvite) -> Self:
128128
self._invites.append(invite)
129129
return self
130130

131-
def build(self):
131+
def build(self) -> Guild:
132132
return Guild(
133133
name=self._name,
134134
logo_url=self._logo_url,
@@ -166,7 +166,7 @@ def history(self, history: List[GuildWarEntry]) -> Self:
166166
self._history = history
167167
return self
168168

169-
def build(self):
169+
def build(self) -> GuildWars:
170170
return GuildWars(
171171
name=self._name,
172172
history=self._history,
@@ -237,7 +237,7 @@ def surrender(self, surrender: bool) -> Self:
237237
self._surrender = surrender
238238
return self
239239

240-
def build(self):
240+
def build(self) -> GuildWarEntry:
241241
return GuildWarEntry(
242242
guild_name=self._guild_name,
243243
guild_score=self._guild_score,

tibiapy/builders/highscores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def available_worlds(self, available_worlds: List[str]) -> Self:
7474
self._available_worlds = available_worlds
7575
return self
7676

77-
def build(self):
77+
def build(self) -> Highscores:
7878
return Highscores(
7979
world=self._world,
8080
category=self._category,

tibiapy/builders/house.py

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from typing import List, TYPE_CHECKING, Optional
55

6+
from typing_extensions import Self
7+
68
from tibiapy.models.house import HouseEntry, HousesSection, House
79

810
if TYPE_CHECKING:
@@ -21,43 +23,43 @@ def __init__(self):
2123
self._available_worlds = []
2224
self._available_towns = []
2325

24-
def world(self, world: str):
26+
def world(self, world: str) -> Self:
2527
self._world = world
2628
return self
2729

28-
def town(self, town: str):
30+
def town(self, town: str) -> Self:
2931
self._town = town
3032
return self
3133

32-
def status(self, status: HouseStatus):
34+
def status(self, status: HouseStatus) -> Self:
3335
self._status = status
3436
return self
3537

36-
def house_type(self, house_type: HouseType):
38+
def house_type(self, house_type: HouseType) -> Self:
3739
self._house_type = house_type
3840
return self
3941

40-
def order(self, order: HouseOrder):
42+
def order(self, order: HouseOrder) -> Self:
4143
self._order = order
4244
return self
4345

44-
def entries(self, entries: List[HouseEntry]):
46+
def entries(self, entries: List[HouseEntry]) -> Self:
4547
self._entries = entries
4648
return self
4749

48-
def add_entry(self, entry: HouseEntry):
50+
def add_entry(self, entry: HouseEntry) -> Self:
4951
self._entries.append(entry)
5052
return self
5153

52-
def available_worlds(self, available_worlds: List[str]):
54+
def available_worlds(self, available_worlds: List[str]) -> Self:
5355
self._available_worlds = available_worlds
5456
return self
5557

56-
def available_towns(self, available_towns: List[str]):
58+
def available_towns(self, available_towns: List[str]) -> Self:
5759
self._available_towns = available_towns
5860
return self
5961

60-
def build(self):
62+
def build(self) -> HousesSection:
6163
return HousesSection(
6264
world=self._world,
6365
town=self._town,
@@ -100,35 +102,35 @@ def __init__(self):
100102
self._time_left = None
101103
self._highest_bid = None
102104

103-
def status(self, status: HouseStatus):
105+
def status(self, status: HouseStatus) -> Self:
104106
self._status = status
105107
return self
106108

107-
def type(self, type: HouseType):
109+
def type(self, type: HouseType) -> Self:
108110
self._type = type
109111
return self
110112

111-
def town(self, town: str):
113+
def town(self, town: str) -> Self:
112114
self._town = town
113115
return self
114116

115-
def size(self, size: int):
117+
def size(self, size: int) -> Self:
116118
self._size = size
117119
return self
118120

119-
def rent(self, rent: int):
121+
def rent(self, rent: int) -> Self:
120122
self._rent = rent
121123
return self
122124

123-
def time_left(self, time_left: Optional[datetime.timedelta]):
125+
def time_left(self, time_left: Optional[datetime.timedelta]) -> Self:
124126
self._time_left = time_left
125127
return self
126128

127-
def highest_bid(self, highest_bid: Optional[int]):
129+
def highest_bid(self, highest_bid: Optional[int]) -> Self:
128130
self._highest_bid = highest_bid
129131
return self
130132

131-
def build(self):
133+
def build(self) -> HouseEntry:
132134
return HouseEntry(
133135
name=self._name,
134136
id=self._id,
@@ -163,71 +165,71 @@ def __init__(self):
163165
self._highest_bidder = None
164166
self._auction_end = None
165167

166-
def status(self, status: HouseStatus):
168+
def status(self, status: HouseStatus) -> Self:
167169
self._status = status
168170
return self
169171

170-
def rent(self, rent: int):
172+
def rent(self, rent: int) -> Self:
171173
self._rent = rent
172174
return self
173175

174-
def type(self, type: HouseType):
176+
def type(self, type: HouseType) -> Self:
175177
self._type = type
176178
return self
177179

178-
def image_url(self, image_url: str):
180+
def image_url(self, image_url: str) -> Self:
179181
self._image_url = image_url
180182
return self
181183

182-
def beds(self, beds: int):
184+
def beds(self, beds: int) -> Self:
183185
self._beds = beds
184186
return self
185187

186-
def size(self, size: int):
188+
def size(self, size: int) -> Self:
187189
self._size = size
188190
return self
189191

190-
def owner(self, owner: Optional[str]):
192+
def owner(self, owner: Optional[str]) -> Self:
191193
self._owner = owner
192194
return self
193195

194-
def owner_sex(self, owner_sex: Sex):
196+
def owner_sex(self, owner_sex: Sex) -> Self:
195197
self._owner_sex = owner_sex
196198
return self
197199

198-
def paid_until(self, paid_until: Optional[datetime.datetime]):
200+
def paid_until(self, paid_until: Optional[datetime.datetime]) -> Self:
199201
self._paid_until = paid_until
200202
return self
201203

202-
def transfer_date(self, transfer_date: Optional[datetime.datetime]):
204+
def transfer_date(self, transfer_date: Optional[datetime.datetime]) -> Self:
203205
self._transfer_date = transfer_date
204206
return self
205207

206-
def transfer_recipient(self, transfer_recipient: Optional[str]):
208+
def transfer_recipient(self, transfer_recipient: Optional[str]) -> Self:
207209
self._transfer_recipient = transfer_recipient
208210
return self
209211

210-
def transfer_price(self, transfer_price: Optional[int]):
212+
def transfer_price(self, transfer_price: Optional[int]) -> Self:
211213
self._transfer_price = transfer_price
212214
return self
213215

214-
def transfer_accepted(self, transfer_accepted: Optional[bool]):
216+
def transfer_accepted(self, transfer_accepted: Optional[bool]) -> Self:
215217
self._transfer_accepted = transfer_accepted
216218
return self
217219

218-
def highest_bid(self, highest_bid: Optional[int]):
220+
def highest_bid(self, highest_bid: Optional[int]) -> Self:
219221
self._highest_bid = highest_bid
220222
return self
221223

222-
def highest_bidder(self, highest_bidder: Optional[str]):
224+
def highest_bidder(self, highest_bidder: Optional[str]) -> Self:
223225
self._highest_bidder = highest_bidder
224226
return self
225227

226-
def auction_end(self, auction_end: Optional[datetime.datetime]):
228+
def auction_end(self, auction_end: Optional[datetime.datetime]) -> Self:
227229
self._auction_end = auction_end
228230
return self
229231

230-
def build(self):
232+
def build(self) -> House:
231233
return House(
232234
name=self._name,
233235
id=self._id,

tibiapy/builders/kill_statistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def available_worlds(self, available_worlds: List[str]) -> Self:
3636
self._available_worlds = available_worlds
3737
return self
3838

39-
def build(self):
39+
def build(self) -> KillStatistics:
4040
return KillStatistics(
4141
world=self._world,
4242
entries=self._entries,

0 commit comments

Comments
 (0)