mypy: For EC2, make guess_gateway return None if address is None.

This commit is contained in:
neiljp (Neil Pilgrim) 2017-07-09 12:17:49 -07:00 committed by Tim Abbott
parent 29c5913bb8
commit fd941e8f88
1 changed files with 7 additions and 4 deletions

View File

@ -65,11 +65,14 @@ def address_of(device_id):
return None
def guess_gateway(device_id):
# type: (int) -> str
# type: (int) -> Optional[str]
# This will not work if the default gateway isn't n.n.n.1.
address = address_of(device_id).split('.')
address[3] = '1'
return '.'.join(address)
address = address_of(device_id)
if address is None:
return None
gateway = address.split('.')
gateway[3] = '1'
return '.'.join(gateway)
log = logging.getLogger('configure-cloud-interfaces')
log.setLevel(logging.DEBUG)