Pārlūkot izejas kodu

lint docstrings and shorten assertion

Daniel Gruno 5 gadi atpakaļ
vecāks
revīzija
3de5c4b1cc
1 mainītis faili ar 3 papildinājumiem un 4 dzēšanām
  1. 3 4
      pypubsub_ldap.py

+ 3 - 4
pypubsub_ldap.py

@@ -31,17 +31,16 @@ LDAP_SCHEME = {
 
 
 def vet_settings(lconf):
-    """ Simple test to vet LDAP settings if present """
+    """Simple test to vet LDAP settings if present"""
     if lconf:
         for k, v in LDAP_SCHEME.items():
-            if not isinstance(lconf.get(k), v):
-                raise Exception(f"LDAP configuration item {k} must be of type {v.__name__}!")
+            assert isinstance(lconf.get(k), v), f"LDAP configuration item {k} must be of type {v.__name__}!"
         assert ldap.initialize(lconf['uri'])
     print("==== LDAP configuration looks kosher, enabling LDAP authentication as fallback ====")
 
 
 async def get_groups(lconf, user, password):
-    """ Async fetching of groups an LDAP user belongs to """
+    """Async fetching of groups an LDAP user belongs to"""
     bind_dn = lconf['user_dn'] % user
 
     try: