Skip to content

Commit 2bdf7cb

Browse files
authored
Merge pull request #2393 from Exirel/mypy-type-fix-bot-and-ip
bot, ip: fix minor type issues
2 parents bd16d68 + 7f07a95 commit 2bdf7cb

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

sopel/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def on_job_error(
919919
def error(
920920
self,
921921
trigger: Optional[Trigger] = None,
922-
exception: BaseException = None,
922+
exception: Optional[BaseException] = None,
923923
):
924924
"""Called internally when a plugin causes an error.
925925

sopel/modules/ip.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,30 +79,29 @@ def _find_geoip_db(bot):
7979
elif (os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoLite2-City.mmdb')) and
8080
os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoLite2-ASN.mmdb'))):
8181
return '/usr/share/GeoIP'
82-
elif urlretrieve:
83-
LOGGER.info('Downloading GeoIP database')
84-
bot.say('Downloading GeoIP database, please wait...')
85-
86-
common_params = {'license_key': 'JXBEmLjOzislFnh4', 'suffix': 'tar.gz'}
87-
base_url = 'https://download.maxmind.com/app/geoip_download'
88-
geolite_urls = []
89-
90-
for edition in ['ASN', 'City']:
91-
geolite_urls.append(
92-
'{base}?{params}'.format(
93-
base=base_url,
94-
params=web.urlencode(dict(common_params, **{'edition_id': 'GeoLite2-%s' % edition})),
95-
)
82+
83+
LOGGER.info('Downloading GeoIP database')
84+
bot.say('Downloading GeoIP database, please wait...')
85+
86+
common_params = {'license_key': 'JXBEmLjOzislFnh4', 'suffix': 'tar.gz'}
87+
base_url = 'https://download.maxmind.com/app/geoip_download'
88+
geolite_urls = []
89+
90+
for edition in ['ASN', 'City']:
91+
geolite_urls.append(
92+
'{base}?{params}'.format(
93+
base=base_url,
94+
params=web.urlencode(dict(common_params, **{'edition_id': 'GeoLite2-%s' % edition})),
9695
)
96+
)
9797

98-
for url in geolite_urls:
99-
LOGGER.debug('GeoIP Source URL: %s', url)
100-
full_path = os.path.join(config.core.homedir, url.split("/")[-1])
101-
urlretrieve(url, full_path)
102-
_decompress(full_path, config.core.homedir)
103-
return bot.config.core.homedir
104-
else:
105-
return False
98+
for url in geolite_urls:
99+
LOGGER.debug('GeoIP Source URL: %s', url)
100+
full_path = os.path.join(config.core.homedir, url.split("/")[-1])
101+
urlretrieve(url, full_path)
102+
_decompress(full_path, config.core.homedir)
103+
104+
return config.core.homedir
106105

107106

108107
@plugin.command('iplookup', 'ip')

0 commit comments

Comments
 (0)