Skip to content

Commit be52954

Browse files
authored
Improve passlib.apache (#13689)
1 parent 5bb9409 commit be52954

2 files changed

Lines changed: 85 additions & 40 deletions

File tree

stubs/passlib/@tests/stubtest_allowlist.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ passlib.tests.*
9595
# was dropped from the standard library of Python 3.13, but is still available
9696
# in some environments.
9797
(passlib.hosts.host_context)?
98+
99+
# Fields differs at runtime:
100+
passlib.apache._CommonFile.encoding
101+
passlib.apache._CommonFile.return_unicode

stubs/passlib/passlib/apache.pyi

Lines changed: 81 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,100 @@
1-
from _typeshed import Incomplete
2-
from typing import Any
1+
from typing_extensions import Self
2+
3+
from .context import CryptContext
4+
from .hash import htdigest
35

46
class _CommonFile:
5-
encoding: Any
6-
return_unicode: Any
7+
encoding: str
8+
return_unicode: bool
79
autosave: bool
810
@classmethod
9-
def from_string(cls, data, **kwds): ...
11+
def from_string(
12+
cls,
13+
data: str | bytes,
14+
*,
15+
new: bool = False,
16+
autoload: bool = True,
17+
autosave: bool = False,
18+
encoding: str = "utf-8",
19+
return_unicode: bool = True,
20+
) -> Self: ...
1021
@classmethod
11-
def from_path(cls, path, **kwds): ...
22+
def from_path(
23+
cls,
24+
path: str,
25+
*,
26+
new: bool = False,
27+
autoload: bool = True,
28+
autosave: bool = False,
29+
encoding: str = "utf-8",
30+
return_unicode: bool = True,
31+
) -> Self: ...
1232
def __init__(
1333
self,
14-
path: Incomplete | None = None,
34+
path: str | None = None,
1535
new: bool = False,
1636
autoload: bool = True,
1737
autosave: bool = False,
1838
encoding: str = "utf-8",
19-
return_unicode=True,
39+
return_unicode: bool = True,
2040
) -> None: ...
2141
@property
22-
def path(self): ...
42+
def path(self) -> str: ...
2343
@path.setter
24-
def path(self, value) -> None: ...
44+
def path(self, value: str) -> None: ...
2545
@property
26-
def mtime(self): ...
27-
def load_if_changed(self): ...
28-
def load(self, path: Incomplete | None = None, force: bool = True): ...
29-
def load_string(self, data) -> None: ...
30-
def save(self, path: Incomplete | None = None) -> None: ...
31-
def to_string(self): ...
46+
def mtime(self) -> float: ...
47+
def load_if_changed(self) -> bool: ...
48+
def load(self, path: str | None = None, force: bool = True) -> bool: ...
49+
def load_string(self, data: str | bytes) -> None: ...
50+
def save(self, path: str | None = None) -> None: ...
51+
def to_string(self) -> bytes: ...
3252

3353
class HtpasswdFile(_CommonFile):
34-
context: Any
35-
def __init__(self, path: Incomplete | None = None, default_scheme: Incomplete | None = None, context=..., **kwds) -> None: ...
36-
def users(self): ...
37-
def set_password(self, user, password): ...
38-
def update(self, user, password): ...
39-
def get_hash(self, user): ...
40-
def set_hash(self, user, hash): ...
41-
def find(self, user): ...
42-
def delete(self, user): ...
43-
def check_password(self, user, password): ...
44-
def verify(self, user, password): ...
54+
context: CryptContext
55+
def __init__(
56+
self,
57+
path: str | None = None,
58+
default_scheme: str | None = None,
59+
context: CryptContext = ...,
60+
*,
61+
new: bool = False,
62+
autoload: bool = True,
63+
autosave: bool = False,
64+
encoding: str = "utf-8",
65+
return_unicode: bool = True,
66+
) -> None: ...
67+
def users(self) -> list[str | bytes]: ...
68+
def set_password(self, user: str, password: str | bytes) -> bool: ...
69+
def update(self, user: str, password: str | bytes) -> bool: ...
70+
def get_hash(self, user: str) -> bytes | None: ...
71+
def set_hash(self, user: str, hash: str | bytes) -> bool: ...
72+
def find(self, user: str) -> bytes | None: ...
73+
def delete(self, user: str) -> bool: ...
74+
def check_password(self, user: str, password: str | bytes) -> bool | None: ...
75+
def verify(self, user: str, password: str | bytes) -> bool | None: ...
4576

4677
class HtdigestFile(_CommonFile):
47-
default_realm: Any
48-
def __init__(self, path: Incomplete | None = None, default_realm: Incomplete | None = None, **kwds) -> None: ...
49-
def realms(self): ...
50-
def users(self, realm: Incomplete | None = None): ...
51-
def set_password(self, user, realm: Incomplete | None = None, password=...): ...
52-
def update(self, user, realm, password): ...
53-
def get_hash(self, user, realm: Incomplete | None = None): ...
54-
def set_hash(self, user, realm: Incomplete | None = None, hash=...): ...
55-
def find(self, user, realm): ...
56-
def delete(self, user, realm: Incomplete | None = None): ...
57-
def delete_realm(self, realm): ...
58-
def check_password(self, user, realm: Incomplete | None = None, password=...): ...
59-
def verify(self, user, realm, password): ...
78+
default_realm: str | None
79+
def __init__(
80+
self,
81+
path: str | None = None,
82+
default_realm: str | None = None,
83+
*,
84+
new: bool = False,
85+
autoload: bool = True,
86+
autosave: bool = False,
87+
encoding: str = "utf-8",
88+
return_unicode: bool = True,
89+
) -> None: ...
90+
def realms(self) -> list[str | bytes]: ...
91+
def users(self, realm: str | None = None) -> list[str | bytes]: ...
92+
def set_password(self, user: str, realm: str | None = None, password: str | bytes = ...) -> bool: ...
93+
def update(self, user: str, realm: str | None, password: str | bytes) -> bool: ...
94+
def get_hash(self, user: str, realm: str | None = None) -> htdigest | None: ...
95+
def set_hash(self, user: str, realm: str | None = None, hash: str | bytes = ...) -> bool: ...
96+
def find(self, user: str, realm: str | None) -> htdigest | None: ...
97+
def delete(self, user: str, realm: str | None = None) -> bool: ...
98+
def delete_realm(self, realm: str | None) -> int: ...
99+
def check_password(self, user: str, realm: str | None = None, password: str | bytes = ...) -> bool | None: ...
100+
def verify(self, user: str, realm: str | None, password: str | bytes) -> bool | None: ...

0 commit comments

Comments
 (0)