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.apache #13689

Merged
merged 4 commits into from
Mar 21, 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
4 changes: 4 additions & 0 deletions stubs/passlib/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ passlib.tests.*
# was dropped from the standard library of Python 3.13, but is still available
# in some environments.
(passlib.hosts.host_context)?

# Fields differs at runtime:
passlib.apache._CommonFile.encoding
passlib.apache._CommonFile.return_unicode
121 changes: 81 additions & 40 deletions stubs/passlib/passlib/apache.pyi
Original file line number Diff line number Diff line change
@@ -1,59 +1,100 @@
from _typeshed import Incomplete
from typing import Any
from typing_extensions import Self

from .context import CryptContext
from .hash import htdigest

class _CommonFile:
encoding: Any
return_unicode: Any
encoding: str
return_unicode: bool
autosave: bool
@classmethod
def from_string(cls, data, **kwds): ...
def from_string(
cls,
data: str | bytes,
*,
new: bool = False,
autoload: bool = True,
autosave: bool = False,
encoding: str = "utf-8",
return_unicode: bool = True,
) -> Self: ...
@classmethod
def from_path(cls, path, **kwds): ...
def from_path(
cls,
path: str,
*,
new: bool = False,
autoload: bool = True,
autosave: bool = False,
encoding: str = "utf-8",
return_unicode: bool = True,
) -> Self: ...
def __init__(
self,
path: Incomplete | None = None,
path: str | None = None,
new: bool = False,
autoload: bool = True,
autosave: bool = False,
encoding: str = "utf-8",
return_unicode=True,
return_unicode: bool = True,
) -> None: ...
@property
def path(self): ...
def path(self) -> str: ...
@path.setter
def path(self, value) -> None: ...
def path(self, value: str) -> None: ...
@property
def mtime(self): ...
def load_if_changed(self): ...
def load(self, path: Incomplete | None = None, force: bool = True): ...
def load_string(self, data) -> None: ...
def save(self, path: Incomplete | None = None) -> None: ...
def to_string(self): ...
def mtime(self) -> float: ...
def load_if_changed(self) -> bool: ...
def load(self, path: str | None = None, force: bool = True) -> bool: ...
def load_string(self, data: str | bytes) -> None: ...
def save(self, path: str | None = None) -> None: ...
def to_string(self) -> bytes: ...

class HtpasswdFile(_CommonFile):
context: Any
def __init__(self, path: Incomplete | None = None, default_scheme: Incomplete | None = None, context=..., **kwds) -> None: ...
def users(self): ...
def set_password(self, user, password): ...
def update(self, user, password): ...
def get_hash(self, user): ...
def set_hash(self, user, hash): ...
def find(self, user): ...
def delete(self, user): ...
def check_password(self, user, password): ...
def verify(self, user, password): ...
context: CryptContext
def __init__(
self,
path: str | None = None,
default_scheme: str | None = None,
context: CryptContext = ...,
*,
new: bool = False,
autoload: bool = True,
autosave: bool = False,
encoding: str = "utf-8",
return_unicode: bool = True,
) -> None: ...
def users(self) -> list[str | bytes]: ...
def set_password(self, user: str, password: str | bytes) -> bool: ...
def update(self, user: str, password: str | bytes) -> bool: ...
def get_hash(self, user: str) -> bytes | None: ...
def set_hash(self, user: str, hash: str | bytes) -> bool: ...
def find(self, user: str) -> bytes | None: ...
def delete(self, user: str) -> bool: ...
def check_password(self, user: str, password: str | bytes) -> bool | None: ...
def verify(self, user: str, password: str | bytes) -> bool | None: ...

class HtdigestFile(_CommonFile):
default_realm: Any
def __init__(self, path: Incomplete | None = None, default_realm: Incomplete | None = None, **kwds) -> None: ...
def realms(self): ...
def users(self, realm: Incomplete | None = None): ...
def set_password(self, user, realm: Incomplete | None = None, password=...): ...
def update(self, user, realm, password): ...
def get_hash(self, user, realm: Incomplete | None = None): ...
def set_hash(self, user, realm: Incomplete | None = None, hash=...): ...
def find(self, user, realm): ...
def delete(self, user, realm: Incomplete | None = None): ...
def delete_realm(self, realm): ...
def check_password(self, user, realm: Incomplete | None = None, password=...): ...
def verify(self, user, realm, password): ...
default_realm: str | None
def __init__(
self,
path: str | None = None,
default_realm: str | None = None,
*,
new: bool = False,
autoload: bool = True,
autosave: bool = False,
encoding: str = "utf-8",
return_unicode: bool = True,
) -> None: ...
def realms(self) -> list[str | bytes]: ...
def users(self, realm: str | None = None) -> list[str | bytes]: ...
def set_password(self, user: str, realm: str | None = None, password: str | bytes = ...) -> bool: ...
def update(self, user: str, realm: str | None, password: str | bytes) -> bool: ...
def get_hash(self, user: str, realm: str | None = None) -> htdigest | None: ...
def set_hash(self, user: str, realm: str | None = None, hash: str | bytes = ...) -> bool: ...
def find(self, user: str, realm: str | None) -> htdigest | None: ...
def delete(self, user: str, realm: str | None = None) -> bool: ...
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: ...