From bc62943fb140a6f2c2ca8afde5101092e650e769 Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Mon, 27 Jul 2026 23:35:39 -0300 Subject: [PATCH 1/2] python-ldap: Add package stubs --- pyproject.toml | 1 + pyrightconfig.json | 1 + pyrightconfig.stricter.json | 1 + python-ldap | 1 + stubs/python-ldap/METADATA.toml | 11 + stubs/python-ldap/ldap/__init__.pyi | 37 ++++ stubs/python-ldap/ldap/async.pyi | 2 + stubs/python-ldap/ldap/asyncsearch.pyi | 60 ++++++ stubs/python-ldap/ldap/cidict.pyi | 24 +++ stubs/python-ldap/ldap/compat.pyi | 9 + stubs/python-ldap/ldap/constants.pyi | 29 +++ stubs/python-ldap/ldap/controls/__init__.pyi | 47 +++++ stubs/python-ldap/ldap/controls/deref.pyi | 12 ++ stubs/python-ldap/ldap/controls/libldap.pyi | 28 +++ stubs/python-ldap/ldap/controls/openldap.pyi | 20 ++ .../ldap/controls/pagedresults.pyi | 10 + stubs/python-ldap/ldap/controls/ppolicy.pyi | 20 ++ stubs/python-ldap/ldap/controls/psearch.pyi | 10 + stubs/python-ldap/ldap/controls/pwdpolicy.pyi | 15 ++ stubs/python-ldap/ldap/controls/readentry.pyi | 16 ++ .../ldap/controls/sessiontrack.pyi | 19 ++ stubs/python-ldap/ldap/controls/simple.pyi | 57 ++++++ stubs/python-ldap/ldap/controls/sss.pyi | 31 +++ stubs/python-ldap/ldap/controls/vlv.pyi | 55 +++++ stubs/python-ldap/ldap/dn.pyi | 8 + stubs/python-ldap/ldap/extop/__init__.pyi | 16 ++ stubs/python-ldap/ldap/extop/dds.pyi | 25 +++ stubs/python-ldap/ldap/extop/passwd.pyi | 13 ++ stubs/python-ldap/ldap/filter.pyi | 9 + stubs/python-ldap/ldap/functions.pyi | 35 ++++ stubs/python-ldap/ldap/ldapobject.pyi | 188 ++++++++++++++++++ stubs/python-ldap/ldap/logger.pyi | 12 ++ stubs/python-ldap/ldap/modlist.pyi | 4 + stubs/python-ldap/ldap/pkginfo.pyi | 1 + stubs/python-ldap/ldap/resiter.pyi | 9 + stubs/python-ldap/ldap/sasl.pyi | 31 +++ stubs/python-ldap/ldap/schema/__init__.pyi | 9 + stubs/python-ldap/ldap/schema/models.pyi | 74 +++++++ stubs/python-ldap/ldap/schema/subentry.pyi | 45 +++++ stubs/python-ldap/ldap/schema/tokenizer.pyi | 7 + stubs/python-ldap/ldap/syncrepl.pyi | 86 ++++++++ stubs/python-ldap/ldif.pyi | 65 ++++++ 42 files changed, 1153 insertions(+) create mode 160000 python-ldap create mode 100644 stubs/python-ldap/METADATA.toml create mode 100644 stubs/python-ldap/ldap/__init__.pyi create mode 100644 stubs/python-ldap/ldap/async.pyi create mode 100644 stubs/python-ldap/ldap/asyncsearch.pyi create mode 100644 stubs/python-ldap/ldap/cidict.pyi create mode 100644 stubs/python-ldap/ldap/compat.pyi create mode 100644 stubs/python-ldap/ldap/constants.pyi create mode 100644 stubs/python-ldap/ldap/controls/__init__.pyi create mode 100644 stubs/python-ldap/ldap/controls/deref.pyi create mode 100644 stubs/python-ldap/ldap/controls/libldap.pyi create mode 100644 stubs/python-ldap/ldap/controls/openldap.pyi create mode 100644 stubs/python-ldap/ldap/controls/pagedresults.pyi create mode 100644 stubs/python-ldap/ldap/controls/ppolicy.pyi create mode 100644 stubs/python-ldap/ldap/controls/psearch.pyi create mode 100644 stubs/python-ldap/ldap/controls/pwdpolicy.pyi create mode 100644 stubs/python-ldap/ldap/controls/readentry.pyi create mode 100644 stubs/python-ldap/ldap/controls/sessiontrack.pyi create mode 100644 stubs/python-ldap/ldap/controls/simple.pyi create mode 100644 stubs/python-ldap/ldap/controls/sss.pyi create mode 100644 stubs/python-ldap/ldap/controls/vlv.pyi create mode 100644 stubs/python-ldap/ldap/dn.pyi create mode 100644 stubs/python-ldap/ldap/extop/__init__.pyi create mode 100644 stubs/python-ldap/ldap/extop/dds.pyi create mode 100644 stubs/python-ldap/ldap/extop/passwd.pyi create mode 100644 stubs/python-ldap/ldap/filter.pyi create mode 100644 stubs/python-ldap/ldap/functions.pyi create mode 100644 stubs/python-ldap/ldap/ldapobject.pyi create mode 100644 stubs/python-ldap/ldap/logger.pyi create mode 100644 stubs/python-ldap/ldap/modlist.pyi create mode 100644 stubs/python-ldap/ldap/pkginfo.pyi create mode 100644 stubs/python-ldap/ldap/resiter.pyi create mode 100644 stubs/python-ldap/ldap/sasl.pyi create mode 100644 stubs/python-ldap/ldap/schema/__init__.pyi create mode 100644 stubs/python-ldap/ldap/schema/models.pyi create mode 100644 stubs/python-ldap/ldap/schema/subentry.pyi create mode 100644 stubs/python-ldap/ldap/schema/tokenizer.pyi create mode 100644 stubs/python-ldap/ldap/syncrepl.pyi create mode 100644 stubs/python-ldap/ldif.pyi diff --git a/pyproject.toml b/pyproject.toml index b4a430f7510c..040ca94b1488 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ exclude = [ ".git", ".mypy_cache", ".pytype", + "python-ldap", ] [tool.ruff.lint] diff --git a/pyrightconfig.json b/pyrightconfig.json index 5e63976c9eab..af4f0d71ef12 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -12,6 +12,7 @@ "stubs/geopandas", // test cases use a custom config file "**/@tests/test_cases", + "python-ldap" ], "typeCheckingMode": "strict", // Allowed in base settings for incomplete stubs, checked in stricter settings diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index b24a9abf2af3..d0ff9865c764 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -86,6 +86,7 @@ "stubs/python-dateutil", "stubs/python-http-client", "stubs/python-jose", + "stubs/python-ldap", "stubs/pywin32", "stubs/pyxdg", "stubs/PyYAML", diff --git a/python-ldap b/python-ldap new file mode 160000 index 000000000000..cbcbb6275ca8 --- /dev/null +++ b/python-ldap @@ -0,0 +1 @@ +Subproject commit cbcbb6275ca8f4dc36eb2f131f37e2f03814a400 diff --git a/stubs/python-ldap/METADATA.toml b/stubs/python-ldap/METADATA.toml new file mode 100644 index 000000000000..5cba0eebe802 --- /dev/null +++ b/stubs/python-ldap/METADATA.toml @@ -0,0 +1,11 @@ +version = "3.4.*" +requires = ["types-pyasn1"] +upstream_repository = "https://github.com/python-ldap/python-ldap" +extra_description = """ +Type stubs for python-ldap, covering the public API as documented at +https://www.python-ldap.org/doc/html/api.html. +""" +partial_stub = true + +[tool.stubtest] +stubtest_requirements = ["python-ldap"] diff --git a/stubs/python-ldap/ldap/__init__.pyi b/stubs/python-ldap/ldap/__init__.pyi new file mode 100644 index 000000000000..d448e68fa9d2 --- /dev/null +++ b/stubs/python-ldap/ldap/__init__.pyi @@ -0,0 +1,37 @@ +from typing import Any + +__version__: str +__author__: str +__license__: str + +LIBLDAP_API_INFO: Any +OPT_NAMES_DICT: dict[Any, Any] +OPT_ERROR_STRING: int +OPT_DIAGNOSTIC_MESSAGE: int + +class LDAPLock: + def __init__(self, lock_class: Any = ..., desc: str = ...) -> None: ... + def acquire(self) -> None: ... + def release(self) -> None: ... + +_ldap_module_lock: LDAPLock + +def initialize( + uri: str, + trace_level: int = ..., + trace_file: Any = ..., + trace_stack_limit: Any = ..., + bytes_mode: Any = ..., + fileno: Any = ..., + **kwargs: Any, +) -> Any: ... +def get_option(option: Any) -> Any: ... +def set_option(option: Any, invalue: Any) -> None: ... +def escape_str(escape_func: Any, s: Any, *args: Any) -> Any: ... +def strf_secs(secs: Any) -> Any: ... +def strp_secs(dt_str: Any) -> Any: ... + +class NO_UNIQUE_ENTRY(Exception): ... +class LDAPBytesWarning(Warning): ... + +from ldap.dn import explode_dn as explode_dn, explode_rdn as explode_rdn diff --git a/stubs/python-ldap/ldap/async.pyi b/stubs/python-ldap/ldap/async.pyi new file mode 100644 index 000000000000..e45458baec62 --- /dev/null +++ b/stubs/python-ldap/ldap/async.pyi @@ -0,0 +1,2 @@ +from ldap.asyncsearch import * +from ldap.asyncsearch import __version__ as __version__ diff --git a/stubs/python-ldap/ldap/asyncsearch.pyi b/stubs/python-ldap/ldap/asyncsearch.pyi new file mode 100644 index 000000000000..36469f4ddb37 --- /dev/null +++ b/stubs/python-ldap/ldap/asyncsearch.pyi @@ -0,0 +1,60 @@ +from typing import Any +from ldap import __version__ as __version__ + +SEARCH_RESULT_TYPES: set[int] +ENTRY_RESULT_TYPES: set[int] + +class WrongResultType(Exception): + + receivedResultType: Any + expectedResultTypes: Any + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class AsyncSearchHandler: + + beginResultsDropped: int + endResultBreak: int + def __init__(self, l: Any) -> None: ... + def startSearch( + self, + searchRoot: Any, + searchScope: Any, + filterStr: Any, + attrList: Any = ..., + attrsOnly: int = 0, + timeout: int = -1, + sizelimit: int = 0, + serverctrls: Any = ..., + clientctrls: Any = ..., + ) -> None: ... + def preProcessing(self) -> None: ... + def afterFirstResult(self) -> None: ... + def postProcessing(self) -> None: ... + def processResults(self, ignoreResultsNumber: int = 0, processResultsCount: int = 0, timeout: int = -1) -> bool: ... + +class List(AsyncSearchHandler): + + allResults: list[Any] + def __init__(self, l: Any) -> None: ... + +class Dict(AsyncSearchHandler): + + allEntries: dict[Any, Any] + def __init__(self, l: Any) -> None: ... + +class IndexedDict(Dict): + + indexed_attrs: Any + index: Any + def __init__(self, l: Any, indexed_attrs: Any = ...) -> None: ... + +class FileWriter(AsyncSearchHandler): + + headerStr: str + footerStr: str + def __init__(self, l: Any, f: Any, headerStr: str = "", footerStr: str = "") -> None: ... + def preProcessing(self) -> None: ... + def postProcessing(self) -> None: ... + +class LDIFWriter(FileWriter): + def __init__(self, l: Any, writer_obj: Any, headerStr: str = "", footerStr: str = "") -> None: ... diff --git a/stubs/python-ldap/ldap/cidict.pyi b/stubs/python-ldap/ldap/cidict.pyi new file mode 100644 index 000000000000..49063fb0fdfa --- /dev/null +++ b/stubs/python-ldap/ldap/cidict.pyi @@ -0,0 +1,24 @@ +from typing import Any + +class cidict(dict[Any, Any]): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __getitem__(self, key: Any) -> Any: ... + def __setitem__(self, key: Any, value: Any) -> None: ... + def __delitem__(self, key: Any) -> None: ... + def __contains__(self, key: Any) -> bool: ... + def get(self, key: Any, default: Any = ...) -> Any: ... + def setdefault(self, key: Any, default: Any = ...) -> Any: ... + def update(self, *args: Any, **kwargs: Any) -> None: ... + def pop(self, key: Any, default: Any = ...) -> Any: ... + def popitem(self) -> tuple[Any, Any]: ... + def clear(self) -> None: ... + def copy(self) -> cidict: ... + def keys(self) -> Any: ... + def items(self) -> Any: ... + def values(self) -> Any: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + +def strlist_minus(a: Any, b: Any) -> Any: ... +def strlist_intersection(a: Any, b: Any) -> Any: ... +def strlist_union(a: Any, b: Any) -> Any: ... diff --git a/stubs/python-ldap/ldap/compat.pyi b/stubs/python-ldap/ldap/compat.pyi new file mode 100644 index 000000000000..f7407f663389 --- /dev/null +++ b/stubs/python-ldap/ldap/compat.pyi @@ -0,0 +1,9 @@ +from collections import UserDict +from collections.abc import MutableMapping as MutableMapping +from shutil import which as which +from urllib.parse import quote as quote, quote_plus as quote_plus, unquote as unquote, urlparse as urlparse +from urllib.request import urlopen as urlopen + +IterableUserDict = UserDict + +def reraise(exc_type, exc_value, exc_traceback) -> None: ... diff --git a/stubs/python-ldap/ldap/constants.pyi b/stubs/python-ldap/ldap/constants.pyi new file mode 100644 index 000000000000..d202cb6614f1 --- /dev/null +++ b/stubs/python-ldap/ldap/constants.pyi @@ -0,0 +1,29 @@ +from typing import Any + +class Constant: + name: Any + requirements: Any + doc: Any + def __init__(self, name: str, optional: bool = False, requirements: Any = ..., doc: Any = ...) -> None: ... + +class Error(Constant): + c_template: str + +class Int(Constant): + c_template: str + +class TLSInt(Int): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class Feature(Constant): + c_template: Any + c_feature: Any + def __init__(self, name: str, c_feature: Any, **kwargs: Any) -> None: ... + +class Str(Constant): + c_template: str + +API_2004: str +CONSTANTS: Any + +def print_header() -> None: ... diff --git a/stubs/python-ldap/ldap/controls/__init__.pyi b/stubs/python-ldap/ldap/controls/__init__.pyi new file mode 100644 index 000000000000..fd3df3ba2861 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/__init__.pyi @@ -0,0 +1,47 @@ +from typing import Any +from ldap.controls.simple import BooleanControl, ManageDSAITControl, RelaxRulesControl, ValueLessRequestControl +from ldap.controls.libldap import AssertionControl, MatchedValuesControl, SimplePagedResultsControl + +__all__ = [ + "KNOWN_RESPONSE_CONTROLS", + "AssertionControl", + "BooleanControl", + "LDAPControl", + "ManageDSAITControl", + "MatchedValuesControl", + "RelaxRulesControl", + "RequestControl", + "ResponseControl", + "SimplePagedResultsControl", + "ValueLessRequestControl", + "RequestControlTuples", + "DecodeControlTuples", +] + +KNOWN_RESPONSE_CONTROLS: Any + +class RequestControl: + controlType: Any + criticality: Any + encodedControlValue: Any + def __init__(self, controlType: Any = ..., criticality: bool = False, encodedControlValue: Any = ...) -> None: ... + def encodeControlValue(self) -> Any: ... + +class ResponseControl: + controlType: Any + criticality: Any + encodedControlValue: Any + def __init__(self, controlType: Any = ..., criticality: bool = False) -> None: ... + def decodeControlValue(self, encodedControlValue: Any) -> Any: ... + +class LDAPControl(RequestControl, ResponseControl): + controlType: Any + criticality: Any + controlValue: Any + encodedControlValue: Any + def __init__( + self, controlType: Any = ..., criticality: bool = False, controlValue: Any = ..., encodedControlValue: Any = ... + ) -> None: ... + +def RequestControlTuples(ldapControls: Any) -> Any: ... +def DecodeControlTuples(ldapControlTuples: Any, knownLDAPControls: Any = ...) -> Any: ... diff --git a/stubs/python-ldap/ldap/controls/deref.pyi b/stubs/python-ldap/ldap/controls/deref.pyi new file mode 100644 index 000000000000..54eccd06ff50 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/deref.pyi @@ -0,0 +1,12 @@ +from typing import Any +from ldap.controls import LDAPControl + +DEREF_CONTROL_OID: str + +class DereferenceControl(LDAPControl): + controlType: Any + derefSpecs: Any + def __init__(self, criticality: bool = False, derefSpecs: Any = ...) -> None: ... + def encodeControlValue(self): ... + derefRes: Any + def decodeControlValue(self, encodedControlValue) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/libldap.pyi b/stubs/python-ldap/ldap/controls/libldap.pyi new file mode 100644 index 000000000000..62194f4c8bb1 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/libldap.pyi @@ -0,0 +1,28 @@ +from typing import Any +from ldap.controls import ( + KNOWN_RESPONSE_CONTROLS as KNOWN_RESPONSE_CONTROLS, + LDAPControl as LDAPControl, + RequestControl as RequestControl, + ResponseControl as ResponseControl, +) +from ldap.pkginfo import __version__ as __version__ + +class AssertionControl(RequestControl): + controlType: Any + assertion: Any + def __init__(self, assertion: Any, criticality: bool = False) -> None: ... + def encodeControlValue(self): ... + +class MatchedValuesControl(ResponseControl): + controlType: Any + matchedValues: Any + def __init__(self, matchedValues: Any, criticality: bool = False) -> None: ... + def decodeControlValue(self, encodedControlValue) -> None: ... + +class SimplePagedResultsControl(RequestControl): + controlType: Any + size: int + cookie: Any + def __init__(self, size: int = 0, cookie: Any = ...) -> None: ... + def encodeControlValue(self): ... + def decodeControlValue(self, encodedControlValue) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/openldap.pyi b/stubs/python-ldap/ldap/controls/openldap.pyi new file mode 100644 index 000000000000..89727964c99a --- /dev/null +++ b/stubs/python-ldap/ldap/controls/openldap.pyi @@ -0,0 +1,20 @@ +from typing import Any + +from ldap.controls import ResponseControl, ValueLessRequestControl +from pyasn1.type import univ + +__all__ = ["SearchNoOpControl", "SearchNoOpMixIn"] + +class SearchNoOpControl(ValueLessRequestControl, ResponseControl): + controlType: str + criticality: Any # TODO: Precise type + def __init__(self, criticality: bool = False) -> None: ... + + class SearchNoOpControlValue(univ.Sequence): ... + resultCode: Any # TODO: Precise type + numSearchResults: Any # TODO: Precise type + numSearchContinuations: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... + +class SearchNoOpMixIn: + def noop_search_st(self, base, scope=..., filterstr: str = "(objectClass=*)", timeout: int = -1): ... diff --git a/stubs/python-ldap/ldap/controls/pagedresults.pyi b/stubs/python-ldap/ldap/controls/pagedresults.pyi new file mode 100644 index 000000000000..296141ade8d3 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/pagedresults.pyi @@ -0,0 +1,10 @@ +from typing import Any +from ldap.controls import RequestControl, ResponseControl + +class SimplePagedResultsControl(RequestControl, ResponseControl): + controlType: Any + size: int + cookie: Any + def __init__(self, size: int = 0, cookie: Any = ...) -> None: ... + def encodeControlValue(self): ... + def decodeControlValue(self, encodedControlValue) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/ppolicy.pyi b/stubs/python-ldap/ldap/controls/ppolicy.pyi new file mode 100644 index 000000000000..00ea8e192886 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/ppolicy.pyi @@ -0,0 +1,20 @@ +from typing import Any +from ldap.controls import LDAPControl, ResponseControl + +__all__ = ["PasswordExpiringControl", "PasswordExpiredControl"] + +class PasswordPolicyControl(LDAPControl): + controlType: Any + def __init__(self, criticality: bool = False) -> None: ... + def encodeControlValue(self): ... + def decodeControlValue(self, encodedControlValue) -> None: ... + +class PasswordExpiringControl(ResponseControl): + controlType: str + gracePeriod: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... + +class PasswordExpiredControl(ResponseControl): + controlType: str + passwordExpired: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/psearch.pyi b/stubs/python-ldap/ldap/controls/psearch.pyi new file mode 100644 index 000000000000..4bf488507ca3 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/psearch.pyi @@ -0,0 +1,10 @@ +from typing import Any +from ldap.controls import LDAPControl + +class PersistentSearchControl(LDAPControl): + controlType: Any + def __init__( + self, criticality: bool = False, changeTypes: Any = ..., changesOnly: bool = False, returnECs: bool = False + ) -> None: ... + def encodeControlValue(self): ... + def decodeControlValue(self, encodedControlValue) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/pwdpolicy.pyi b/stubs/python-ldap/ldap/controls/pwdpolicy.pyi new file mode 100644 index 000000000000..9aa41e50fff1 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/pwdpolicy.pyi @@ -0,0 +1,15 @@ +from typing import Any + +from ldap.controls import ResponseControl + +__all__ = ["PasswordExpiringControl", "PasswordExpiredControl"] + +class PasswordExpiringControl(ResponseControl): + controlType: str + gracePeriod: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... + +class PasswordExpiredControl(ResponseControl): + controlType: str + passwordExpired: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/readentry.pyi b/stubs/python-ldap/ldap/controls/readentry.pyi new file mode 100644 index 000000000000..f41899b2246f --- /dev/null +++ b/stubs/python-ldap/ldap/controls/readentry.pyi @@ -0,0 +1,16 @@ +from typing import Any + +from ldap.controls import KNOWN_RESPONSE_CONTROLS as KNOWN_RESPONSE_CONTROLS, LDAPControl as LDAPControl + +class ReadEntryControl(LDAPControl): + def __init__(self, criticality: bool = False, attrList: Any | None = None) -> None: ... # TODO: Precise type for attrList + def encodeControlValue(self): ... + dn: Any # TODO: Precise type + entry: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... + +class PreReadControl(ReadEntryControl): + controlType: Any # TODO: Precise type + +class PostReadControl(ReadEntryControl): + controlType: Any # TODO: Precise type diff --git a/stubs/python-ldap/ldap/controls/sessiontrack.pyi b/stubs/python-ldap/ldap/controls/sessiontrack.pyi new file mode 100644 index 000000000000..28eb8bd7a07a --- /dev/null +++ b/stubs/python-ldap/ldap/controls/sessiontrack.pyi @@ -0,0 +1,19 @@ +from typing import Any + +from ldap.controls import RequestControl as RequestControl +from pyasn1.type import univ + +SESSION_TRACKING_CONTROL_OID: str = "SESSION_TRACKING_CONTROL_OID" # TODO: Set real OID value +SESSION_TRACKING_FORMAT_OID_RADIUS_ACCT_SESSION_ID: Any # TODO: Precise type +SESSION_TRACKING_FORMAT_OID_RADIUS_ACCT_MULTI_SESSION_ID: Any # TODO: Precise type +SESSION_TRACKING_FORMAT_OID_USERNAME: Any # TODO: Precise type + +class SessionTrackingControl(RequestControl): + controlType: str + + class SessionIdentifierControlValue(univ.Sequence): + componentType: Any # TODO: Precise type + + criticality: bool + def __init__(self, sessionSourceIp, sessionSourceName, formatOID, sessionTrackingIdentifier) -> None: ... + def encodeControlValue(self): ... diff --git a/stubs/python-ldap/ldap/controls/simple.pyi b/stubs/python-ldap/ldap/controls/simple.pyi new file mode 100644 index 000000000000..52e0eab1610f --- /dev/null +++ b/stubs/python-ldap/ldap/controls/simple.pyi @@ -0,0 +1,57 @@ +from typing import Any + +from ldap.controls import ( + KNOWN_RESPONSE_CONTROLS as KNOWN_RESPONSE_CONTROLS, + LDAPControl as LDAPControl, + RequestControl as RequestControl, + ResponseControl as ResponseControl, +) + +class ValueLessRequestControl(RequestControl): + controlType: Any + criticality: Any + def __init__(self, controlType: Any | None = None, criticality: bool = False) -> None: ... + def encodeControlValue(self) -> None: ... + +class OctetStringInteger(LDAPControl): + controlType: Any + criticality: Any + integerValue: Any + def __init__(self, controlType: Any | None = None, criticality: bool = False, integerValue: Any | None = None) -> None: ... + def encodeControlValue(self): ... + def decodeControlValue(self, encodedControlValue) -> None: ... + +class BooleanControl(LDAPControl): + controlType: Any + criticality: Any + booleanValue: Any + def __init__(self, controlType: Any | None = None, criticality: bool = False, booleanValue: bool = False) -> None: ... + def encodeControlValue(self): ... + def decodeControlValue(self, encodedControlValue) -> None: ... + +class ManageDSAITControl(ValueLessRequestControl): + def __init__(self, criticality: bool = False) -> None: ... + +class RelaxRulesControl(ValueLessRequestControl): + def __init__(self, criticality: bool = False) -> None: ... + +class ProxyAuthzControl(RequestControl): + def __init__(self, criticality, authzId) -> None: ... + +class AuthorizationIdentityRequestControl(ValueLessRequestControl): + controlType: str + def __init__(self, criticality) -> None: ... + +class AuthorizationIdentityResponseControl(ResponseControl): + controlType: str + authzId: Any + def decodeControlValue(self, encodedControlValue) -> None: ... + +class GetEffectiveRightsControl(RequestControl): + def __init__(self, criticality, authzId: Any | None = None) -> None: ... + +class SimpleControl: + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + # TODO: Add more precise attributes and methods + +def create_simple_control(*args: Any, **kwargs: Any) -> Any: ... # TODO: precise types diff --git a/stubs/python-ldap/ldap/controls/sss.pyi b/stubs/python-ldap/ldap/controls/sss.pyi new file mode 100644 index 000000000000..42edca9abfd5 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/sss.pyi @@ -0,0 +1,31 @@ +from typing import Any + +from ldap.controls import RequestControl, ResponseControl +from pyasn1.type import univ + +__all__ = ["SSSRequestControl", "SSSResponseControl"] + +class SortKeyType(univ.Sequence): + componentType: Any # TODO: Precise type + +class SortKeyListType(univ.SequenceOf): + componentType: Any # TODO: Precise type + +class SSSRequestControl(RequestControl): + controlType: str + ordering_rules: Any # TODO: Precise type + def __init__(self, criticality: bool = False, ordering_rules: Any | None = None) -> None: ... + def asn1(self): ... + def encodeControlValue(self): ... + +class SortResultType(univ.Sequence): + componentType: Any # TODO: Precise type + +class SSSResponseControl(ResponseControl): + controlType: str + def __init__(self, criticality: bool = False) -> None: ... + sortResult: Any # TODO: Precise type + attributeType: Any # TODO: Precise type + result: Any # TODO: Precise type + attribute_type_error: Any # TODO: Precise type + def decodeControlValue(self, encoded) -> None: ... diff --git a/stubs/python-ldap/ldap/controls/vlv.pyi b/stubs/python-ldap/ldap/controls/vlv.pyi new file mode 100644 index 000000000000..82b2e4af7fc6 --- /dev/null +++ b/stubs/python-ldap/ldap/controls/vlv.pyi @@ -0,0 +1,55 @@ +from typing import Any + +from ldap.controls import RequestControl, ResponseControl +from pyasn1.type import univ + +__all__ = ["VLVRequestControl", "VLVResponseControl"] + +class ByOffsetType(univ.Sequence): + tagSet: Any # TODO: Precise type + componentType: Any # TODO: Precise type + +class TargetType(univ.Choice): + componentType: Any # TODO: Precise type + +class VirtualListViewRequestType(univ.Sequence): + componentType: Any # TODO: Precise type + +class VLVRequestControl(RequestControl): + controlType: str + before_count: Any # TODO: Precise type + after_count: Any # TODO: Precise type + offset: Any # TODO: Precise type + content_count: Any # TODO: Precise type + greater_than_or_equal: Any # TODO: Precise type + context_id: Any # TODO: Precise type + def __init__( + self, + criticality: bool = False, + before_count: int = 0, + after_count: int = 0, + offset: Any | None = None, + content_count: Any | None = None, + greater_than_or_equal: Any | None = None, + context_id: Any | None = None, + ) -> None: ... + def encodeControlValue(self): ... + +class VirtualListViewResultType(univ.Enumerated): + namedValues: Any # TODO: Precise type + +class VirtualListViewResponseType(univ.Sequence): + componentType: Any # TODO: Precise type + +class VLVResponseControl(ResponseControl): + controlType: str + def __init__(self, criticality: bool = False) -> None: ... + targetPosition: Any # TODO: Precise type + contentCount: Any # TODO: Precise type + virtualListViewResult: Any # TODO: Precise type + contextID: Any # TODO: Precise type + target_position: Any # TODO: Precise type + content_count: Any # TODO: Precise type + result: Any # TODO: Precise type + context_id: Any # TODO: Precise type + def decodeControlValue(self, encoded) -> None: ... diff --git a/stubs/python-ldap/ldap/dn.pyi b/stubs/python-ldap/ldap/dn.pyi new file mode 100644 index 000000000000..11bc8c3b6683 --- /dev/null +++ b/stubs/python-ldap/ldap/dn.pyi @@ -0,0 +1,8 @@ +from ldap.pkginfo import __version__ as __version__ + +def escape_dn_chars(s): ... +def str2dn(dn, flags: int = 0): ... +def dn2str(dn): ... +def explode_dn(dn, notypes: bool = False, flags: int = 0): ... +def explode_rdn(rdn, notypes: bool = False, flags: int = 0): ... +def is_dn(s, flags: int = 0): ... diff --git a/stubs/python-ldap/ldap/extop/__init__.pyi b/stubs/python-ldap/ldap/extop/__init__.pyi new file mode 100644 index 000000000000..cedb2abf618d --- /dev/null +++ b/stubs/python-ldap/ldap/extop/__init__.pyi @@ -0,0 +1,16 @@ +from typing import Any + +from ldap import __version__ as __version__ +from ldap.extop.passwd import PasswordModifyResponse as PasswordModifyResponse + +class ExtendedRequest: + requestName: Any # TODO: Precise type + requestValue: Any # TODO: Precise type + def __init__(self, requestName, requestValue) -> None: ... + def encodedRequestValue(self): ... + +class ExtendedResponse: + responseName: Any # TODO: Precise type + responseValue: Any # TODO: Precise type + def __init__(self, responseName, encodedResponseValue) -> None: ... + def decodeResponseValue(self, value): ... diff --git a/stubs/python-ldap/ldap/extop/dds.pyi b/stubs/python-ldap/ldap/extop/dds.pyi new file mode 100644 index 000000000000..a31f43d9305a --- /dev/null +++ b/stubs/python-ldap/ldap/extop/dds.pyi @@ -0,0 +1,25 @@ +from typing import Any + +from ldap.extop import ExtendedRequest as ExtendedRequest, ExtendedResponse as ExtendedResponse +from pyasn1.type import univ + +class RefreshRequest(ExtendedRequest): + requestName: str + defaultRequestTtl: int + + class RefreshRequestValue(univ.Sequence): + componentType: Any # TODO: Precise type + + entryName: Any # TODO: Precise type + requestTtl: Any # TODO: Precise type + def __init__(self, requestName: Any | None = None, entryName: Any | None = None, requestTtl: Any | None = None) -> None: ... + def encodedRequestValue(self): ... + +class RefreshResponse(ExtendedResponse): + responseName: str + + class RefreshResponseValue(univ.Sequence): + componentType: Any # TODO: Precise type + + responseTtl: Any # TODO: Precise type + def decodeResponseValue(self, value): ... diff --git a/stubs/python-ldap/ldap/extop/passwd.pyi b/stubs/python-ldap/ldap/extop/passwd.pyi new file mode 100644 index 000000000000..b4c17778192b --- /dev/null +++ b/stubs/python-ldap/ldap/extop/passwd.pyi @@ -0,0 +1,13 @@ +from typing import Any + +from ldap.extop import ExtendedResponse as ExtendedResponse +from pyasn1.type import univ + +class PasswordModifyResponse(ExtendedResponse): + responseName: Any # TODO: Precise type + + class PasswordModifyResponseValue(univ.Sequence): + componentType: Any # TODO: Precise type + + genPasswd: Any # TODO: Precise type + def decodeResponseValue(self, value): ... diff --git a/stubs/python-ldap/ldap/filter.pyi b/stubs/python-ldap/ldap/filter.pyi new file mode 100644 index 000000000000..cc92a98659bb --- /dev/null +++ b/stubs/python-ldap/ldap/filter.pyi @@ -0,0 +1,9 @@ +from typing import Any +from ldap import __version__ as __version__ +from ldap.functions import strf_secs as strf_secs + +def escape_filter_chars(s: Any, ignore: Any = ...) -> Any: ... +def filter_format(filter_template: Any, assertion_values: Any) -> Any: ... +def time_span_filter( + filterstr: str = "", from_timestamp: int = 0, until_timestamp: object = ..., delta_attr: str = "modifyTimestamp" +) -> str: ... diff --git a/stubs/python-ldap/ldap/functions.pyi b/stubs/python-ldap/ldap/functions.pyi new file mode 100644 index 000000000000..e7a188b36820 --- /dev/null +++ b/stubs/python-ldap/ldap/functions.pyi @@ -0,0 +1,35 @@ +from typing import Any + +from ldap.dn import explode_dn as explode_dn, explode_rdn as explode_rdn + +__all__ = [ + "open", + "initialize", + "init", + "explode_dn", + "explode_rdn", + "get_option", + "set_option", + "escape_str", + "strf_secs", + "strp_secs", +] + +def initialize( + uri: Any, + trace_level: int = 0, + trace_file: Any = ..., + trace_stack_limit: Any = ..., + bytes_mode: Any = ..., + fileno: Any = ..., + **kwargs: Any, +) -> Any: ... +def get_option(option: Any) -> Any: ... +def set_option(option: Any, invalue: Any) -> None: ... +def escape_str(escape_func: Any, s: Any, *args: Any) -> Any: ... +def strf_secs(secs: Any) -> Any: ... +def strp_secs(dt_str: Any) -> Any: ... + +# Names in __all__ with no definition: +open: Any +init: Any diff --git a/stubs/python-ldap/ldap/ldapobject.pyi b/stubs/python-ldap/ldap/ldapobject.pyi new file mode 100644 index 000000000000..f821328b5c05 --- /dev/null +++ b/stubs/python-ldap/ldap/ldapobject.pyi @@ -0,0 +1,188 @@ +from typing import Any + +__all__ = ["LDAPObject", "SimpleLDAPObject", "ReconnectLDAPObject", "LDAPBytesWarning"] + +class LDAPBytesWarning(Warning): ... +class NO_UNIQUE_ENTRY(Exception): ... + +class SimpleLDAPObject: + CLASSATTR_OPTION_MAPPING: dict[str, Any] + timeout: int + protocol_version: Any + def __init__( + self, + uri: str, + trace_level: int = 0, + trace_file: Any = ..., + trace_stack_limit: int = 5, + bytes_mode: Any = ..., + bytes_strictness: Any = ..., + fileno: Any = ..., + ) -> None: ... + # Property: bytes_mode + def bytes_mode(self) -> Any: ... + # Property: bytes_strictness + def bytes_strictness(self) -> Any: ... + def __setattr__(self, name: str, value: Any) -> None: ... + def __getattr__(self, name: str) -> Any: ... + def fileno(self) -> Any: ... + def abandon_ext(self, msgid: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def abandon(self, msgid: Any) -> Any: ... + def cancel(self, cancelid: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def cancel_s(self, cancelid: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def add_ext(self, dn: str, modlist: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def add_ext_s(self, dn: str, modlist: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def add(self, dn: str, modlist: Any) -> Any: ... + def add_s(self, dn: str, modlist: Any) -> Any: ... + def simple_bind(self, who: Any = ..., cred: Any = ..., serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def simple_bind_s(self, who: Any = ..., cred: Any = ..., serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def bind(self, who: Any, cred: Any, method: Any = ...) -> Any: ... + def bind_s(self, who: Any, cred: Any, method: Any = ...) -> Any: ... + def sasl_interactive_bind_s( + self, who: Any, auth: Any, serverctrls: Any = ..., clientctrls: Any = ..., sasl_flags: Any = ... + ) -> Any: ... + def sasl_non_interactive_bind_s( + self, sasl_mech: Any, serverctrls: Any = ..., clientctrls: Any = ..., sasl_flags: Any = ..., authz_id: str = "" + ) -> None: ... + def sasl_external_bind_s( + self, serverctrls: Any = ..., clientctrls: Any = ..., sasl_flags: Any = ..., authz_id: str = "" + ) -> None: ... + def sasl_gssapi_bind_s( + self, serverctrls: Any = ..., clientctrls: Any = ..., sasl_flags: Any = ..., authz_id: str = "" + ) -> None: ... + def sasl_bind_s(self, dn: Any, mechanism: Any, cred: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def compare_ext(self, dn: str, attr: str, value: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def compare_ext_s(self, dn: str, attr: str, value: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def compare(self, dn: str, attr: str, value: Any) -> Any: ... + def compare_s(self, dn: str, attr: str, value: Any) -> Any: ... + def delete_ext(self, dn: str, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def delete_ext_s(self, dn: str, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def delete(self, dn: str) -> Any: ... + def delete_s(self, dn: str) -> Any: ... + def extop(self, extreq: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def extop_result(self, msgid: Any = ..., all: int = 1, timeout: Any = ...) -> Any: ... + def extop_s(self, extreq: Any, serverctrls: Any = ..., clientctrls: Any = ..., extop_resp_class: Any = ...) -> Any: ... + def modify_ext(self, dn: str, modlist: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def modify_ext_s(self, dn: str, modlist: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def modify(self, dn: str, modlist: Any) -> Any: ... + def modify_s(self, dn: str, modlist: Any) -> Any: ... + def modrdn(self, dn: str, newrdn: str, delold: int = 1) -> Any: ... + def modrdn_s(self, dn: str, newrdn: str, delold: int = 1) -> Any: ... + def passwd(self, user: Any, oldpw: Any, newpw: Any, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def passwd_s( + self, user: Any, oldpw: Any, newpw: Any, serverctrls: Any = ..., clientctrls: Any = ..., extract_newpw: bool = False + ) -> Any: ... + def rename( + self, dn: str, newrdn: str, newsuperior: Any = ..., delold: int = 1, serverctrls: Any = ..., clientctrls: Any = ... + ) -> Any: ... + def rename_s( + self, dn: str, newrdn: str, newsuperior: Any = ..., delold: int = 1, serverctrls: Any = ..., clientctrls: Any = ... + ) -> Any: ... + def result(self, msgid: Any = ..., all: int = 1, timeout: Any = ...) -> Any: ... + def result2(self, msgid: Any = ..., all: int = 1, timeout: Any = ...) -> Any: ... + def result3(self, msgid: Any = ..., all: int = 1, timeout: Any = ..., resp_ctrl_classes: Any = ...) -> Any: ... + def result4( + self, + msgid: Any = ..., + all: int = 1, + timeout: Any = ..., + add_ctrls: int = 0, + add_intermediates: int = 0, + add_extop: int = 0, + resp_ctrl_classes: Any = ..., + ) -> Any: ... + def search_ext( + self, + base: str, + scope: int, + filterstr: Any = ..., + attrlist: Any = ..., + attrsonly: int = 0, + serverctrls: Any = ..., + clientctrls: Any = ..., + timeout: int = -1, + sizelimit: int = 0, + ) -> Any: ... + def search_ext_s( + self, + base: str, + scope: int, + filterstr: Any = ..., + attrlist: Any = ..., + attrsonly: int = 0, + serverctrls: Any = ..., + clientctrls: Any = ..., + timeout: int = -1, + sizelimit: int = 0, + ) -> Any: ... + def search(self, base: str, scope: int, filterstr: Any = ..., attrlist: Any = ..., attrsonly: int = 0) -> Any: ... + def search_s(self, base: str, scope: int, filterstr: Any = ..., attrlist: Any = ..., attrsonly: int = 0) -> Any: ... + def search_st( + self, base: str, scope: int, filterstr: Any = ..., attrlist: Any = ..., attrsonly: int = 0, timeout: int = -1 + ) -> Any: ... + def start_tls_s(self) -> Any: ... + def unbind_ext(self, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def unbind_ext_s(self, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def unbind(self) -> Any: ... + def unbind_s(self) -> Any: ... + def whoami_s(self, serverctrls: Any = ..., clientctrls: Any = ...) -> Any: ... + def get_option(self, option: Any) -> Any: ... + def set_option(self, option: Any, invalue: Any) -> None: ... + def search_subschemasubentry_s(self, dn: Any = ...) -> Any: ... + def read_s( + self, + dn: str, + filterstr: Any = ..., + attrlist: Any = ..., + serverctrls: Any = ..., + clientctrls: Any = ..., + timeout: int = -1, + ) -> Any: ... + def read_subschemasubentry_s(self, subschemasubentry_dn: Any, attrs: Any = ...) -> Any: ... + def find_unique_entry( + self, + base: str, + scope: Any = ..., + filterstr: Any = ..., + attrlist: Any = ..., + attrsonly: int = 0, + serverctrls: Any = ..., + clientctrls: Any = ..., + timeout: int = -1, + ) -> Any: ... + def read_rootdse_s(self, filterstr: Any = ..., attrlist: Any = ...) -> Any: ... + def get_naming_contexts(self) -> Any: ... + +class ReconnectLDAPObject(SimpleLDAPObject): + __transient_attrs__: Any + def __init__( + self, + uri: str, + trace_level: int = 0, + trace_file: Any = ..., + trace_stack_limit: int = 5, + bytes_mode: Any = ..., + bytes_strictness: Any = ..., + retry_max: int = 1, + retry_delay: float = 60.0, + fileno: Any = ..., + ) -> None: ... + def passwd_s(self, *args: Any, **kwargs: Any) -> Any: ... + def reconnect(self, uri: str, retry_max: int = 1, retry_delay: float = 60.0, force: bool = True) -> None: ... + def set_option(self, option: Any, invalue: Any) -> None: ... + def bind_s(self, *args: Any, **kwargs: Any) -> Any: ... + def simple_bind_s(self, *args: Any, **kwargs: Any) -> Any: ... + def start_tls_s(self, *args: Any, **kwargs: Any) -> Any: ... + def sasl_interactive_bind_s(self, *args: Any, **kwargs: Any) -> Any: ... + def sasl_bind_s(self, *args: Any, **kwargs: Any) -> Any: ... + def add_ext_s(self, *args: Any, **kwargs: Any) -> Any: ... + def cancel_s(self, *args: Any, **kwargs: Any) -> Any: ... + def compare_ext_s(self, *args: Any, **kwargs: Any) -> Any: ... + def delete_ext_s(self, *args: Any, **kwargs: Any) -> Any: ... + def extop_s(self, *args: Any, **kwargs: Any) -> Any: ... + def modify_ext_s(self, *args: Any, **kwargs: Any) -> Any: ... + def rename_s(self, *args: Any, **kwargs: Any) -> Any: ... + def search_ext_s(self, *args: Any, **kwargs: Any) -> Any: ... + def whoami_s(self, *args: Any, **kwargs: Any) -> Any: ... + +class LDAPObject(SimpleLDAPObject): ... diff --git a/stubs/python-ldap/ldap/logger.pyi b/stubs/python-ldap/ldap/logger.pyi new file mode 100644 index 000000000000..6c75a7f375fe --- /dev/null +++ b/stubs/python-ldap/ldap/logger.pyi @@ -0,0 +1,12 @@ +from typing import Any + +class Logger: + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def log(self, *args: Any, **kwargs: Any) -> None: ... + def debug(self, *args: Any, **kwargs: Any) -> None: ... + def info(self, *args: Any, **kwargs: Any) -> None: ... + def warning(self, *args: Any, **kwargs: Any) -> None: ... + def error(self, *args: Any, **kwargs: Any) -> None: ... + def critical(self, *args: Any, **kwargs: Any) -> None: ... + +logger: Logger diff --git a/stubs/python-ldap/ldap/modlist.pyi b/stubs/python-ldap/ldap/modlist.pyi new file mode 100644 index 000000000000..b66ab25232df --- /dev/null +++ b/stubs/python-ldap/ldap/modlist.pyi @@ -0,0 +1,4 @@ +from typing import Any + +def addModlist(entry: Any, ignore: Any = ...) -> Any: ... +def modifyModlist(entry1: Any, entry2: Any, ignore: Any = ...) -> Any: ... diff --git a/stubs/python-ldap/ldap/pkginfo.pyi b/stubs/python-ldap/ldap/pkginfo.pyi new file mode 100644 index 000000000000..bda5b5a7f4cc --- /dev/null +++ b/stubs/python-ldap/ldap/pkginfo.pyi @@ -0,0 +1 @@ +__version__: str diff --git a/stubs/python-ldap/ldap/resiter.pyi b/stubs/python-ldap/ldap/resiter.pyi new file mode 100644 index 000000000000..464dcc9d4cdf --- /dev/null +++ b/stubs/python-ldap/ldap/resiter.pyi @@ -0,0 +1,9 @@ +from typing import Any +from collections.abc import Generator + +from ldap.pkginfo import __version__ as __version__ + +class ResultProcessor: + def allresults( + self, msgid, timeout: int = -1, add_ctrls: int = 0 + ) -> Generator[Any, None, None]: ... # TODO: Precise type for Generator yield diff --git a/stubs/python-ldap/ldap/sasl.pyi b/stubs/python-ldap/ldap/sasl.pyi new file mode 100644 index 000000000000..6a1e5b32847e --- /dev/null +++ b/stubs/python-ldap/ldap/sasl.pyi @@ -0,0 +1,31 @@ +from typing import Any + +from ldap import __version__ as __version__ + +CB_USER: int +CB_AUTHNAME: int +CB_LANGUAGE: int +CB_PASS: int +CB_ECHOPROMPT: int +CB_NOECHOPROMPT: int +CB_GETREALM: int + +class sasl: + + cb_value_dict: dict[Any, Any] + mech: bytes + + def __init__(self, cb_value_dict: dict[Any, Any], mech: str | bytes) -> None: ... + def callback(self, cb_id: int, challenge: Any, prompt: Any, defresult: Any) -> bytes: ... + +class cram_md5(sasl): + def __init__(self, authc_id: Any, password: Any, authz_id: str = "") -> None: ... + +class digest_md5(sasl): + def __init__(self, authc_id: Any, password: Any, authz_id: str = "") -> None: ... + +class gssapi(sasl): + def __init__(self, authz_id: str = "") -> None: ... + +class external(sasl): + def __init__(self, authz_id: str = "") -> None: ... diff --git a/stubs/python-ldap/ldap/schema/__init__.pyi b/stubs/python-ldap/ldap/schema/__init__.pyi new file mode 100644 index 000000000000..47a028dd6386 --- /dev/null +++ b/stubs/python-ldap/ldap/schema/__init__.pyi @@ -0,0 +1,9 @@ +from ldap import __version__ as __version__ +from ldap.schema.models import * +from ldap.schema.subentry import ( + SCHEMA_ATTR_MAPPING as SCHEMA_ATTR_MAPPING, + SCHEMA_ATTRS as SCHEMA_ATTRS, + SCHEMA_CLASS_MAPPING as SCHEMA_CLASS_MAPPING, + SubSchema as SubSchema, + urlfetch as urlfetch, +) diff --git a/stubs/python-ldap/ldap/schema/models.pyi b/stubs/python-ldap/ldap/schema/models.pyi new file mode 100644 index 000000000000..b5fb1fd2e00f --- /dev/null +++ b/stubs/python-ldap/ldap/schema/models.pyi @@ -0,0 +1,74 @@ +from _typeshed import SupportsKeysAndGetItem +from collections.abc import Iterable +from typing import Any, overload +from collections import UserDict + +from ldap.schema.tokenizer import extract_tokens as extract_tokens, split_tokens as split_tokens + +NOT_HUMAN_READABLE_LDAP_SYNTAXES: Any # TODO: Precise type + +class SchemaElement: + token_defaults: Any # TODO: Precise type + def __init__(self, schema_element_str: Any | None = None) -> None: ... + oid: Any # TODO: Precise type + def set_id(self, element_id) -> None: ... + def get_id(self): ... + def key_attr(self, key, value, quoted: int = 0): ... + def key_list(self, key, values, sep: str = " ", quoted: int = 0): ... + +class ObjectClass(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +AttributeUsage: Any # TODO: Precise type + +class AttributeType(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +class LDAPSyntax(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +class MatchingRule(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +class MatchingRuleUse(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +class DITContentRule(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +class DITStructureRule(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + ruleid: Any # TODO: Precise type + def set_id(self, element_id) -> None: ... + def get_id(self): ... + +class NameForm(SchemaElement): + schema_attribute: str + token_defaults: Any # TODO: Precise type + +class Entry(UserDict[Any, Any]): + dn: Any # TODO: Precise type + def __init__(self, schema, dn, entry) -> None: ... + @overload + def update(self, other: SupportsKeysAndGetItem[Any, Any], /, **kwargs: Any) -> None: ... + @overload + def update(self, other: Iterable[tuple[Any, Any]], /, **kwargs: Any) -> None: ... + @overload + def update(self, **kwargs: Any) -> None: ... + def __contains__(self, nameoroid) -> bool: ... + def __getitem__(self, nameoroid): ... + def __setitem__(self, nameoroid, attr_values) -> None: ... + def __delitem__(self, nameoroid) -> None: ... + def has_key(self, nameoroid): ... + def keys(self): ... + def items(self): ... + def attribute_types( + self, attr_type_filter: Any | None = None, raise_keyerror: int = 1 + ): ... # TODO: Precise type for attr_type_filter diff --git a/stubs/python-ldap/ldap/schema/subentry.pyi b/stubs/python-ldap/ldap/schema/subentry.pyi new file mode 100644 index 000000000000..76705a905763 --- /dev/null +++ b/stubs/python-ldap/ldap/schema/subentry.pyi @@ -0,0 +1,45 @@ +from typing import Any + +from ldap.schema.models import * + +SCHEMA_CLASS_MAPPING: Any # TODO: Precise type +SCHEMA_ATTR_MAPPING: Any # TODO: Precise type +SCHEMA_ATTRS: Any # TODO: Precise type + +class SubschemaError(ValueError): ... + +class OIDNotUnique(SubschemaError): + desc: Any # TODO: Precise type + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class NameNotUnique(SubschemaError): + desc: Any # TODO: Precise type + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class SubSchema: + name2oid: Any # TODO: Precise type + sed: Any # TODO: Precise type + non_unique_oids: Any # TODO: Precise type + non_unique_names: Any # TODO: Precise type + def __init__(self, sub_schema_sub_entry, check_uniqueness: int = 1) -> None: ... + def ldap_entry(self): ... + def listall( + self, schema_element_class, schema_element_filters: Any | None = None + ): ... # TODO: Precise type for schema_element_filters + def tree( + self, schema_element_class, schema_element_filters: Any | None = None + ): ... # TODO: Precise type for schema_element_filters + def getoid(self, se_class, nameoroid, raise_keyerror: int = 0): ... + def get_inheritedattr(self, se_class, nameoroid, name): ... + def get_obj( + self, se_class, nameoroid, default: Any | None = None, raise_keyerror: int = 0 + ): ... # TODO: Precise type for default + def get_inheritedobj(self, se_class, nameoroid, inherited: Any | None = None): ... # TODO: Precise type for inherited + def get_syntax(self, nameoroid): ... + def get_structural_oc(self, oc_list): ... + def get_applicable_aux_classes(self, nameoroid): ... + def attribute_types( + self, object_class_list, attr_type_filter: Any | None = None, raise_keyerror: int = 1, ignore_dit_content_rule: int = 0 + ): ... # TODO: Precise type for attr_type_filter + +def urlfetch(uri, trace_level: int = 0): ... diff --git a/stubs/python-ldap/ldap/schema/tokenizer.pyi b/stubs/python-ldap/ldap/schema/tokenizer.pyi new file mode 100644 index 000000000000..6dd43d10f4d6 --- /dev/null +++ b/stubs/python-ldap/ldap/schema/tokenizer.pyi @@ -0,0 +1,7 @@ +from typing import Any + +TOKENS_FINDALL: Any # TODO: Precise type +UNESCAPE_PATTERN: Any # TODO: Precise type + +def split_tokens(s): ... +def extract_tokens(l, known_tokens): ... diff --git a/stubs/python-ldap/ldap/syncrepl.pyi b/stubs/python-ldap/ldap/syncrepl.pyi new file mode 100644 index 000000000000..fdb566d886b1 --- /dev/null +++ b/stubs/python-ldap/ldap/syncrepl.pyi @@ -0,0 +1,86 @@ +from typing import Any + +from ldap.controls import RequestControl, ResponseControl +from pyasn1.type import univ + +__all__ = ["SyncreplConsumer"] + +class SyncUUID(univ.OctetString): + subtypeSpec: Any # TODO: Precise type + +class SyncCookie(univ.OctetString): ... + +class SyncRequestMode(univ.Enumerated): + namedValues: Any # TODO: Precise type + subtypeSpec: Any # TODO: Precise type + +class SyncRequestValue(univ.Sequence): + componentType: Any # TODO: Precise type + +class SyncRequestControl(RequestControl): + controlType: str + criticality: Any # TODO: Precise type + cookie: Any # TODO: Precise type + mode: Any # TODO: Precise type + reloadHint: Any # TODO: Precise type + def __init__( + self, criticality: int = 1, cookie: Any | None = None, mode: str = "refreshOnly", reloadHint: bool = False + ) -> None: ... + def encodeControlValue(self): ... + +class SyncStateOp(univ.Enumerated): + namedValues: Any # TODO: Precise type + subtypeSpec: Any # TODO: Precise type + +class SyncStateValue(univ.Sequence): + componentType: Any # TODO: Precise type + +class SyncStateControl(ResponseControl): + controlType: str + opnames: Any # TODO: Precise type + cookie: Any # TODO: Precise type + state: Any # TODO: Precise type + entryUUID: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... + +class SyncDoneValue(univ.Sequence): + componentType: Any # TODO: Precise type + +class SyncDoneControl(ResponseControl): + controlType: str + cookie: Any # TODO: Precise type + refreshDeletes: Any # TODO: Precise type + def decodeControlValue(self, encodedControlValue) -> None: ... + +class RefreshDelete(univ.Sequence): + componentType: Any # TODO: Precise type + +class RefreshPresent(univ.Sequence): + componentType: Any # TODO: Precise type + +class SyncUUIDs(univ.SetOf): + componentType: Any # TODO: Precise type + +class SyncIdSet(univ.Sequence): + componentType: Any # TODO: Precise type + +class SyncInfoValue(univ.Choice): + componentType: Any # TODO: Precise type + +class SyncInfoMessage: + responseName: str + newcookie: Any # TODO: Precise type + refreshDelete: Any # TODO: Precise type + refreshPresent: Any # TODO: Precise type + syncIdSet: Any # TODO: Precise type + def __init__(self, encodedMessage) -> None: ... + +class SyncreplConsumer: + def syncrepl_search(self, base, scope, mode: str = "refreshOnly", cookie: Any | None = None, **search_args): ... + def syncrepl_poll(self, msgid: int = -1, timeout: Any | None = None, all: int = 0): ... + def syncrepl_set_cookie(self, cookie) -> None: ... + def syncrepl_get_cookie(self) -> None: ... + def syncrepl_present(self, uuids, refreshDeletes: bool = False) -> None: ... + def syncrepl_delete(self, uuids) -> None: ... + def syncrepl_entry(self, dn, attrs, uuid) -> None: ... + def syncrepl_refreshdone(self) -> None: ... diff --git a/stubs/python-ldap/ldif.pyi b/stubs/python-ldap/ldif.pyi new file mode 100644 index 000000000000..428510e29ab7 --- /dev/null +++ b/stubs/python-ldap/ldif.pyi @@ -0,0 +1,65 @@ +from typing import IO, Any + +__all__ = ["ldif_pattern", "CreateLDIF", "ParseLDIF", "LDIFWriter", "LDIFParser", "LDIFRecordList", "LDIFCopy"] + +ldif_pattern: str + +class LDIFWriter: + + records_written: int + def __init__(self, output_file: IO[str], base64_attrs: Any | None = None, cols: int = 76, line_sep: str = "\n") -> None: ... + def unparse(self, dn: str, record: dict[str, list[bytes]] | list[Any]) -> None: ... + def unparseChangeRecords(self, records: Any) -> None: ... + +def CreateLDIF(dn: str, record: dict[str, list[bytes]] | list[Any], base64_attrs: Any | None = None, cols: int = 76) -> str: ... + +class LDIFParser: + + version: int | None + line_counter: int + byte_counter: int + records_read: int + changetype_counter: dict[str, int] + def __init__( + self, + input_file: IO[str], + ignored_attr_types: Any | None = None, + max_entries: int = 0, + process_url_schemes: Any | None = None, + line_sep: str = "\n", + ) -> None: ... + def handle(self, dn: str, entry: dict[str, list[bytes]]) -> None: ... + def parse_entry_records(self) -> None: ... + def parse(self) -> None: ... + def handle_modify(self, dn: str, modops: list[tuple[int, str, list[bytes]]], controls: Any | None = None) -> None: ... + def parse_change_records(self) -> None: ... + +class LDIFRecordList(LDIFParser): + + all_records: list[tuple[str, dict[str, list[bytes]]]] + all_modify_changes: list[tuple[str, list[tuple[int, str, list[bytes]]], Any]] + def __init__( + self, + input_file: IO[str], + ignored_attr_types: Any | None = None, + max_entries: int = 0, + process_url_schemes: Any | None = None, + ) -> None: ... + def handle(self, dn: str, entry: dict[str, list[bytes]]) -> None: ... + def handle_modify(self, dn: str, modops: list[tuple[int, str, list[bytes]]], controls: Any | None = None) -> None: ... + +class LDIFCopy(LDIFParser): + def __init__( + self, + input_file: IO[str], + output_file: IO[str], + ignored_attr_types: Any | None = None, + max_entries: int = 0, + process_url_schemes: Any | None = None, + base64_attrs: Any | None = None, + cols: int = 76, + line_sep: str = "\n", + ) -> None: ... + def handle(self, dn: str, entry: dict[str, list[bytes]]) -> None: ... + +def ParseLDIF(f: IO[str], ignore_attrs: Any | None = None, maxentries: int = 0) -> list[tuple[str, dict[str, list[bytes]]]]: ... From a71cfe936f355960fa671193524ad4cfb5194a81 Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Mon, 27 Jul 2026 23:40:12 -0300 Subject: [PATCH 2/2] python-ldap: Update metadata for current typeshed --- stubs/python-ldap/METADATA.toml | 10 +++++----- stubs/python-ldap/ldap/schema/models.pyi | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/stubs/python-ldap/METADATA.toml b/stubs/python-ldap/METADATA.toml index 5cba0eebe802..01675c783b53 100644 --- a/stubs/python-ldap/METADATA.toml +++ b/stubs/python-ldap/METADATA.toml @@ -1,11 +1,11 @@ version = "3.4.*" -requires = ["types-pyasn1"] -upstream_repository = "https://github.com/python-ldap/python-ldap" -extra_description = """ +dependencies = ["types-pyasn1"] +upstream-repository = "https://github.com/python-ldap/python-ldap" +extra-description = """ Type stubs for python-ldap, covering the public API as documented at https://www.python-ldap.org/doc/html/api.html. """ -partial_stub = true +partial-stub = true [tool.stubtest] -stubtest_requirements = ["python-ldap"] +stubtest-dependencies = ["python-ldap"] diff --git a/stubs/python-ldap/ldap/schema/models.pyi b/stubs/python-ldap/ldap/schema/models.pyi index b5fb1fd2e00f..99926b473ccf 100644 --- a/stubs/python-ldap/ldap/schema/models.pyi +++ b/stubs/python-ldap/ldap/schema/models.pyi @@ -56,12 +56,14 @@ class NameForm(SchemaElement): class Entry(UserDict[Any, Any]): dn: Any # TODO: Precise type def __init__(self, schema, dn, entry) -> None: ... + @overload def update(self, other: SupportsKeysAndGetItem[Any, Any], /, **kwargs: Any) -> None: ... @overload def update(self, other: Iterable[tuple[Any, Any]], /, **kwargs: Any) -> None: ... @overload def update(self, **kwargs: Any) -> None: ... + def __contains__(self, nameoroid) -> bool: ... def __getitem__(self, nameoroid): ... def __setitem__(self, nameoroid, attr_values) -> None: ...