Apply suggestions from code review

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
This commit is contained in:
Erik Sundell
2021-08-26 03:32:55 +02:00
parent d6c48b15fe
commit bc71ad6d73
4 changed files with 6 additions and 6 deletions

View File

@@ -210,7 +210,7 @@ class UserListAPIHandler(APIHandler):
except Exception as e: except Exception as e:
self.log.error("Failed to create user: %s" % name, exc_info=True) self.log.error("Failed to create user: %s" % name, exc_info=True)
self.users.delete(user) self.users.delete(user)
raise web.HTTPError(400, f"Failed to create user {name}: {str(e)}") raise web.HTTPError(400, f"Failed to create user {name}: {e}")
else: else:
created.append(user) created.append(user)

View File

@@ -623,7 +623,7 @@ class BaseHandler(RequestHandler):
if (next_url + '/').startswith( if (next_url + '/').startswith(
( (
f'{self.request.protocol}://{self.request.host}/', f'{self.request.protocol}://{self.request.host}/',
'//%s/' % self.request.host, f'//{self.request.host}/',
) )
) or ( ) or (
self.subdomain_host self.subdomain_host

View File

@@ -148,7 +148,9 @@ class Server(HasTraits):
def host(self): def host(self):
if self.connect_url: if self.connect_url:
parsed = urlparse(self.connect_url) parsed = urlparse(self.connect_url)
return f"{parsed.scheme}://{parsed.netloc}" proto = parsed.scheme
host = parsed.netloc
return f"{proto}://{host}"
if ':' in self._connect_ip: if ':' in self._connect_ip:
fmt = "{proto}://[{ip}]:{port}" fmt = "{proto}://[{ip}]:{port}"

View File

@@ -1039,8 +1039,6 @@ def get_class(resource_name):
} }
if resource_name not in class_dict: if resource_name not in class_dict:
raise ValueError( raise ValueError(
"Kind must be one of {}, not {}".format( f'Kind must be one of {", ".join(class_dict)}, not {resource_name}'
", ".join(class_dict), resource_name
)
) )
return class_dict[resource_name] return class_dict[resource_name]