diff --git a/stubs/ldap3/METADATA.toml b/stubs/ldap3/METADATA.toml index 77ff5706c..d47a19ed3 100644 --- a/stubs/ldap3/METADATA.toml +++ b/stubs/ldap3/METADATA.toml @@ -1,2 +1,2 @@ version = "2.9.*" -requires = [] # requires types-pyasn1 (not available yet) +requires = ["types-pyasn1"] diff --git a/stubs/ldap3/ldap3/core/connection.pyi b/stubs/ldap3/ldap3/core/connection.pyi index 11a4ecd09..fe7acb467 100644 --- a/stubs/ldap3/ldap3/core/connection.pyi +++ b/stubs/ldap3/ldap3/core/connection.pyi @@ -1,68 +1,69 @@ from _collections_abc import Generator, dict_keys -from _typeshed import Self +from _typeshed import Incomplete, ReadableBuffer, Self from types import TracebackType -from typing import Any from typing_extensions import Literal, TypeAlias +from pyasn1.type.base import Asn1Item + from .pooling import ServerPool from .server import Server -SASL_AVAILABLE_MECHANISMS: Any -CLIENT_STRATEGIES: Any +SASL_AVAILABLE_MECHANISMS: Incomplete +CLIENT_STRATEGIES: Incomplete _ServerSequence: TypeAlias = ( - set[Server] | list[Server] | tuple[Server, ...] | Generator[Server, None, None] | dict_keys[Server, Any] + set[Server] | list[Server] | tuple[Server, ...] | Generator[Server, None, None] | dict_keys[Server, Incomplete] ) class Connection: - connection_lock: Any + connection_lock: Incomplete last_error: str - strategy_type: Any - user: Any - password: Any - authentication: Any - version: Any - auto_referrals: Any - request: Any - response: Any | None - result: Any + strategy_type: Incomplete + user: Incomplete + password: Incomplete + authentication: Incomplete + version: Incomplete + auto_referrals: Incomplete + request: Incomplete + response: Incomplete | None + result: Incomplete bound: bool listening: bool closed: bool - auto_bind: Any - sasl_mechanism: Any - sasl_credentials: Any - socket: Any + auto_bind: Incomplete + sasl_mechanism: Incomplete + sasl_credentials: Incomplete + socket: Incomplete tls_started: bool sasl_in_progress: bool - read_only: Any - lazy: Any - pool_name: Any + read_only: Incomplete + lazy: Incomplete + pool_name: Incomplete pool_size: int | None - cred_store: Any - pool_lifetime: Any - pool_keepalive: Any + cred_store: Incomplete + pool_lifetime: Incomplete + pool_keepalive: Incomplete starting_tls: bool - check_names: Any - raise_exceptions: Any - auto_range: Any - extend: Any - fast_decoder: Any - receive_timeout: Any - empty_attributes: Any - use_referral_cache: Any - auto_escape: Any - auto_encode: Any - source_address: Any - source_port_list: Any - server_pool: Any | None - server: Any - strategy: Any - send: Any - open: Any - get_response: Any - post_send_single_response: Any - post_send_search: Any + check_names: Incomplete + raise_exceptions: Incomplete + auto_range: Incomplete + extend: Incomplete + fast_decoder: Incomplete + receive_timeout: Incomplete + empty_attributes: Incomplete + use_referral_cache: Incomplete + auto_escape: Incomplete + auto_encode: Incomplete + source_address: Incomplete + source_port_list: Incomplete + server_pool: Incomplete | None + server: Incomplete + strategy: Incomplete + send: Incomplete + open: Incomplete + get_response: Incomplete + post_send_single_response: Incomplete + post_send_search: Incomplete def __init__( self, server: Server | str | _ServerSequence | ServerPool, @@ -86,7 +87,7 @@ class Connection: auto_referrals: bool = ..., auto_range: bool = ..., sasl_mechanism: str | None = ..., - sasl_credentials: Any | None = ..., + sasl_credentials: Incomplete | None = ..., check_names: bool = ..., collect_usage: bool = ..., read_only: bool = ..., @@ -95,17 +96,17 @@ class Connection: pool_name: str | None = ..., pool_size: int | None = ..., pool_lifetime: int | None = ..., - cred_store: Any | None = ..., + cred_store: Incomplete | None = ..., fast_decoder: bool = ..., - receive_timeout: Any | None = ..., + receive_timeout: Incomplete | None = ..., return_empty_attributes: bool = ..., use_referral_cache: bool = ..., auto_escape: bool = ..., auto_encode: bool = ..., - pool_keepalive: Any | None = ..., + pool_keepalive: Incomplete | None = ..., source_address: str | None = ..., source_port: int | None = ..., - source_port_list: Any | None = ..., + source_port_list: Incomplete | None = ..., ) -> None: ... def repr_with_sensitive_data_stripped(self): ... @property @@ -118,45 +119,51 @@ class Connection: def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> Literal[False] | None: ... - def bind(self, read_server_info: bool = ..., controls: Any | None = ...): ... + def bind(self, read_server_info: bool = ..., controls: Incomplete | None = ...): ... def rebind( self, - user: Any | None = ..., - password: Any | None = ..., - authentication: Any | None = ..., - sasl_mechanism: Any | None = ..., - sasl_credentials: Any | None = ..., + user: Incomplete | None = ..., + password: Incomplete | None = ..., + authentication: Incomplete | None = ..., + sasl_mechanism: Incomplete | None = ..., + sasl_credentials: Incomplete | None = ..., read_server_info: bool = ..., - controls: Any | None = ..., + controls: Incomplete | None = ..., ): ... - def unbind(self, controls: Any | None = ...): ... + def unbind(self, controls: Incomplete | None = ...): ... def search( self, search_base: str, search_filter: str, search_scope: Literal["BASE", "LEVEL", "SUBTREE"] = ..., dereference_aliases: Literal["NEVER", "SEARCH", "FINDING_BASE", "ALWAYS"] = ..., - attributes: Any | None = ..., + attributes: Incomplete | None = ..., size_limit: int = ..., time_limit: int = ..., types_only: bool = ..., get_operational_attributes: bool = ..., - controls: Any | None = ..., + controls: Incomplete | None = ..., paged_size: int | None = ..., paged_criticality: bool = ..., paged_cookie: str | bytes | None = ..., auto_escape: bool | None = ..., ): ... - def compare(self, dn, attribute, value, controls: Any | None = ...): ... - def add(self, dn, object_class: Any | None = ..., attributes: Any | None = ..., controls: Any | None = ...): ... - def delete(self, dn, controls: Any | None = ...): ... - def modify(self, dn, changes, controls: Any | None = ...): ... - def modify_dn( - self, dn, relative_dn, delete_old_dn: bool = ..., new_superior: Any | None = ..., controls: Any | None = ... + def compare(self, dn, attribute, value, controls: Incomplete | None = ...): ... + def add( + self, dn, object_class: Incomplete | None = ..., attributes: Incomplete | None = ..., controls: Incomplete | None = ... ): ... - def abandon(self, message_id, controls: Any | None = ...): ... + def delete(self, dn, controls: Incomplete | None = ...): ... + def modify(self, dn, changes, controls: Incomplete | None = ...): ... + def modify_dn( + self, dn, relative_dn, delete_old_dn: bool = ..., new_superior: Incomplete | None = ..., controls: Incomplete | None = ... + ): ... + def abandon(self, message_id, controls: Incomplete | None = ...): ... def extended( - self, request_name, request_value: Any | None = ..., controls: Any | None = ..., no_encode: Any | None = ... + self, + request_name, + request_value: Asn1Item | ReadableBuffer | None = ..., + controls: Incomplete | None = ..., + no_encode: bool | None = ..., ): ... def start_tls(self, read_server_info: bool = ...): ... def do_sasl_bind(self, controls): ... @@ -164,19 +171,19 @@ class Connection: def refresh_server_info(self) -> None: ... def response_to_ldif( self, - search_result: Any | None = ..., + search_result: Incomplete | None = ..., all_base64: bool = ..., - line_separator: Any | None = ..., - sort_order: Any | None = ..., - stream: Any | None = ..., + line_separator: Incomplete | None = ..., + sort_order: Incomplete | None = ..., + stream: Incomplete | None = ..., ): ... def response_to_json( self, raw: bool = ..., - search_result: Any | None = ..., + search_result: Incomplete | None = ..., indent: int = ..., sort: bool = ..., - stream: Any | None = ..., + stream: Incomplete | None = ..., checked_attributes: bool = ..., include_empty: bool = ..., ): ... diff --git a/stubs/ldap3/ldap3/extend/novell/endTransaction.pyi b/stubs/ldap3/ldap3/extend/novell/endTransaction.pyi index f0e8c5896..d0b07c285 100644 --- a/stubs/ldap3/ldap3/extend/novell/endTransaction.pyi +++ b/stubs/ldap3/ldap3/extend/novell/endTransaction.pyi @@ -1,14 +1,15 @@ -from typing import Any +from _typeshed import Incomplete from ...extend.operation import ExtendedOperation +from ...protocol.novell import EndGroupTypeRequestValue, EndGroupTypeResponseValue class EndTransaction(ExtendedOperation): request_name: str response_name: str - request_value: Any - asn1_spec: Any + request_value: EndGroupTypeRequestValue + asn1_spec: EndGroupTypeResponseValue def config(self) -> None: ... - def __init__(self, connection, commit: bool = ..., controls: Any | None = ...) -> None: ... + def __init__(self, connection, commit: bool = ..., controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... - response_value: Any + response_value: Incomplete def set_response(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/getBindDn.pyi b/stubs/ldap3/ldap3/extend/novell/getBindDn.pyi index 4c194ce82..3e9e9c40b 100644 --- a/stubs/ldap3/ldap3/extend/novell/getBindDn.pyi +++ b/stubs/ldap3/ldap3/extend/novell/getBindDn.pyi @@ -1,11 +1,10 @@ -from typing import Any - from ...extend.operation import ExtendedOperation +from ...protocol.novell import Identity class GetBindDn(ExtendedOperation): request_name: str response_name: str response_attribute: str - asn1_spec: Any + asn1_spec: Identity def config(self) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/listReplicas.pyi b/stubs/ldap3/ldap3/extend/novell/listReplicas.pyi index 0c7b6e7a8..ec94538a1 100644 --- a/stubs/ldap3/ldap3/extend/novell/listReplicas.pyi +++ b/stubs/ldap3/ldap3/extend/novell/listReplicas.pyi @@ -1,13 +1,15 @@ -from typing import Any +from _typeshed import Incomplete from ...extend.operation import ExtendedOperation +from ...protocol.novell import ReplicaList +from ...protocol.rfc4511 import LDAPDN class ListReplicas(ExtendedOperation): request_name: str response_name: str - request_value: Any - asn1_spec: Any + request_value: LDAPDN + asn1_spec: ReplicaList response_attribute: str def config(self) -> None: ... - def __init__(self, connection, server_dn, controls: Any | None = ...) -> None: ... + def __init__(self, connection, server_dn, controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/nmasGetUniversalPassword.pyi b/stubs/ldap3/ldap3/extend/novell/nmasGetUniversalPassword.pyi index 59d0f1ca3..bc467cd51 100644 --- a/stubs/ldap3/ldap3/extend/novell/nmasGetUniversalPassword.pyi +++ b/stubs/ldap3/ldap3/extend/novell/nmasGetUniversalPassword.pyi @@ -1,13 +1,14 @@ -from typing import Any +from _typeshed import Incomplete from ...extend.operation import ExtendedOperation +from ...protocol.novell import NmasGetUniversalPasswordRequestValue, NmasGetUniversalPasswordResponseValue class NmasGetUniversalPassword(ExtendedOperation): request_name: str response_name: str - request_value: Any - asn1_spec: Any + request_value: NmasGetUniversalPasswordRequestValue + asn1_spec: NmasGetUniversalPasswordResponseValue response_attribute: str def config(self) -> None: ... - def __init__(self, connection, user, controls: Any | None = ...) -> None: ... + def __init__(self, connection, user, controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/nmasSetUniversalPassword.pyi b/stubs/ldap3/ldap3/extend/novell/nmasSetUniversalPassword.pyi index a35b984ba..de23d84d4 100644 --- a/stubs/ldap3/ldap3/extend/novell/nmasSetUniversalPassword.pyi +++ b/stubs/ldap3/ldap3/extend/novell/nmasSetUniversalPassword.pyi @@ -1,13 +1,14 @@ -from typing import Any +from _typeshed import Incomplete from ...extend.operation import ExtendedOperation +from ...protocol.novell import NmasSetUniversalPasswordRequestValue, NmasSetUniversalPasswordResponseValue class NmasSetUniversalPassword(ExtendedOperation): request_name: str response_name: str - request_value: Any - asn1_spec: Any + request_value: NmasSetUniversalPasswordRequestValue + asn1_spec: NmasSetUniversalPasswordResponseValue response_attribute: str def config(self) -> None: ... - def __init__(self, connection, user, new_password, controls: Any | None = ...) -> None: ... + def __init__(self, connection, user, new_password, controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/partition_entry_count.pyi b/stubs/ldap3/ldap3/extend/novell/partition_entry_count.pyi index a9127983a..cd2e1c077 100644 --- a/stubs/ldap3/ldap3/extend/novell/partition_entry_count.pyi +++ b/stubs/ldap3/ldap3/extend/novell/partition_entry_count.pyi @@ -1,12 +1,13 @@ -from typing import Any +from _typeshed import Incomplete +from ...protocol.rfc4511 import LDAPDN from ..operation import ExtendedOperation class PartitionEntryCount(ExtendedOperation): request_name: str response_name: str - request_value: Any + request_value: LDAPDN response_attribute: str def config(self) -> None: ... - def __init__(self, connection, partition_dn, controls: Any | None = ...) -> None: ... + def __init__(self, connection, partition_dn, controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/replicaInfo.pyi b/stubs/ldap3/ldap3/extend/novell/replicaInfo.pyi index 6a4358053..a9405d21d 100644 --- a/stubs/ldap3/ldap3/extend/novell/replicaInfo.pyi +++ b/stubs/ldap3/ldap3/extend/novell/replicaInfo.pyi @@ -1,12 +1,13 @@ -from typing import Any +from _typeshed import Incomplete +from ...protocol.novell import ReplicaInfoRequestValue from ..operation import ExtendedOperation class ReplicaInfo(ExtendedOperation): request_name: str response_name: str - request_value: Any + request_value: ReplicaInfoRequestValue response_attribute: str def config(self) -> None: ... - def __init__(self, connection, server_dn, partition_dn, controls: Any | None = ...) -> None: ... + def __init__(self, connection, server_dn, partition_dn, controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/novell/startTransaction.pyi b/stubs/ldap3/ldap3/extend/novell/startTransaction.pyi index 74dd78c5c..e013b81a2 100644 --- a/stubs/ldap3/ldap3/extend/novell/startTransaction.pyi +++ b/stubs/ldap3/ldap3/extend/novell/startTransaction.pyi @@ -1,14 +1,15 @@ -from typing import Any +from _typeshed import Incomplete from ...extend.operation import ExtendedOperation +from ...protocol.novell import CreateGroupTypeRequestValue, CreateGroupTypeResponseValue class StartTransaction(ExtendedOperation): request_name: str response_name: str - request_value: Any - asn1_spec: Any + request_value: CreateGroupTypeRequestValue + asn1_spec: CreateGroupTypeResponseValue def config(self) -> None: ... - def __init__(self, connection, controls: Any | None = ...) -> None: ... + def __init__(self, connection, controls: Incomplete | None = ...) -> None: ... def populate_result(self) -> None: ... - response_value: Any + response_value: Incomplete def set_response(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/operation.pyi b/stubs/ldap3/ldap3/extend/operation.pyi index 4b14b4b53..e07b81421 100644 --- a/stubs/ldap3/ldap3/extend/operation.pyi +++ b/stubs/ldap3/ldap3/extend/operation.pyi @@ -1,19 +1,21 @@ -from typing import Any +from _typeshed import Incomplete + +from pyasn1.type.base import Asn1Type class ExtendedOperation: - connection: Any - decoded_response: Any - result: Any - asn1_spec: Any - request_name: Any - response_name: Any - request_value: Any - response_value: Any - response_attribute: Any - controls: Any - def __init__(self, connection, controls: Any | None = ...) -> None: ... + connection: Incomplete + decoded_response: Incomplete | None + result: Incomplete | None + asn1_spec: Asn1Type | None + request_name: Incomplete | None + response_name: Incomplete | None + request_value: Asn1Type | None + response_value: Incomplete | None + response_attribute: Incomplete | None + controls: Incomplete + def __init__(self, connection, controls: Incomplete | None = ...) -> None: ... def send(self): ... def populate_result(self) -> None: ... - def decode_response(self, response: Any | None = ...) -> None: ... + def decode_response(self, response: Incomplete | None = ...) -> None: ... def set_response(self) -> None: ... def config(self) -> None: ... diff --git a/stubs/ldap3/ldap3/extend/standard/modifyPassword.pyi b/stubs/ldap3/ldap3/extend/standard/modifyPassword.pyi index 5df4b6d1e..37698dcee 100644 --- a/stubs/ldap3/ldap3/extend/standard/modifyPassword.pyi +++ b/stubs/ldap3/ldap3/extend/standard/modifyPassword.pyi @@ -1,21 +1,22 @@ -from typing import Any +from _typeshed import Incomplete from ...extend.operation import ExtendedOperation +from ...protocol.rfc3062 import PasswdModifyRequestValue, PasswdModifyResponseValue class ModifyPassword(ExtendedOperation): request_name: str - request_value: Any - asn1_spec: Any + request_value: PasswdModifyRequestValue + asn1_spec: PasswdModifyResponseValue response_attribute: str def config(self) -> None: ... def __init__( self, connection, - user: Any | None = ..., - old_password: Any | None = ..., - new_password: Any | None = ..., - hash_algorithm: Any | None = ..., - salt: Any | None = ..., - controls: Any | None = ..., + user: Incomplete | None = ..., + old_password: Incomplete | None = ..., + new_password: Incomplete | None = ..., + hash_algorithm: Incomplete | None = ..., + salt: Incomplete | None = ..., + controls: Incomplete | None = ..., ) -> None: ... def populate_result(self) -> None: ... diff --git a/stubs/ldap3/ldap3/operation/extended.pyi b/stubs/ldap3/ldap3/operation/extended.pyi index 2cc46be69..470849ed2 100644 --- a/stubs/ldap3/ldap3/operation/extended.pyi +++ b/stubs/ldap3/ldap3/operation/extended.pyi @@ -1,6 +1,12 @@ -from typing import Any +from _typeshed import ReadableBuffer -def extended_operation(request_name, request_value: Any | None = ..., no_encode: Any | None = ...): ... +from pyasn1.type.base import Asn1Item + +from ..protocol.rfc4511 import ExtendedRequest + +def extended_operation( + request_name, request_value: Asn1Item | ReadableBuffer | None = ..., no_encode: bool | None = ... +) -> ExtendedRequest: ... def extended_request_to_dict(request): ... def extended_response_to_dict(response): ... def intermediate_response_to_dict(response): ... diff --git a/stubs/ldap3/ldap3/protocol/microsoft.pyi b/stubs/ldap3/ldap3/protocol/microsoft.pyi index 2200343b2..c2961a7d5 100644 --- a/stubs/ldap3/ldap3/protocol/microsoft.pyi +++ b/stubs/ldap3/ldap3/protocol/microsoft.pyi @@ -1,25 +1,22 @@ -from typing import Any -from typing_extensions import TypeAlias +from pyasn1.type.namedtype import NamedTypes +from pyasn1.type.tag import TagSet +from pyasn1.type.univ import Sequence -# Enable when pyasn1 gets stubs: -# from pyasn1.type.univ import Sequence -_Sequence: TypeAlias = Any +class SicilyBindResponse(Sequence): + tagSet: TagSet + componentType: NamedTypes -class SicilyBindResponse(_Sequence): - tagSet: Any - componentType: Any +class DirSyncControlRequestValue(Sequence): + componentType: NamedTypes -class DirSyncControlRequestValue(_Sequence): - componentType: Any +class DirSyncControlResponseValue(Sequence): + componentType: NamedTypes -class DirSyncControlResponseValue(_Sequence): - componentType: Any +class SdFlags(Sequence): + componentType: NamedTypes -class SdFlags(_Sequence): - componentType: Any - -class ExtendedDN(_Sequence): - componentType: Any +class ExtendedDN(Sequence): + componentType: NamedTypes def dir_sync_control(criticality, object_security, ancestors_first, public_data_only, incremental_values, max_length, cookie): ... def extended_dn_control(criticality: bool = ..., hex_format: bool = ...): ... diff --git a/stubs/ldap3/ldap3/protocol/novell.pyi b/stubs/ldap3/ldap3/protocol/novell.pyi index 60c5c913a..bfa4a1cdc 100644 --- a/stubs/ldap3/ldap3/protocol/novell.pyi +++ b/stubs/ldap3/ldap3/protocol/novell.pyi @@ -1,73 +1,67 @@ -from typing import Any -from typing_extensions import TypeAlias - -# Enable when pyasn1 gets stubs: -# from pyasn1.type.univ import Integer, OctetString, Sequence, SequenceOf -_Integer: TypeAlias = Any -_OctetString: TypeAlias = Any -_Sequence: TypeAlias = Any -_SequenceOf: TypeAlias = Any +from pyasn1.type.namedtype import NamedTypes +from pyasn1.type.tag import TagSet +from pyasn1.type.univ import Integer, OctetString, Sequence, SequenceOf NMAS_LDAP_EXT_VERSION: int -class Identity(_OctetString): +class Identity(OctetString): encoding: str -class LDAPDN(_OctetString): - tagSet: Any +class LDAPDN(OctetString): + tagSet: TagSet encoding: str -class Password(_OctetString): - tagSet: Any +class Password(OctetString): + tagSet: TagSet encoding: str -class LDAPOID(_OctetString): - tagSet: Any +class LDAPOID(OctetString): + tagSet: TagSet encoding: str -class GroupCookie(_Integer): - tagSet: Any +class GroupCookie(Integer): + tagSet: TagSet -class NmasVer(_Integer): - tagSet: Any +class NmasVer(Integer): + tagSet: TagSet -class Error(_Integer): - tagSet: Any +class Error(Integer): + tagSet: TagSet -class NmasGetUniversalPasswordRequestValue(_Sequence): - componentType: Any +class NmasGetUniversalPasswordRequestValue(Sequence): + componentType: NamedTypes -class NmasGetUniversalPasswordResponseValue(_Sequence): - componentType: Any +class NmasGetUniversalPasswordResponseValue(Sequence): + componentType: NamedTypes -class NmasSetUniversalPasswordRequestValue(_Sequence): - componentType: Any +class NmasSetUniversalPasswordRequestValue(Sequence): + componentType: NamedTypes -class NmasSetUniversalPasswordResponseValue(_Sequence): - componentType: Any +class NmasSetUniversalPasswordResponseValue(Sequence): + componentType: NamedTypes -class ReplicaList(_SequenceOf): - componentType: Any +class ReplicaList(SequenceOf): + componentType: OctetString # type: ignore[assignment] -class ReplicaInfoRequestValue(_Sequence): - tagSet: Any - componentType: Any +class ReplicaInfoRequestValue(Sequence): + tagSet: TagSet + componentType: NamedTypes -class ReplicaInfoResponseValue(_Sequence): - tagSet: Any - componentType: Any +class ReplicaInfoResponseValue(Sequence): + tagSet: TagSet + componentType: NamedTypes -class CreateGroupTypeRequestValue(_Sequence): - componentType: Any +class CreateGroupTypeRequestValue(Sequence): + componentType: NamedTypes -class CreateGroupTypeResponseValue(_Sequence): - componentType: Any +class CreateGroupTypeResponseValue(Sequence): + componentType: NamedTypes -class EndGroupTypeRequestValue(_Sequence): - componentType: Any +class EndGroupTypeRequestValue(Sequence): + componentType: NamedTypes -class EndGroupTypeResponseValue(_Sequence): - componentType: Any +class EndGroupTypeResponseValue(Sequence): + componentType: NamedTypes -class GroupingControlValue(_Sequence): - componentType: Any +class GroupingControlValue(Sequence): + componentType: NamedTypes diff --git a/stubs/ldap3/ldap3/protocol/persistentSearch.pyi b/stubs/ldap3/ldap3/protocol/persistentSearch.pyi index 3d19c087d..c584d4070 100644 --- a/stubs/ldap3/ldap3/protocol/persistentSearch.pyi +++ b/stubs/ldap3/ldap3/protocol/persistentSearch.pyi @@ -1,18 +1,14 @@ -from typing import Any -from typing_extensions import TypeAlias +from pyasn1.type.namedtype import NamedTypes +from pyasn1.type.namedval import NamedValues +from pyasn1.type.univ import Enumerated, Sequence -# Enable when pyasn1 gets stubs: -# from pyasn1.type.univ import Enumerated, Sequence -_Enumerated: TypeAlias = Any -_Sequence: TypeAlias = Any +class PersistentSearchControl(Sequence): + componentType: NamedTypes -class PersistentSearchControl(_Sequence): - componentType: Any +class ChangeType(Enumerated): + namedValues: NamedValues -class ChangeType(_Enumerated): - namedValues: Any - -class EntryChangeNotificationControl(_Sequence): - componentType: Any +class EntryChangeNotificationControl(Sequence): + componentType: NamedTypes def persistent_search_control(change_types, changes_only: bool = ..., return_ecs: bool = ..., criticality: bool = ...): ... diff --git a/stubs/ldap3/ldap3/protocol/rfc2696.pyi b/stubs/ldap3/ldap3/protocol/rfc2696.pyi index c131194a6..28159c273 100644 --- a/stubs/ldap3/ldap3/protocol/rfc2696.pyi +++ b/stubs/ldap3/ldap3/protocol/rfc2696.pyi @@ -1,22 +1,20 @@ -from typing import Any -from typing_extensions import TypeAlias +from _typeshed import Incomplete +from typing_extensions import Final -# Enable when pyasn1 gets stubs: -# from pyasn1.type.univ import Integer, OctetString, Sequence -_Integer: TypeAlias = Any -_OctetString: TypeAlias = Any -_Sequence: TypeAlias = Any +from pyasn1.type.constraint import ConstraintsIntersection, ValueRangeConstraint +from pyasn1.type.namedtype import NamedTypes +from pyasn1.type.univ import Integer, OctetString, Sequence -MAXINT: Any -rangeInt0ToMaxConstraint: Any +MAXINT: Final[Integer] +rangeInt0ToMaxConstraint: ValueRangeConstraint -class Integer0ToMax(_Integer): - subtypeSpec: Any +class Integer0ToMax(Integer): + subtypeSpec: ConstraintsIntersection class Size(Integer0ToMax): ... -class Cookie(_OctetString): ... +class Cookie(OctetString): ... -class RealSearchControlValue(_Sequence): - componentType: Any +class RealSearchControlValue(Sequence): + componentType: NamedTypes -def paged_search_control(criticality: bool = ..., size: int = ..., cookie: Any | None = ...): ... +def paged_search_control(criticality: bool = ..., size: int = ..., cookie: Incomplete | None = ...): ... diff --git a/stubs/ldap3/ldap3/protocol/rfc3062.pyi b/stubs/ldap3/ldap3/protocol/rfc3062.pyi index 7076147ce..4a97a374a 100644 --- a/stubs/ldap3/ldap3/protocol/rfc3062.pyi +++ b/stubs/ldap3/ldap3/protocol/rfc3062.pyi @@ -1,29 +1,25 @@ -from typing import Any -from typing_extensions import TypeAlias +from pyasn1.type.namedtype import NamedTypes +from pyasn1.type.tag import TagSet +from pyasn1.type.univ import OctetString, Sequence -# Enable when pyasn1 gets stubs: -# from pyasn1.type.univ import OctetString, Sequence -_OctetString: TypeAlias = Any -_Sequence: TypeAlias = Any - -class UserIdentity(_OctetString): - tagSet: Any +class UserIdentity(OctetString): + tagSet: TagSet encoding: str -class OldPasswd(_OctetString): - tagSet: Any +class OldPasswd(OctetString): + tagSet: TagSet encoding: str -class NewPasswd(_OctetString): - tagSet: Any +class NewPasswd(OctetString): + tagSet: TagSet encoding: str -class GenPasswd(_OctetString): - tagSet: Any +class GenPasswd(OctetString): + tagSet: TagSet encoding: str -class PasswdModifyRequestValue(_Sequence): - componentType: Any +class PasswdModifyRequestValue(Sequence): + componentType: NamedTypes -class PasswdModifyResponseValue(_Sequence): - componentType: Any +class PasswdModifyResponseValue(Sequence): + componentType: NamedTypes diff --git a/stubs/ldap3/ldap3/protocol/rfc4511.pyi b/stubs/ldap3/ldap3/protocol/rfc4511.pyi index 070910ae3..b673e6743 100644 --- a/stubs/ldap3/ldap3/protocol/rfc4511.pyi +++ b/stubs/ldap3/ldap3/protocol/rfc4511.pyi @@ -1,32 +1,28 @@ -from typing import Any as _Any +# Alias the import to avoid name clash with a class called "Final" +from typing_extensions import Final as _Final -# Enable when pyasn1 gets stubs: -# from pyasn1.type.univ import Boolean, Choice, Enumerated, Integer, Null, OctetString, Sequence, SequenceOf, SetOf -Boolean = _Any -Choice = _Any -Enumerated = _Any -Integer = _Any -Null = _Any -OctetString = _Any -Sequence = _Any -SequenceOf = _Any -SetOf = _Any +from pyasn1.type.constraint import ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint +from pyasn1.type.namedtype import NamedTypes +from pyasn1.type.namedval import NamedValues +from pyasn1.type.tag import TagSet +from pyasn1.type.univ import Boolean, Choice, Enumerated, Integer, Null, OctetString, Sequence, SequenceOf, SetOf -LDAP_MAX_INT: int -MAXINT: _Any -rangeInt0ToMaxConstraint: _Any -rangeInt1To127Constraint: _Any -size1ToMaxConstraint: _Any -responseValueConstraint: _Any -numericOIDConstraint: _Any -distinguishedNameConstraint: _Any -nameComponentConstraint: _Any -attributeDescriptionConstraint: _Any -uriConstraint: _Any -attributeSelectorConstraint: _Any +LDAP_MAX_INT: _Final = 2147483647 +MAXINT: _Final[Integer] +rangeInt0ToMaxConstraint: ValueRangeConstraint +rangeInt1To127Constraint: ValueRangeConstraint +size1ToMaxConstraint: ValueSizeConstraint +responseValueConstraint: SingleValueConstraint +# Custom constraints. They have yet to be implemented so ldap3 keeps them as None. +numericOIDConstraint: None +distinguishedNameConstraint: None +nameComponentConstraint: None +attributeDescriptionConstraint: None +uriConstraint: None +attributeSelectorConstraint: None class Integer0ToMax(Integer): - subtypeSpec: _Any + subtypeSpec: ConstraintsIntersection class LDAPString(OctetString): encoding: str @@ -44,71 +40,71 @@ class AssertionValue(OctetString): encoding: str class AttributeValueAssertion(Sequence): - componentType: _Any + componentType: NamedTypes class MatchingRuleId(LDAPString): ... class Vals(SetOf): - componentType: _Any + componentType: AttributeValue # type: ignore[assignment] class ValsAtLeast1(SetOf): - componentType: _Any - subtypeSpec: _Any + componentType: AttributeValue # type: ignore[assignment] + subtypeSpec: ConstraintsIntersection class PartialAttribute(Sequence): - componentType: _Any + componentType: NamedTypes class Attribute(Sequence): - componentType: _Any + componentType: NamedTypes class AttributeList(SequenceOf): - componentType: _Any + componentType: Attribute # type: ignore[assignment] class Simple(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class Credentials(OctetString): encoding: str class SaslCredentials(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class SicilyPackageDiscovery(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class SicilyNegotiate(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class SicilyResponse(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class AuthenticationChoice(Choice): - componentType: _Any + componentType: NamedTypes class Version(Integer): - subtypeSpec: _Any + subtypeSpec: ConstraintsIntersection class ResultCode(Enumerated): - namedValues: _Any - subTypeSpec: _Any + namedValues: NamedValues + subTypeSpec: ConstraintsIntersection class URI(LDAPString): ... class Referral(SequenceOf): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: URI # type: ignore[assignment] class ServerSaslCreds(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class LDAPResult(Sequence): - componentType: _Any + componentType: NamedTypes class Criticality(Boolean): defaultValue: bool @@ -117,207 +113,209 @@ class ControlValue(OctetString): encoding: str class Control(Sequence): - componentType: _Any + componentType: NamedTypes class Controls(SequenceOf): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: Control # type: ignore[assignment] class Scope(Enumerated): - namedValues: _Any + namedValues: NamedValues class DerefAliases(Enumerated): - namedValues: _Any + namedValues: NamedValues class TypesOnly(Boolean): ... class Selector(LDAPString): ... class AttributeSelection(SequenceOf): - componentType: _Any + componentType: Selector # type: ignore[assignment] class MatchingRule(MatchingRuleId): - tagSet: _Any + tagSet: TagSet class Type(AttributeDescription): - tagSet: _Any + tagSet: TagSet class MatchValue(AssertionValue): - tagSet: _Any + tagSet: TagSet class DnAttributes(Boolean): - tagSet: _Any - defaultValue: _Any + tagSet: TagSet + defaultValue: Boolean class MatchingRuleAssertion(Sequence): - componentType: _Any + componentType: NamedTypes class Initial(AssertionValue): - tagSet: _Any + tagSet: TagSet class Any(AssertionValue): - tagSet: _Any + tagSet: TagSet class Final(AssertionValue): - tagSet: _Any + tagSet: TagSet class Substring(Choice): - componentType: _Any + componentType: NamedTypes class Substrings(SequenceOf): - subtypeSpec: _Any - componentType: _Any + subtypeSpec: ConstraintsIntersection + componentType: Substring # type: ignore[assignment] class SubstringFilter(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class And(SetOf): - tagSet: _Any - subtypeSpec: _Any + tagSet: TagSet + subtypeSpec: ConstraintsIntersection + componentType: Filter # type: ignore[assignment] class Or(SetOf): - tagSet: _Any - subtypeSpec: _Any + tagSet: TagSet + subtypeSpec: ConstraintsIntersection + componentType: Filter # type: ignore[assignment] class Not(Choice): ... class EqualityMatch(AttributeValueAssertion): - tagSet: _Any + tagSet: TagSet class GreaterOrEqual(AttributeValueAssertion): - tagSet: _Any + tagSet: TagSet class LessOrEqual(AttributeValueAssertion): - tagSet: _Any + tagSet: TagSet class Present(AttributeDescription): - tagSet: _Any + tagSet: TagSet class ApproxMatch(AttributeValueAssertion): - tagSet: _Any + tagSet: TagSet class ExtensibleMatch(MatchingRuleAssertion): - tagSet: _Any + tagSet: TagSet class Filter(Choice): - componentType: _Any + componentType: NamedTypes class PartialAttributeList(SequenceOf): - componentType: _Any + componentType: PartialAttribute # type: ignore[assignment] class Operation(Enumerated): - namedValues: _Any + namedValues: NamedValues class Change(Sequence): - componentType: _Any + componentType: NamedTypes class Changes(SequenceOf): - componentType: _Any + componentType: Change # type: ignore[assignment] class DeleteOldRDN(Boolean): ... class NewSuperior(LDAPDN): - tagSet: _Any + tagSet: TagSet class RequestName(LDAPOID): - tagSet: _Any + tagSet: TagSet class RequestValue(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class ResponseName(LDAPOID): - tagSet: _Any + tagSet: TagSet class ResponseValue(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class IntermediateResponseName(LDAPOID): - tagSet: _Any + tagSet: TagSet class IntermediateResponseValue(OctetString): - tagSet: _Any + tagSet: TagSet encoding: str class BindRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class BindResponse(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class UnbindRequest(Null): - tagSet: _Any + tagSet: TagSet class SearchRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class SearchResultReference(SequenceOf): - tagSet: _Any - subtypeSpec: _Any - componentType: _Any + tagSet: TagSet + subtypeSpec: ConstraintsIntersection + componentType: URI # type: ignore[assignment] class SearchResultEntry(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class SearchResultDone(LDAPResult): - tagSet: _Any + tagSet: TagSet class ModifyRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class ModifyResponse(LDAPResult): - tagSet: _Any + tagSet: TagSet class AddRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class AddResponse(LDAPResult): - tagSet: _Any + tagSet: TagSet class DelRequest(LDAPDN): - tagSet: _Any + tagSet: TagSet class DelResponse(LDAPResult): - tagSet: _Any + tagSet: TagSet class ModifyDNRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class ModifyDNResponse(LDAPResult): - tagSet: _Any + tagSet: TagSet class CompareRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class CompareResponse(LDAPResult): - tagSet: _Any + tagSet: TagSet class AbandonRequest(MessageID): - tagSet: _Any + tagSet: TagSet class ExtendedRequest(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class ExtendedResponse(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class IntermediateResponse(Sequence): - tagSet: _Any - componentType: _Any + tagSet: TagSet + componentType: NamedTypes class ProtocolOp(Choice): - componentType: _Any + componentType: NamedTypes class LDAPMessage(Sequence): - componentType: _Any + componentType: NamedTypes diff --git a/stubs/ldap3/ldap3/utils/asn1.pyi b/stubs/ldap3/ldap3/utils/asn1.pyi index 6af8d2c53..811397e7e 100644 --- a/stubs/ldap3/ldap3/utils/asn1.pyi +++ b/stubs/ldap3/ldap3/utils/asn1.pyi @@ -1,37 +1,48 @@ -from typing import Any -from typing_extensions import TypeAlias +from _typeshed import Incomplete, IndexableBuffer, SliceableBuffer +from collections.abc import Callable, Mapping +from typing import Any, TypeVar, overload +from typing_extensions import Final, TypeAlias -# Enable when pyasn1 gets stubs: -# from pyasn1.codec.ber.encoder import AbstractItemEncoder -_AbstractItemEncoder: TypeAlias = Any +from pyasn1.codec.ber.encoder import AbstractItemEncoder -CLASSES: Any +# Use _typeshed._SupportsGetItemBuffer after PEP 688 +_SupportsGetItemBuffer: TypeAlias = SliceableBuffer | IndexableBuffer +_Unused: TypeAlias = object +_R = TypeVar("_R") +_B = TypeVar("_B", bound=_SupportsGetItemBuffer) +# The possible return type is a union of all other decode methods, ie: AnyOf[Incomplete | bool] +_AllDecodersReturnType: TypeAlias = Any -class LDAPBooleanEncoder(_AbstractItemEncoder): +CLASSES: Final[dict[tuple[bool, bool], int]] + +class LDAPBooleanEncoder(AbstractItemEncoder): supportIndefLenMode: bool # Requires pyasn1 > 0.3.7 - def encodeValue(self, value, asn1Spec, encodeFun, **options): ... - -customTagMap: Any -customTypeMap: Any + def encodeValue(self, value: bool | int, asn1Spec: _Unused, encodeFun: _Unused, **options: _Unused): ... def compute_ber_size(data): ... def decode_message_fast(message): ... -def decode_sequence(message, start, stop, context_decoders: Any | None = ...): ... -def decode_integer(message, start, stop, context_decoders: Any | None = ...): ... -def decode_octet_string(message, start, stop, context_decoders: Any | None = ...): ... -def decode_boolean(message, start, stop, context_decoders: Any | None = ...): ... -def decode_bind_response(message, start, stop, context_decoders: Any | None = ...): ... -def decode_extended_response(message, start, stop, context_decoders: Any | None = ...): ... -def decode_intermediate_response(message, start, stop, context_decoders: Any | None = ...): ... -def decode_controls(message, start, stop, context_decoders: Any | None = ...): ... +@overload +def decode_sequence(message: _B, start: int, stop: int, context_decoders: Mapping[int, Callable[[_B, int, int], _R]]) -> _R: ... +@overload +def decode_sequence( + message: _SupportsGetItemBuffer, start: int, stop: int, context_decoders: None = ... +) -> _AllDecodersReturnType: ... +def decode_integer(message, start: int, stop: int, context_decoders: _Unused = ...): ... +def decode_octet_string(message, start: int, stop: int, context_decoders: _Unused = ...): ... +def decode_boolean(message, start: int, stop: int, context_decoders: _Unused = ...): ... +def decode_bind_response(message, start: int, stop: int, context_decoders: _Unused = ...): ... +def decode_extended_response(message, start: int, stop: int, context_decoders: _Unused = ...): ... +def decode_intermediate_response(message, start: int, stop: int, context_decoders: _Unused = ...): ... +def decode_controls(message, start: int, stop: int, context_decoders: _Unused = ...): ... def ldap_result_to_dict_fast(response): ... def get_byte(x): ... def get_bytes(x): ... -DECODERS: Any -BIND_RESPONSE_CONTEXT: Any -EXTENDED_RESPONSE_CONTEXT: Any -INTERMEDIATE_RESPONSE_CONTEXT: Any -LDAP_MESSAGE_CONTEXT: Any -CONTROLS_CONTEXT: Any +# The possible return type is a union of all other decode methods, ie: AnyOf[Incomplete | bool] +DECODERS: dict[tuple[int, int], Callable[..., _AllDecodersReturnType]] +BIND_RESPONSE_CONTEXT: dict[int, Callable[..., Incomplete]] +EXTENDED_RESPONSE_CONTEXT: dict[int, Callable[..., Incomplete]] +INTERMEDIATE_RESPONSE_CONTEXT: dict[int, Callable[..., Incomplete]] +LDAP_MESSAGE_CONTEXT: dict[int, Callable[..., Incomplete]] +CONTROLS_CONTEXT: dict[int, Callable[..., Incomplete]]