Skip to content

Commit 7ba6f43

Browse files
committed
refactor: replace old-style type comments with annotations
1 parent e36fd90 commit 7ba6f43

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

plugins/core/cap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def send_cap_ls(conn):
2020

2121

2222
async def handle_available_caps(conn, caplist, event, irc_paramlist, bot):
23-
available_caps = conn.memory["available_caps"] # type: CapList
23+
available_caps: CapList = conn.memory["available_caps"]
2424
available_caps.extend(caplist)
2525
cap_queue = conn.memory["cap_queue"]
2626
for cap in caplist:

plugins/core/chan_track.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ def get_chans(conn):
282282
# endregion util functions
283283

284284

285-
def update_chan_data(conn, chan):
286-
# type: (IrcClient, str) -> None
285+
def update_chan_data(conn: IrcClient, chan: str) -> None:
287286
"""
288287
Start the process of updating channel data from /NAMES
289288
:param conn: The current connection
@@ -294,8 +293,7 @@ def update_chan_data(conn, chan):
294293
conn.cmd("NAMES", chan)
295294

296295

297-
def update_conn_data(conn):
298-
# type: (IrcClient) -> None
296+
def update_conn_data(conn: IrcClient) -> None:
299297
"""
300298
Update all channel data for this connection
301299
:param conn: The connection to update
@@ -585,7 +583,7 @@ def handle_tags(conn: IrcClient, nick: str, irc_tags: TagList) -> None:
585583
users = get_users(conn)
586584

587585
if irc_tags:
588-
account_tag = irc_tags.get("account") # type: MessageTag
586+
account_tag: MessageTag = irc_tags.get("account")
589587
if account_tag:
590588
user_data = users.getuser(nick)
591589
user_data.account = account_tag.value
@@ -659,8 +657,8 @@ def on_mode(chan, irc_paramlist, conn):
659657
return
660658

661659
serv_info = conn.memory["server_info"]
662-
statuses = serv_info["statuses"] # type: Dict[str, StatusMode]
663-
mode_types = serv_info["channel_modes"] # type: Dict[str, ChannelMode]
660+
statuses: Dict[str, StatusMode] = serv_info["statuses"]
661+
mode_types: Dict[str, ChannelMode] = serv_info["channel_modes"]
664662

665663
chan_data = get_chans(conn).getchan(chan)
666664

plugins/duckhunt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def start_hunt(db, chan, message, conn):
262262

263263

264264
def set_ducktime(chan, conn):
265-
status = get_state_table(conn, chan) # type: ChannelState
265+
status: ChannelState = get_state_table(conn, chan)
266266
status.next_duck_time = random.randint(
267267
int(time()) + 480, int(time()) + 3600
268268
)

plugins/tvdb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ class NoMatchingSeries(LookupError):
4343
class TvdbApi:
4444
def __init__(self) -> None:
4545
self.token_lifetime = token_lifetime
46-
self._headers = None # type: Optional[Dict[str, str]]
46+
self._headers: Optional[Dict[str, str]] = None
4747
self.base_url = "https://api.thetvdb.com"
4848
self.api_version = "3.0.0"
4949
self.default_headers = {
5050
"Accept": f"application/vnd.thetvdb.v{self.api_version}"
5151
}
5252

53-
self.jwt_token = None # type: Optional[str]
53+
self.jwt_token: Optional[str] = None
5454
self.refresh_time = datetime.datetime.min
5555

5656
@property
@@ -209,7 +209,7 @@ class Holder(Generic[T]):
209209
"""
210210

211211
def __init__(self) -> None:
212-
self._item = None # type: Optional[T]
212+
self._item: Optional[T] = None
213213
self._set = False
214214

215215
def set(self, item: T) -> None:
@@ -284,7 +284,7 @@ class LazyCollection(Sized, Iterable[T], Container[T]):
284284
"""
285285

286286
def __init__(self, it: Iterable[T]) -> None:
287-
self._data = [] # type: List[T]
287+
self._data: List[T] = []
288288
self._it = iter(it)
289289
self._complete = False
290290

plugins/weather.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
class PluginData:
19-
maps_api = None # type: Api
19+
maps_api: Api = None
2020
owm_api: Optional[OWM] = None
2121

2222

plugins/youtube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def get_video_id(text: str) -> str:
184184
if not json.get("items"):
185185
raise NoResultsError(request)
186186

187-
video_id = json["items"][0]["id"]["videoId"] # type: str
187+
video_id: str = json["items"][0]["id"]["videoId"]
188188
return video_id
189189

190190

0 commit comments

Comments
 (0)