From 7e6b757e3ad649f66adb890d4f3f762ae6887730 Mon Sep 17 00:00:00 2001 From: Blallo Date: Sun, 30 Jun 2019 21:19:04 +0200 Subject: [PATCH] Style. --- src/phi/async_ldap/model.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/phi/async_ldap/model.py b/src/phi/async_ldap/model.py index 840855e..6257c55 100644 --- a/src/phi/async_ldap/model.py +++ b/src/phi/async_ldap/model.py @@ -1,9 +1,16 @@ +# -*- encoding: utf-8 -*- + import asyncio +import logging +import typing as T + from phi.logging import get_logger log = get_logger(__name__) +alog = logging.getLogger("asyncio") +alog.setLevel(logging.DEBUG) def get_class(obj): @@ -53,8 +60,8 @@ class Entry(object): LDAP Entry. Interface to LDAP. """ - kind = None - _name = None + kind: T.Union[None, str] = None + _name: T.Union[None, str] = None @classmethod def name(cls): @@ -98,7 +105,7 @@ class Entry(object): return res -async def build_heritage(obj, ChildClass, attribute_id="uid"): +async def build_heritage(obj, child_class, attribute_id="uid"): """ Given the object and the child class, yields the instances of the children. @@ -106,7 +113,7 @@ async def build_heritage(obj, ChildClass, attribute_id="uid"): async for child in obj.get_children(): if attribute_id in child: _name = child[attribute_id][0] - yield ChildClass(_name, obj.client) + yield child_class(_name, obj.client) class Hackers(Entry): @@ -175,7 +182,7 @@ class User(Hackers): """ kind = "uid" - _instances = dict() + _instances: T.Dict[str, Entry] = dict() def __new__(cls, name, client, *args, **kwargs): _name = f"{name}-{id(client)}" @@ -210,7 +217,7 @@ class Service(Robots): """ kind = "uid" - _instances = dict() + _instances: T.Dict[str, Entry] = dict() def __new__(cls, name, client, *args, **kwargs): _name = f"{name}-{id(client)}" @@ -244,7 +251,7 @@ class Group(Congregations): """ kind = "cn" - _instances = dict() + _instances: T.Dict[str, Entry] = dict() def __new__(cls, name, client, *args, **kwargs): _name = f"{name}-{id(client)}"