Skip to content

Commit

Permalink
refactor: replace old-style type comments with annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Apr 18, 2024
1 parent e36fd90 commit 7ba6f43
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion plugins/core/cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def send_cap_ls(conn):


async def handle_available_caps(conn, caplist, event, irc_paramlist, bot):
available_caps = conn.memory["available_caps"] # type: CapList
available_caps: CapList = conn.memory["available_caps"]
available_caps.extend(caplist)
cap_queue = conn.memory["cap_queue"]
for cap in caplist:
Expand Down
12 changes: 5 additions & 7 deletions plugins/core/chan_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ def get_chans(conn):
# endregion util functions


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


def update_conn_data(conn):
# type: (IrcClient) -> None
def update_conn_data(conn: IrcClient) -> None:
"""
Update all channel data for this connection
:param conn: The connection to update
Expand Down Expand Up @@ -585,7 +583,7 @@ def handle_tags(conn: IrcClient, nick: str, irc_tags: TagList) -> None:
users = get_users(conn)

if irc_tags:
account_tag = irc_tags.get("account") # type: MessageTag
account_tag: MessageTag = irc_tags.get("account")
if account_tag:
user_data = users.getuser(nick)
user_data.account = account_tag.value
Expand Down Expand Up @@ -659,8 +657,8 @@ def on_mode(chan, irc_paramlist, conn):
return

serv_info = conn.memory["server_info"]
statuses = serv_info["statuses"] # type: Dict[str, StatusMode]
mode_types = serv_info["channel_modes"] # type: Dict[str, ChannelMode]
statuses: Dict[str, StatusMode] = serv_info["statuses"]
mode_types: Dict[str, ChannelMode] = serv_info["channel_modes"]

chan_data = get_chans(conn).getchan(chan)

Expand Down
2 changes: 1 addition & 1 deletion plugins/duckhunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def start_hunt(db, chan, message, conn):


def set_ducktime(chan, conn):
status = get_state_table(conn, chan) # type: ChannelState
status: ChannelState = get_state_table(conn, chan)
status.next_duck_time = random.randint(
int(time()) + 480, int(time()) + 3600
)
Expand Down
8 changes: 4 additions & 4 deletions plugins/tvdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class NoMatchingSeries(LookupError):
class TvdbApi:
def __init__(self) -> None:
self.token_lifetime = token_lifetime
self._headers = None # type: Optional[Dict[str, str]]
self._headers: Optional[Dict[str, str]] = None
self.base_url = "https://api.thetvdb.com"
self.api_version = "3.0.0"
self.default_headers = {
"Accept": f"application/vnd.thetvdb.v{self.api_version}"
}

self.jwt_token = None # type: Optional[str]
self.jwt_token: Optional[str] = None
self.refresh_time = datetime.datetime.min

@property
Expand Down Expand Up @@ -209,7 +209,7 @@ class Holder(Generic[T]):
"""

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion plugins/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class PluginData:
maps_api = None # type: Api
maps_api: Api = None
owm_api: Optional[OWM] = None


Expand Down
2 changes: 1 addition & 1 deletion plugins/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_video_id(text: str) -> str:
if not json.get("items"):
raise NoResultsError(request)

video_id = json["items"][0]["id"]["videoId"] # type: str
video_id: str = json["items"][0]["id"]["videoId"]
return video_id


Expand Down

0 comments on commit 7ba6f43

Please sign in to comment.