From 26d445142f670792e81bc480895dcdc1df09fd24 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Tue, 25 Mar 2025 16:14:03 +0400 Subject: [PATCH] [passlib] Add ___all__, improve passlib.hosts (#13712) --- stubs/passlib/@tests/stubtest_allowlist.txt | 8 +------- stubs/passlib/passlib/apache.pyi | 2 ++ stubs/passlib/passlib/context.pyi | 2 ++ stubs/passlib/passlib/hosts.pyi | 16 +++++++++------- stubs/passlib/passlib/ifc.pyi | 2 ++ stubs/passlib/passlib/pwd.pyi | 2 ++ stubs/passlib/passlib/registry.pyi | 2 ++ stubs/passlib/passlib/totp.pyi | 11 +++++++++++ 8 files changed, 31 insertions(+), 14 deletions(-) diff --git a/stubs/passlib/@tests/stubtest_allowlist.txt b/stubs/passlib/@tests/stubtest_allowlist.txt index fc0d9fa23..f72936065 100644 --- a/stubs/passlib/@tests/stubtest_allowlist.txt +++ b/stubs/passlib/@tests/stubtest_allowlist.txt @@ -1,6 +1,5 @@ # TODO: missing from stub -passlib.apache.__all__ -passlib.context.__all__ +passlib.hosts.__all__ passlib.crypto._blowfish.__all__ passlib.crypto._blowfish.base.__all__ passlib.crypto._blowfish.unrolled.__all__ @@ -28,11 +27,6 @@ passlib.handlers.sha1_crypt.__all__ passlib.handlers.sha2_crypt.__all__ passlib.handlers.sun_md5_crypt.__all__ passlib.handlers.windows.__all__ -passlib.hosts.__all__ -passlib.ifc.__all__ -passlib.pwd.__all__ -passlib.registry.__all__ -passlib.totp.__all__ passlib.utils.binary.__all__ passlib.utils.decor.__all__ passlib.utils.handlers.__all__ diff --git a/stubs/passlib/passlib/apache.pyi b/stubs/passlib/passlib/apache.pyi index 126a0c3a1..f474dee62 100644 --- a/stubs/passlib/passlib/apache.pyi +++ b/stubs/passlib/passlib/apache.pyi @@ -98,3 +98,5 @@ class HtdigestFile(_CommonFile): def delete_realm(self, realm: str | None) -> int: ... def check_password(self, user: str, realm: str | None = None, password: str | bytes = ...) -> bool | None: ... def verify(self, user: str, realm: str | None, password: str | bytes) -> bool | None: ... + +__all__ = ["HtpasswdFile", "HtdigestFile"] diff --git a/stubs/passlib/passlib/context.pyi b/stubs/passlib/passlib/context.pyi index cf853f4f0..0d6521b91 100644 --- a/stubs/passlib/passlib/context.pyi +++ b/stubs/passlib/passlib/context.pyi @@ -85,3 +85,5 @@ class CryptContext: class LazyCryptContext(CryptContext): def __init__(self, schemes: Incomplete | None = None, **kwds) -> None: ... def __getattribute__(self, attr: str) -> Any: ... + +__all__ = ["CryptContext", "LazyCryptContext", "CryptPolicy"] diff --git a/stubs/passlib/passlib/hosts.pyi b/stubs/passlib/passlib/hosts.pyi index 5b365e00e..c07bbc048 100644 --- a/stubs/passlib/passlib/hosts.pyi +++ b/stubs/passlib/passlib/hosts.pyi @@ -1,13 +1,15 @@ import sys -from typing import Any from passlib.context import CryptContext -linux_context: Any -linux2_context: Any -freebsd_context: Any -openbsd_context: Any -netbsd_context: Any +linux_context: CryptContext +linux2_context: CryptContext +freebsd_context: CryptContext +openbsd_context: CryptContext +netbsd_context: CryptContext # Only exists if crypt is present -if sys.version_info < (3, 13): +if sys.version_info < (3, 13) and sys.platform != "win32": host_context: CryptContext + __all__ = ["linux_context", "linux2_context", "openbsd_context", "netbsd_context", "freebsd_context", "host_context"] +else: + __all__ = ["linux_context", "linux2_context", "openbsd_context", "netbsd_context", "freebsd_context"] diff --git a/stubs/passlib/passlib/ifc.pyi b/stubs/passlib/passlib/ifc.pyi index b91cb6993..03e22623f 100644 --- a/stubs/passlib/passlib/ifc.pyi +++ b/stubs/passlib/passlib/ifc.pyi @@ -35,3 +35,5 @@ class DisabledHash(PasswordHash, metaclass=ABCMeta): def disable(cls, hash: str | None = None) -> str: ... @classmethod def enable(cls, hash: str) -> str: ... + +__all__ = ["PasswordHash"] diff --git a/stubs/passlib/passlib/pwd.pyi b/stubs/passlib/passlib/pwd.pyi index b0b4a69c2..a1189c161 100644 --- a/stubs/passlib/passlib/pwd.pyi +++ b/stubs/passlib/passlib/pwd.pyi @@ -138,3 +138,5 @@ def genphrase( sep: str | bytes | None = None, rng: random.Random | None = None, ) -> Iterator[str]: ... + +__all__ = ["genword", "default_charsets", "genphrase", "default_wordsets"] diff --git a/stubs/passlib/passlib/registry.pyi b/stubs/passlib/passlib/registry.pyi index 50b55d1fe..ff1e5d7a2 100644 --- a/stubs/passlib/passlib/registry.pyi +++ b/stubs/passlib/passlib/registry.pyi @@ -13,3 +13,5 @@ def register_crypt_handler( ) -> None: ... # expected handler is object with attr handler.name def get_crypt_handler(name: str, default: Any = ...) -> Any: ... # returns handler or default def list_crypt_handlers(loaded_only: bool = False) -> list[str]: ... + +__all__ = ["register_crypt_handler_path", "register_crypt_handler", "get_crypt_handler", "list_crypt_handlers"] diff --git a/stubs/passlib/passlib/totp.pyi b/stubs/passlib/passlib/totp.pyi index 22bdc4ed8..74096fa25 100644 --- a/stubs/passlib/passlib/totp.pyi +++ b/stubs/passlib/passlib/totp.pyi @@ -146,3 +146,14 @@ class TotpMatch(SequenceMixin): def cache_seconds(self) -> int: ... @property def cache_time(self) -> int: ... + +__all__ = [ + "AppWallet", + "TOTP", + "TokenError", + "MalformedTokenError", + "InvalidTokenError", + "UsedTokenError", + "TotpToken", + "TotpMatch", +]