Skip to content

Commit

Permalink
Add stubs for ldap3 (#6561)
Browse files Browse the repository at this point in the history
  • Loading branch information
srittau authored Dec 10, 2021
1 parent 739a052 commit 74ecc29
Show file tree
Hide file tree
Showing 113 changed files with 2,877 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"stubs/humanfriendly",
"stubs/jmespath",
"stubs/jsonschema",
"stubs/ldap3",
"stubs/Markdown",
"stubs/mysqlclient",
"stubs/oauthlib",
Expand Down
1 change: 1 addition & 0 deletions stubs/ldap3/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ldap3.protocol.sasl.kerberos # requires gssapi package to import
2 changes: 2 additions & 0 deletions stubs/ldap3/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "2.9.*"
requires = [] # requires types-pyasn1 (not available yet)
104 changes: 104 additions & 0 deletions stubs/ldap3/ldap3/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from typing import Any, Tuple, Type
from typing_extensions import Literal

from .abstract.attrDef import AttrDef as AttrDef
from .abstract.attribute import (
Attribute as Attribute,
OperationalAttribute as OperationalAttribute,
WritableAttribute as WritableAttribute,
)
from .abstract.cursor import Reader as Reader, Writer as Writer
from .abstract.entry import Entry as Entry, WritableEntry as WritableEntry
from .abstract.objectDef import ObjectDef as ObjectDef
from .core.connection import Connection as Connection
from .core.pooling import ServerPool as ServerPool
from .core.rdns import ReverseDnsSetting as ReverseDnsSetting
from .core.server import Server as Server
from .core.tls import Tls as Tls
from .protocol.rfc4512 import DsaInfo as DsaInfo, SchemaInfo as SchemaInfo
from .utils.config import get_config_parameter as get_config_parameter, set_config_parameter as set_config_parameter
from .version import __description__ as __description__, __status__ as __status__, __url__ as __url__

ANONYMOUS: Literal["ANONYMOUS"]
SIMPLE: Literal["SIMPLE"]
SASL: Literal["SASL"]
NTLM: Literal["NTLM"]

EXTERNAL: Literal["EXTERNAL"]
DIGEST_MD5: Literal["DIGEST-MD5"]
KERBEROS: Literal["GSSAPI"]
GSSAPI: Literal["GSSAPI"]
PLAIN: Literal["PLAIN"]

AUTO_BIND_DEFAULT: Literal["DEFAULT"]
AUTO_BIND_NONE: Literal["NONE"]
AUTO_BIND_NO_TLS: Literal["NO_TLS"]
AUTO_BIND_TLS_BEFORE_BIND: Literal["TLS_BEFORE_BIND"]
AUTO_BIND_TLS_AFTER_BIND: Literal["TLS_AFTER_BIND"]

IP_SYSTEM_DEFAULT: Literal["IP_SYSTEM_DEFAULT"]
IP_V4_ONLY: Literal["IP_V4_ONLY"]
IP_V6_ONLY: Literal["IP_V6_ONLY"]
IP_V4_PREFERRED: Literal["IP_V4_PREFERRED"]
IP_V6_PREFERRED: Literal["IP_V6_PREFERRED"]

BASE: Literal["BASE"]
LEVEL: Literal["LEVEL"]
SUBTREE: Literal["SUBTREE"]

DEREF_NEVER: Literal["NEVER"]
DEREF_SEARCH: Literal["SEARCH"]
DEREF_BASE: Literal["FINDING_BASE"]
DEREF_ALWAYS: Literal["ALWAYS"]

ALL_ATTRIBUTES: Literal["*"]
NO_ATTRIBUTES: Literal["1.1"]
ALL_OPERATIONAL_ATTRIBUTES: Literal["+"]

MODIFY_ADD: Literal["MODIFY_ADD"]
MODIFY_DELETE: Literal["MODIFY_DELETE"]
MODIFY_REPLACE: Literal["MODIFY_REPLACE"]
MODIFY_INCREMENT: Literal["MODIFY_INCREMENT"]

SYNC: Literal["SYNC"]
SAFE_SYNC: Literal["SAFE_SYNC"]
SAFE_RESTARTABLE: Literal["SAFE_RESTARTABLE"]
ASYNC: Literal["ASYNC"]
LDIF: Literal["LDIF"]
RESTARTABLE: Literal["RESTARTABLE"]
REUSABLE: Literal["REUSABLE"]
MOCK_SYNC: Literal["MOCK_SYNC"]
MOCK_ASYNC: Literal["MOCK_ASYNC"]
ASYNC_STREAM: Literal["ASYNC_STREAM"]

NONE: Literal["NO_INFO"]
DSA: Literal["DSA"]
SCHEMA: Literal["SCHEMA"]
ALL: Literal["ALL"]

OFFLINE_EDIR_8_8_8: Literal["EDIR_8_8_8"]
OFFLINE_EDIR_9_1_4: Literal["EDIR_9_1_4"]
OFFLINE_AD_2012_R2: Literal["AD_2012_R2"]
OFFLINE_SLAPD_2_4: Literal["SLAPD_2_4"]
OFFLINE_DS389_1_3_3: Literal["DS389_1_3_3"]

FIRST: Literal["FIRST"]
ROUND_ROBIN: Literal["ROUND_ROBIN"]
RANDOM: Literal["RANDOM"]

HASHED_NONE: Literal["PLAIN"]
HASHED_SHA: Literal["SHA"]
HASHED_SHA256: Literal["SHA256"]
HASHED_SHA384: Literal["SHA384"]
HASHED_SHA512: Literal["SHA512"]
HASHED_MD5: Literal["MD5"]
HASHED_SALTED_SHA: Literal["SALTED_SHA"]
HASHED_SALTED_SHA256: Literal["SALTED_SHA256"]
HASHED_SALTED_SHA384: Literal["SALTED_SHA384"]
HASHED_SALTED_SHA512: Literal["SALTED_SHA512"]
HASHED_SALTED_MD5: Literal["SALTED_MD5"]

NUMERIC_TYPES: Tuple[Type[Any], ...]
INTEGER_TYPES: Tuple[Type[Any], ...]
STRING_TYPES: Tuple[Type[Any], ...]
SEQUENCE_TYPES: Tuple[Type[Any], ...]
15 changes: 15 additions & 0 deletions stubs/ldap3/ldap3/abstract/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import Any

STATUS_INIT: str
STATUS_VIRTUAL: str
STATUS_MANDATORY_MISSING: str
STATUS_READ: str
STATUS_WRITABLE: str
STATUS_PENDING_CHANGES: str
STATUS_COMMITTED: str
STATUS_READY_FOR_DELETION: str
STATUS_READY_FOR_MOVING: str
STATUS_READY_FOR_RENAMING: str
STATUS_DELETED: str
STATUSES: Any
INITIAL_STATUSES: Any
33 changes: 33 additions & 0 deletions stubs/ldap3/ldap3/abstract/attrDef.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import Any

class AttrDef:
name: Any
key: Any
validate: Any
pre_query: Any
post_query: Any
default: Any
dereference_dn: Any
description: Any
mandatory: Any
single_value: Any
oid_info: Any
other_names: Any
def __init__(
self,
name,
key: Any | None = ...,
validate: Any | None = ...,
pre_query: Any | None = ...,
post_query: Any | None = ...,
default=...,
dereference_dn: Any | None = ...,
description: Any | None = ...,
mandatory: bool = ...,
single_value: Any | None = ...,
alias: Any | None = ...,
) -> None: ...
def __eq__(self, other): ...
def __lt__(self, other): ...
def __hash__(self): ...
def __setattr__(self, key, value) -> None: ...
34 changes: 34 additions & 0 deletions stubs/ldap3/ldap3/abstract/attribute.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import Any

class Attribute:
key: Any
definition: Any
values: Any
raw_values: Any
response: Any
entry: Any
cursor: Any
other_names: Any
def __init__(self, attr_def, entry, cursor) -> None: ...
def __len__(self): ...
def __iter__(self): ...
def __getitem__(self, item): ...
def __eq__(self, other): ...
def __ne__(self, other): ...
@property
def value(self): ...

class OperationalAttribute(Attribute): ...

class WritableAttribute(Attribute):
def __iadd__(self, other): ...
def __isub__(self, other): ...
def add(self, values) -> None: ...
def set(self, values) -> None: ...
def delete(self, values) -> None: ...
def remove(self) -> None: ...
def discard(self) -> None: ...
@property
def virtual(self): ...
@property
def changes(self): ...
102 changes: 102 additions & 0 deletions stubs/ldap3/ldap3/abstract/cursor.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from typing import Any, NamedTuple

class Operation(NamedTuple):
request: Any
result: Any
response: Any

class Cursor:
connection: Any
get_operational_attributes: Any
definition: Any
attributes: Any
controls: Any
execution_time: Any
entries: Any
schema: Any
def __init__(
self,
connection,
object_def,
get_operational_attributes: bool = ...,
attributes: Any | None = ...,
controls: Any | None = ...,
auxiliary_class: Any | None = ...,
) -> None: ...
def __iter__(self): ...
def __getitem__(self, item): ...
def __len__(self): ...
def __bool__(self): ...
def match_dn(self, dn): ...
def match(self, attributes, value): ...
def remove(self, entry) -> None: ...
@property
def operations(self): ...
@property
def errors(self): ...
@property
def failed(self): ...

class Reader(Cursor):
entry_class: Any
attribute_class: Any
entry_initial_status: Any
sub_tree: Any
base: Any
dereference_aliases: Any
validated_query: Any
query_filter: Any
def __init__(
self,
connection,
object_def,
base,
query: str = ...,
components_in_and: bool = ...,
sub_tree: bool = ...,
get_operational_attributes: bool = ...,
attributes: Any | None = ...,
controls: Any | None = ...,
auxiliary_class: Any | None = ...,
) -> None: ...
@property
def query(self): ...
@query.setter
def query(self, value) -> None: ...
@property
def components_in_and(self): ...
@components_in_and.setter
def components_in_and(self, value) -> None: ...
def clear(self) -> None: ...
execution_time: Any
entries: Any
def reset(self) -> None: ...
def search(self, attributes: Any | None = ...): ...
def search_object(self, entry_dn: Any | None = ..., attributes: Any | None = ...): ...
def search_level(self, attributes: Any | None = ...): ...
def search_subtree(self, attributes: Any | None = ...): ...
def search_paged(self, paged_size, paged_criticality: bool = ..., generator: bool = ..., attributes: Any | None = ...): ...

class Writer(Cursor):
entry_class: Any
attribute_class: Any
entry_initial_status: Any
@staticmethod
def from_cursor(cursor, connection: Any | None = ..., object_def: Any | None = ..., custom_validator: Any | None = ...): ...
@staticmethod
def from_response(connection, object_def, response: Any | None = ...): ...
dereference_aliases: Any
def __init__(
self,
connection,
object_def,
get_operational_attributes: bool = ...,
attributes: Any | None = ...,
controls: Any | None = ...,
auxiliary_class: Any | None = ...,
) -> None: ...
execution_time: Any
def commit(self, refresh: bool = ...): ...
def discard(self) -> None: ...
def new(self, dn): ...
def refresh_entry(self, entry, tries: int = ..., seconds: int = ...): ...
83 changes: 83 additions & 0 deletions stubs/ldap3/ldap3/abstract/entry.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from typing import Any

class EntryState:
dn: Any
status: Any
attributes: Any
raw_attributes: Any
response: Any
cursor: Any
origin: Any
read_time: Any
changes: Any
definition: Any
def __init__(self, dn, cursor) -> None: ...
def set_status(self, status) -> None: ...
@property
def entry_raw_attributes(self): ...

class EntryBase:
def __init__(self, dn, cursor) -> None: ...
def __iter__(self): ...
def __contains__(self, item): ...
def __getattr__(self, item): ...
def __setattr__(self, item, value) -> None: ...
def __getitem__(self, item): ...
def __eq__(self, other): ...
def __lt__(self, other): ...
@property
def entry_dn(self): ...
@property
def entry_cursor(self): ...
@property
def entry_status(self): ...
@property
def entry_definition(self): ...
@property
def entry_raw_attributes(self): ...
def entry_raw_attribute(self, name): ...
@property
def entry_mandatory_attributes(self): ...
@property
def entry_attributes(self): ...
@property
def entry_attributes_as_dict(self): ...
@property
def entry_read_time(self): ...
def entry_to_json(
self,
raw: bool = ...,
indent: int = ...,
sort: bool = ...,
stream: Any | None = ...,
checked_attributes: bool = ...,
include_empty: bool = ...,
): ...
def entry_to_ldif(
self, all_base64: bool = ..., line_separator: Any | None = ..., sort_order: Any | None = ..., stream: Any | None = ...
): ...

class Entry(EntryBase):
def entry_writable(
self,
object_def: Any | None = ...,
writer_cursor: Any | None = ...,
attributes: Any | None = ...,
custom_validator: Any | None = ...,
auxiliary_class: Any | None = ...,
): ...

class WritableEntry(EntryBase):
def __setitem__(self, key, value) -> None: ...
def __setattr__(self, item, value) -> None: ...
def __getattr__(self, item): ...
@property
def entry_virtual_attributes(self): ...
def entry_commit_changes(self, refresh: bool = ..., controls: Any | None = ..., clear_history: bool = ...): ...
def entry_discard_changes(self) -> None: ...
def entry_delete(self) -> None: ...
def entry_refresh(self, tries: int = ..., seconds: int = ...): ...
def entry_move(self, destination_dn) -> None: ...
def entry_rename(self, new_name) -> None: ...
@property
def entry_changes(self): ...
Loading

0 comments on commit 74ecc29

Please sign in to comment.