aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-30 17:49:35 +0000
committerGravatar jesopo2018-10-30 17:49:35 +0000
commitb543e31cd2a665b25aab4554e46a0ed5067d1bfe (patch)
tree285e0b52f45e167dbc381951482c7bff660c6630 /src/utils
parentTypo in src/Exports; 'self_exports' -> 'self.exports' (diff)
signature
Fix/refactor issues brought up by type hint linting
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/__init__.py6
-rw-r--r--src/utils/http.py4
-rw-r--r--src/utils/irc.py12
3 files changed, 11 insertions, 11 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
index 52de64ba..f60c199e 100644
--- a/src/utils/__init__.py
+++ b/src/utils/__init__.py
@@ -93,9 +93,9 @@ def parse_number(s: str) -> str:
pass
unit = s[-1].lower()
- number = s[:-1]
+ number_str = s[:-1]
try:
- number = decimal.Decimal(number)
+ number = decimal.Decimal(number_str)
except:
raise ValueError("Invalid format '%s' passed to parse_number" % number)
@@ -155,7 +155,7 @@ def export(setting: str, value: typing.Any):
return _export_func
TOP_10_CALLABLE = typing.Callable[[typing.Any], typing.Any]
-def top_10(items: typing.List[typing.Any],
+def top_10(items: typing.Dict[typing.Any, typing.Any],
convert_key: TOP_10_CALLABLE=lambda x: x,
value_format: TOP_10_CALLABLE=lambda x: x):
top_10 = sorted(items.keys())
diff --git a/src/utils/http.py b/src/utils/http.py
index b949e9ff..8856cd43 100644
--- a/src/utils/http.py
+++ b/src/utils/http.py
@@ -8,7 +8,7 @@ REGEX_HTTP = re.compile("https?://", re.I)
RESPONSE_MAX = (1024*1024)*100
-class HTTPException:
+class HTTPException(Exception):
pass
class HTTPTimeoutException(HTTPException):
pass
@@ -52,7 +52,7 @@ def get_url(url: str, method: str="GET", get_params: dict={},
if soup:
soup = bs4.BeautifulSoup(response_content, parser)
if code:
- return response.code, soup
+ return response.status_code, soup
return soup
data = response_content.decode(response.encoding or fallback_encoding)
diff --git a/src/utils/irc.py b/src/utils/irc.py
index 3e7f8b76..b7819e7c 100644
--- a/src/utils/irc.py
+++ b/src/utils/irc.py
@@ -53,7 +53,7 @@ def seperate_hostmask(hostmask: str) -> IRCHostmask:
return IRCHostmask(nickname, username, hostname, hostmask)
class IRCLine(object):
- def __init__(self, tags: dict, prefix: str, command: str,
+ def __init__(self, tags: dict, prefix: typing.Optional[str], command: str,
args: typing.List[str], arbitrary: typing.Optional[str],
last: str):
self.tags = tags
@@ -65,7 +65,7 @@ class IRCLine(object):
def parse_line(line: str) -> IRCLine:
tags = {}
- prefix = None
+ prefix = typing.Optional[IRCHostmask]
command = None
if line[0] == "@":
@@ -74,12 +74,12 @@ def parse_line(line: str) -> IRCLine:
tag, _, value = tag.partition("=")
tags[tag] = value
- line, _, arbitrary = line.partition(" :")
- arbitrary = arbitrary or None
+ line, _, arbitrary_split = line.partition(" :")
+ arbitrary = arbitrary_split or None
if line[0] == ":":
- prefix, line = line[1:].split(" ", 1)
- prefix = seperate_hostmask(prefix)
+ prefix_str, line = line[1:].split(" ", 1)
+ prefix = seperate_hostmask(prefix_str)
command, _, line = line.partition(" ")
args = line.split(" ")