A couple of tweaks to clarify some type hints

This commit is contained in:
jesopo 2018-12-02 09:56:57 +00:00
parent c4ea6fa562
commit 08bd31f150
3 changed files with 7 additions and 5 deletions

View file

@ -3,6 +3,7 @@ from src import EventManager, IRCBot, IRCBuffer, IRCObject, IRCServer, IRCUser
from src import utils
class Channel(IRCObject.Object):
name = ""
def __init__(self, name: str, id, server: "IRCServer.Server",
bot: "IRCBot.Bot"):
self.name = utils.irc.lower(server.case_mapping, name)

View file

@ -173,7 +173,10 @@ class Server(IRCObject.Object):
self.nickname = nickname
self.nickname_lower = utils.irc.lower(self.case_mapping, nickname)
def is_own_nickname(self, nickname: str) -> bool:
return utils.irc.equals(self.case_mapping, nickname, self.nickname)
if self.nickname == None:
return False
return utils.irc.equals(self.case_mapping, nickname,
typing.cast(str, self.nickname))
def add_own_mode(self, mode: str, arg: str=None):
self.own_modes[mode] = arg

View file

@ -80,7 +80,7 @@ def message_tag_unescape(s):
return _multi_replace(s, MESSAGE_TAG_ESCAPED, MESSAGE_TAG_UNESCAPED)
def parse_line(line: str) -> IRCLine:
tags = {}
tags = {} # type: typing.Dict[str, typing.Any]
prefix = None # type: typing.Optional[IRCHostmask]
command = None
@ -108,10 +108,8 @@ def parse_line(line: str) -> IRCLine:
prefix_str, line = line[1:].split(" ", 1)
prefix = seperate_hostmask(prefix_str)
args = []
command, sep, line = line.partition(" ")
if sep:
args = line.split(" ")
args = line.split(" ")
if arbitrary:
args.append(arbitrary)