zulip-ec2-configure-interfaces: Convert function type annotations.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-22 19:42:19 -07:00
committed by Tim Abbott
parent f8339f019d
commit 5e01a0ae8b
2 changed files with 3 additions and 6 deletions

View File

@@ -53,15 +53,13 @@ import netifaces
from typing import Optional
def address_of(device_id):
# type: (int) -> Optional[str]
def address_of(device_id: int) -> Optional[str]:
try:
return netifaces.ifaddresses("ens%i" % (device_id,))[netifaces.AF_INET][0]['addr']
except KeyError:
return None
def guess_gateway(device_id):
# type: (int) -> Optional[str]
def guess_gateway(device_id: int) -> Optional[str]:
# This will not work if the default gateway isn't n.n.n.1.
address = address_of(device_id)
if address is None: