Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve passlib.win32 #13711

Merged
merged 3 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stubs/passlib/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ passlib.utils.decor.__all__
passlib.utils.handlers.__all__
passlib.utils.md4.__all__
passlib.utils.pbkdf2.__all__
passlib.win32.__all__

# proxy module that uses some import magic incompatible with stubtest
passlib.hash
Expand Down
11 changes: 9 additions & 2 deletions stubs/passlib/passlib/handlers/windows.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from typing import Any, ClassVar
from typing import Any, ClassVar, Literal, overload

import passlib.utils.handlers as uh

Expand All @@ -17,8 +17,15 @@ class nthash(uh.StaticHandler):
checksum_size: ClassVar[int]
@classmethod
def raw(cls, secret): ...
@overload
@classmethod
def raw_nthash(cls, secret, hex: bool = False): ...
def raw_nthash(cls, secret: str | bytes, hex: Literal[True]) -> str: ...
@overload
@classmethod
def raw_nthash(cls, secret: str | bytes, hex: Literal[False] = False) -> bytes: ...
@overload
@classmethod
def raw_nthash(cls, secret: str | bytes, hex: bool = False) -> str | bytes: ...

bsd_nthash: Any

Expand Down
17 changes: 13 additions & 4 deletions stubs/passlib/passlib/win32.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from typing import Any
from binascii import hexlify as hexlify
from typing import Final, Literal, overload

from passlib.hash import nthash as nthash
from passlib.handlers.windows import nthash as nthash

raw_nthash: Any
LM_MAGIC: Final[bytes]
raw_nthash = nthash.raw_nthash

def raw_lmhash(secret, encoding: str = "ascii", hex: bool = False): ...
@overload
def raw_lmhash(secret: str | bytes, encoding: str = "ascii", hex: Literal[False] = False) -> bytes: ...
@overload
def raw_lmhash(secret: str | bytes, encoding: str, hex: Literal[True]) -> str: ...
@overload
def raw_lmhash(secret: str | bytes, *, hex: Literal[True]) -> str: ...

__all__ = ["nthash", "raw_lmhash", "raw_nthash"]