Skip to content
Permalink
Browse files

Explicitly return None

  • Loading branch information...
lukasjuhrich committed Mar 1, 2019
1 parent 2e9a33f commit 30efa07f6cd2c9b3f257349c1758ec6aff24f55d
Showing with 6 additions and 1 deletion.
  1. +5 −0 sipa/backends/extension.py
  2. +1 −1 sipa/flatpages.py
@@ -245,6 +245,7 @@ def get_dormitory(self, name: str) -> Optional[Dormitory]:
for dormitory in self.all_dormitories:
if dormitory.name == name:
return dormitory
return None

def get_datasource(self, name: str) -> Optional[DataSource]:
"""Lookup the datasource with name ``name``.
@@ -256,6 +257,7 @@ def get_datasource(self, name: str) -> Optional[DataSource]:
for datasource in self.datasources:
if datasource.name == name:
return datasource
return None

def dormitory_from_ip(self, ip: str) -> Optional[Dormitory]:
"""Return the dormitory whose subnets contain ``ip``
@@ -272,6 +274,7 @@ def dormitory_from_ip(self, ip: str) -> Optional[Dormitory]:
for dormitory in self.dormitories:
if address in dormitory.subnets:
return dormitory
return None

def preferred_dormitory_name(self) -> Optional[str]:
"""Return the name of the preferred dormitory based on the
@@ -282,6 +285,7 @@ def preferred_dormitory_name(self) -> Optional[str]:
dormitory = self.dormitory_from_ip(request.remote_addr)
if dormitory:
return dormitory.name
return None

def user_from_ip(self, ip: str) -> Optional[UserLike]:
"""Return the User that corresponds to ``ip`` according to the
@@ -313,6 +317,7 @@ def current_datasource(self) -> Optional[DataSource]:
dormitory = self.current_dormitory()
if dormitory:
return dormitory.datasource
return None


#: A namedtuple to improve readability of some return values
@@ -121,7 +121,7 @@ def link(self) -> Optional[str]:
if raw_link and raw_link[0] == "/":
return dirname(request.url_root) + raw_link

return
return None

def __getattr__(self, attr: str) -> str:
"""Return the meta attribute of the localized page

0 comments on commit 30efa07

Please sign in to comment.
You can’t perform that action at this time.