pykeepass-stubs 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.3
2
+ Name: pykeepass-stubs
3
+ Version: 0.1.0
4
+ Summary: Type stubs for pykeepass
5
+ Author: Kaj Kowalski
6
+ Author-email: Kaj Kowalski <info@kajkowalski.nl>
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Typing :: Stubs Only
14
+ Requires-Dist: pykeepass>=4.1.1.post1,<4.2
15
+ Requires-Dist: types-lxml>=2026.2.16
16
+ Requires-Python: >=3.11
17
+ Project-URL: Issues, https://github.com/kjanat/kp2bw/issues
18
+ Project-URL: Repository, https://github.com/kjanat/kp2bw/tree/master/packages/pykeepass-stubs
19
+ Description-Content-Type: text/markdown
20
+
21
+ # pykeepass-stubs
22
+
23
+ Type stubs for [pykeepass].
24
+
25
+ This is a stub-only distribution that improves type-checking for projects using `pykeepass`.
26
+
27
+ - Target package: `pykeepass`
28
+ - Distribution name: `pykeepass-stubs`
29
+ - Status: partial stubs ([PEP 561])
30
+
31
+ ## Versioning policy
32
+
33
+ - `pykeepass-stubs` uses its own version stream (not lockstep with `pykeepass`).
34
+ - Compatibility is declared via package requirements.
35
+ - Current supported runtime range: `pykeepass>=4.1.1.post1,<4.2`.
36
+
37
+ [PEP 561]: https://peps.python.org/pep-0561/ "PEP 561 – Distributing and Packaging Type Information"
38
+ [pykeepass]: https://github.com/libkeepass/pykeepass "GitHub Repository"
@@ -0,0 +1,18 @@
1
+ # pykeepass-stubs
2
+
3
+ Type stubs for [pykeepass].
4
+
5
+ This is a stub-only distribution that improves type-checking for projects using `pykeepass`.
6
+
7
+ - Target package: `pykeepass`
8
+ - Distribution name: `pykeepass-stubs`
9
+ - Status: partial stubs ([PEP 561])
10
+
11
+ ## Versioning policy
12
+
13
+ - `pykeepass-stubs` uses its own version stream (not lockstep with `pykeepass`).
14
+ - Compatibility is declared via package requirements.
15
+ - Current supported runtime range: `pykeepass>=4.1.1.post1,<4.2`.
16
+
17
+ [PEP 561]: https://peps.python.org/pep-0561/ "PEP 561 – Distributing and Packaging Type Information"
18
+ [pykeepass]: https://github.com/libkeepass/pykeepass "GitHub Repository"
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "pykeepass-stubs"
3
+ version = "0.1.0"
4
+ description = "Type stubs for pykeepass"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ classifiers = [
8
+ "Programming Language :: Python :: 3",
9
+ "Programming Language :: Python :: 3 :: Only",
10
+ "Programming Language :: Python :: 3.11",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ "Programming Language :: Python :: 3.14",
14
+ "Typing :: Stubs Only",
15
+ ]
16
+ dependencies = [
17
+ "pykeepass>=4.1.1.post1,<4.2",
18
+ "types-lxml>=2026.2.16",
19
+ ]
20
+
21
+ [[project.authors]]
22
+ name = "Kaj Kowalski"
23
+ email = "info@kajkowalski.nl"
24
+
25
+ [project.urls]
26
+ Issues = "https://github.com/kjanat/kp2bw/issues"
27
+ Repository = "https://github.com/kjanat/kp2bw/tree/master/packages/pykeepass-stubs"
28
+
29
+ [build-system]
30
+ requires = ["uv_build>=0.10.4,<0.11.0"]
31
+ build-backend = "uv_build"
32
+
33
+ [tool.pyright]
34
+ venvPath = "../../"
35
+ venv = ".venv"
36
+ typeCheckingMode = "strict"
37
+ pythonVersion = "3.11"
38
+
39
+ [tool.ruff]
40
+ preview = true
41
+ target-version = "py311"
42
+
43
+ [tool.ruff.lint]
44
+ ignore = ["PYI029"]
@@ -0,0 +1,16 @@
1
+ from pykeepass.attachment import Attachment
2
+ from pykeepass.entry import Entry
3
+ from pykeepass.group import Group
4
+ from pykeepass.icons import icons
5
+ from pykeepass.pykeepass import PyKeePass, create_database
6
+
7
+ __version__: str
8
+ __all__ = [
9
+ "Attachment",
10
+ "Entry",
11
+ "Group",
12
+ "PyKeePass",
13
+ "__version__",
14
+ "create_database",
15
+ "icons",
16
+ ]
@@ -0,0 +1,32 @@
1
+ from lxml.etree import Element
2
+ from pykeepass.entry import Entry
3
+ from pykeepass.pykeepass import PyKeePass
4
+
5
+ class Attachment:
6
+ _element: Element
7
+ _kp: PyKeePass | None
8
+
9
+ def __init__(
10
+ self,
11
+ element: Element | None = ...,
12
+ kp: PyKeePass | None = ...,
13
+ id: int | None = ...,
14
+ filename: str | None = ...,
15
+ ) -> None: ...
16
+ @property
17
+ def id(self) -> int: ...
18
+ @id.setter
19
+ def id(self, id: int) -> None: ...
20
+ @property
21
+ def filename(self) -> str | None: ...
22
+ @filename.setter
23
+ def filename(self, filename: str) -> None: ...
24
+ @property
25
+ def entry(self) -> Entry: ...
26
+ @property
27
+ def binary(self) -> bytes: ...
28
+
29
+ data: bytes
30
+
31
+ def delete(self) -> None: ...
32
+ def __repr__(self) -> str: ...
@@ -0,0 +1,86 @@
1
+ import uuid as _uuid
2
+ from datetime import datetime
3
+ from typing import Any, Literal, overload
4
+
5
+ from lxml.etree import Element
6
+ from pykeepass.group import Group
7
+ from pykeepass.pykeepass import PyKeePass
8
+
9
+ class BaseElement:
10
+ _element: Element
11
+ _kp: PyKeePass | None
12
+
13
+ def __init__(
14
+ self,
15
+ element: Element,
16
+ kp: PyKeePass | None = ...,
17
+ icon: str | None = ...,
18
+ expires: bool = ...,
19
+ expiry_time: datetime | None = ...,
20
+ ) -> None: ...
21
+ @overload
22
+ def _xpath(
23
+ self,
24
+ xpath: str,
25
+ *,
26
+ first: Literal[True],
27
+ cast: bool = ...,
28
+ **kwargs: Any,
29
+ ) -> Element | None: ...
30
+ @overload
31
+ def _xpath(
32
+ self,
33
+ xpath: str,
34
+ *,
35
+ first: Literal[False] = ...,
36
+ cast: bool = ...,
37
+ **kwargs: Any,
38
+ ) -> list[Element]: ...
39
+ def _xpath(self, xpath: str, **kwargs: Any) -> list[Element] | Element | None: ...
40
+ def _get_subelement_text(self, tag: str) -> str | None: ...
41
+ def _set_subelement_text(self, tag: str, value: str) -> None: ...
42
+ @property
43
+ def group(self) -> Group | None: ...
44
+ @property
45
+ def parentgroup(self) -> Group | None: ...
46
+ def dump_xml(self, pretty_print: bool = ...) -> bytes: ...
47
+ @property
48
+ def uuid(self) -> _uuid.UUID: ...
49
+ @uuid.setter
50
+ def uuid(self, uuid: _uuid.UUID) -> None: ...
51
+ @property
52
+ def icon(self) -> str | None: ...
53
+ @icon.setter
54
+ def icon(self, value: str | None) -> None: ...
55
+ @property
56
+ def _path(self) -> str: ...
57
+ def _get_times_property(self, prop: str) -> datetime | None: ...
58
+ def _set_times_property(self, prop: str, value: datetime) -> None: ...
59
+ @property
60
+ def expires(self) -> bool: ...
61
+ @expires.setter
62
+ def expires(self, value: bool) -> None: ...
63
+ @property
64
+ def expired(self) -> bool: ...
65
+ @property
66
+ def expiry_time(self) -> datetime | None: ...
67
+ @expiry_time.setter
68
+ def expiry_time(self, value: datetime) -> None: ...
69
+ @property
70
+ def ctime(self) -> datetime | None: ...
71
+ @ctime.setter
72
+ def ctime(self, value: datetime) -> None: ...
73
+ @property
74
+ def atime(self) -> datetime | None: ...
75
+ @atime.setter
76
+ def atime(self, value: datetime) -> None: ...
77
+ @property
78
+ def mtime(self) -> datetime | None: ...
79
+ @mtime.setter
80
+ def mtime(self, value: datetime) -> None: ...
81
+ def delete(self) -> None: ...
82
+ def __unicode__(self) -> str: ...
83
+ def __repr__(self) -> str: ...
84
+ def __hash__(self) -> int: ...
85
+ def __eq__(self, other: object) -> bool: ...
86
+ def touch(self, modify: bool = ...) -> None: ...
@@ -0,0 +1,104 @@
1
+ from datetime import datetime
2
+
3
+ from lxml.etree import Element
4
+ from lxml.objectify import ObjectifiedElement
5
+ from pykeepass.attachment import Attachment
6
+ from pykeepass.baseelement import BaseElement
7
+ from pykeepass.group import Group
8
+ from pykeepass.pykeepass import PyKeePass
9
+
10
+ class Entry(BaseElement):
11
+ def __init__(
12
+ self,
13
+ title: str | None = None,
14
+ username: str | None = None,
15
+ password: str | None = None,
16
+ url: str | None = None,
17
+ notes: str | None = None,
18
+ otp: str | None = None,
19
+ tags: list[str] | str | None = None,
20
+ expires: bool = False,
21
+ expiry_time: datetime | None = None,
22
+ icon: str | None = None,
23
+ autotype_sequence: str | None = None,
24
+ autotype_enabled: bool = True,
25
+ autotype_window: str | None = None,
26
+ element: Element | ObjectifiedElement | None = None,
27
+ kp: PyKeePass | None = None,
28
+ ) -> None: ...
29
+ @property
30
+ def index(self) -> int: ...
31
+ def reindex(self, new_index: int) -> None: ...
32
+ @property
33
+ def attachments(self) -> list[Attachment]: ...
34
+ def add_attachment(self, id: int, filename: str) -> Attachment: ...
35
+ def delete_attachment(self, attachment: Attachment) -> None: ...
36
+ def deref(self, attribute: str) -> str | None: ...
37
+ @property
38
+ def title(self) -> str | None: ...
39
+ @title.setter
40
+ def title(self, value: str | None) -> None: ...
41
+ @property
42
+ def username(self) -> str | None: ...
43
+ @username.setter
44
+ def username(self, value: str | None) -> None: ...
45
+ @property
46
+ def password(self) -> str | None: ...
47
+ @password.setter
48
+ def password(self, value: str | None) -> None: ...
49
+ @property
50
+ def url(self) -> str | None: ...
51
+ @url.setter
52
+ def url(self, value: str | None) -> None: ...
53
+ @property
54
+ def notes(self) -> str | None: ...
55
+ @notes.setter
56
+ def notes(self, value: str | None) -> None: ...
57
+ @property
58
+ def otp(self) -> str | None: ...
59
+ @otp.setter
60
+ def otp(self, value: str | None) -> None: ...
61
+ @property
62
+ def tags(self) -> list[str]: ...
63
+ @tags.setter
64
+ def tags(self, value: list[str] | str) -> None: ...
65
+ @property
66
+ def history(self) -> list[HistoryEntry]: ...
67
+ @property
68
+ def autotype_enabled(self) -> bool | None: ...
69
+ @autotype_enabled.setter
70
+ def autotype_enabled(self, value: bool | None) -> None: ...
71
+ @property
72
+ def autotype_sequence(self) -> str | None: ...
73
+ @autotype_sequence.setter
74
+ def autotype_sequence(self, value: str | None) -> None: ...
75
+ @property
76
+ def autotype_window(self) -> str | None: ...
77
+ @autotype_window.setter
78
+ def autotype_window(self, value: str | None) -> None: ...
79
+ @property
80
+ def is_a_history_entry(self) -> bool: ...
81
+ @property
82
+ def path(self) -> list[str | None] | None: ...
83
+ @property
84
+ def custom_properties(self) -> dict[str, str | None]: ...
85
+ def set_custom_property(
86
+ self, key: str, value: str, protect: bool = False
87
+ ) -> None: ...
88
+ def get_custom_property(self, key: str) -> str | None: ...
89
+ def delete_custom_property(self, key: str) -> None: ...
90
+ def is_custom_property_protected(self, key: str) -> bool: ...
91
+ def ref(self, attribute: str) -> str: ...
92
+ def save_history(self) -> None: ...
93
+ def delete_history(
94
+ self, history_entry: Entry | None = None, all: bool = False
95
+ ) -> None: ...
96
+ @property
97
+ def group(self) -> Group | None: ...
98
+ @property
99
+ def parentgroup(self) -> Group | None: ...
100
+ def __str__(self) -> str: ...
101
+
102
+ class HistoryEntry(Entry):
103
+ def __str__(self) -> str: ...
104
+ def __hash__(self) -> int: ...
@@ -0,0 +1,5 @@
1
+ class CredentialsError(Exception): ...
2
+ class PayloadChecksumError(Exception): ...
3
+ class HeaderChecksumError(Exception): ...
4
+ class BinaryError(Exception): ...
5
+ class UnableToSendToRecycleBin(Exception): ...
@@ -0,0 +1,41 @@
1
+ from datetime import datetime
2
+
3
+ from lxml.etree import Element
4
+ from lxml.objectify import ObjectifiedElement
5
+ from pykeepass.baseelement import BaseElement
6
+ from pykeepass.entry import Entry
7
+ from pykeepass.pykeepass import PyKeePass
8
+
9
+ class Group(BaseElement):
10
+ def __init__(
11
+ self,
12
+ name: str | None = None,
13
+ element: Element | ObjectifiedElement | None = None,
14
+ icon: str | None = None,
15
+ notes: str | None = None,
16
+ kp: PyKeePass | None = None,
17
+ expires: bool | None = None,
18
+ expiry_time: datetime | None = None,
19
+ ) -> None: ...
20
+ @property
21
+ def name(self) -> str | None: ...
22
+ @name.setter
23
+ def name(self, value: str) -> None: ...
24
+ @property
25
+ def notes(self) -> str | None: ...
26
+ @notes.setter
27
+ def notes(self, value: str) -> None: ...
28
+ @property
29
+ def entries(self) -> list[Entry]: ...
30
+ @property
31
+ def subgroups(self) -> list[Group]: ...
32
+ @property
33
+ def is_root_group(self) -> bool: ...
34
+ @property
35
+ def path(self) -> list[str | None]: ...
36
+ @property
37
+ def group(self) -> Group | None: ...
38
+ @property
39
+ def parentgroup(self) -> Group | None: ...
40
+ def append(self, entries: Entry | Group | list[Entry] | list[Group]) -> None: ...
41
+ def __str__(self) -> str: ...
@@ -0,0 +1,3 @@
1
+ from types import SimpleNamespace
2
+
3
+ icons: SimpleNamespace
@@ -0,0 +1 @@
1
+ partial
@@ -0,0 +1,242 @@
1
+ import uuid as _uuid
2
+ from datetime import datetime
3
+ from io import IOBase
4
+ from pathlib import Path
5
+ from typing import Any, Self, overload
6
+
7
+ from lxml.etree import Element, ElementTree
8
+ from pykeepass.attachment import Attachment
9
+ from pykeepass.entry import Entry
10
+ from pykeepass.group import Group
11
+
12
+ class PyKeePass:
13
+ filename: str | Path
14
+ kdbx: object
15
+
16
+ def __init__(
17
+ self,
18
+ filename: str | Path | IOBase,
19
+ password: str | None = None,
20
+ keyfile: str | Path | None = None,
21
+ transformed_key: bytes | None = None,
22
+ decrypt: bool = True,
23
+ ) -> None: ...
24
+ def __enter__(self) -> Self: ...
25
+ def __exit__(
26
+ self,
27
+ typ: type[BaseException] | None,
28
+ value: BaseException | None,
29
+ tb: object,
30
+ ) -> None: ...
31
+ def read(
32
+ self,
33
+ filename: str | Path | IOBase | None = None,
34
+ password: str | None = None,
35
+ keyfile: str | Path | None = None,
36
+ transformed_key: bytes | None = None,
37
+ decrypt: bool = True,
38
+ ) -> None: ...
39
+ def reload(self) -> None: ...
40
+ def save(
41
+ self,
42
+ filename: str | Path | IOBase | None = None,
43
+ transformed_key: bytes | None = None,
44
+ ) -> None: ...
45
+ @property
46
+ def version(self) -> tuple[int, int]: ...
47
+ @property
48
+ def encryption_algorithm(self) -> str: ...
49
+ @property
50
+ def kdf_algorithm(self) -> str | None: ...
51
+ @property
52
+ def transformed_key(self) -> bytes: ...
53
+ @property
54
+ def database_salt(self) -> bytes: ...
55
+ @property
56
+ def tree(self) -> ElementTree: ...
57
+ @property
58
+ def root_group(self) -> Group: ...
59
+ @property
60
+ def recyclebin_group(self) -> Group | None: ...
61
+ @property
62
+ def groups(self) -> list[Group]: ...
63
+ @property
64
+ def entries(self) -> list[Entry]: ...
65
+ @property
66
+ def database_name(self) -> str | None: ...
67
+ @database_name.setter
68
+ def database_name(self, name: str) -> None: ...
69
+ @property
70
+ def database_description(self) -> str | None: ...
71
+ @database_description.setter
72
+ def database_description(self, name: str) -> None: ...
73
+ @property
74
+ def default_username(self) -> str | None: ...
75
+ @default_username.setter
76
+ def default_username(self, name: str) -> None: ...
77
+ def xml(self) -> bytes: ...
78
+ def dump_xml(self, filename: str) -> None: ...
79
+ @overload
80
+ def xpath(
81
+ self,
82
+ xpath_str: str,
83
+ tree: Element | ElementTree | None = None,
84
+ *,
85
+ first: bool = False,
86
+ cast: bool = False,
87
+ **kwargs: Any,
88
+ ) -> list[Element]: ...
89
+ @overload
90
+ def xpath(
91
+ self,
92
+ xpath_str: str,
93
+ tree: Element | ElementTree | None = None,
94
+ first: bool = False,
95
+ cast: bool = False,
96
+ **kwargs: Any,
97
+ ) -> list[Element] | Element | None: ...
98
+ def xpath(
99
+ self,
100
+ xpath_str: str,
101
+ tree: Element | ElementTree | None = None,
102
+ first: bool = False,
103
+ cast: bool = False,
104
+ **kwargs: Any,
105
+ ) -> list[Element] | Element | None: ...
106
+
107
+ _xpath = xpath
108
+
109
+ # --- Groups ---
110
+
111
+ def find_groups(
112
+ self,
113
+ recursive: bool = True,
114
+ path: list[str] | None = None,
115
+ group: Group | None = None,
116
+ *,
117
+ name: str | None = None,
118
+ uuid: _uuid.UUID | None = None,
119
+ notes: str | None = None,
120
+ first: bool = False,
121
+ regex: bool = False,
122
+ flags: str | None = None,
123
+ ) -> list[Group] | Group | None: ...
124
+ def add_group(
125
+ self,
126
+ destination_group: Group,
127
+ group_name: str,
128
+ icon: str | None = None,
129
+ notes: str | None = None,
130
+ ) -> Group: ...
131
+ def delete_group(self, group: Group) -> None: ...
132
+ def move_group(self, group: Group, destination_group: Group) -> None: ...
133
+ def trash_group(self, group: Group) -> None: ...
134
+ def empty_group(self, group: Group) -> None: ...
135
+
136
+ # --- Entries ---
137
+
138
+ def find_entries(
139
+ self,
140
+ recursive: bool = True,
141
+ path: list[str | None] | None = None,
142
+ group: Group | None = None,
143
+ *,
144
+ title: str | None = None,
145
+ username: str | None = None,
146
+ password: str | None = None,
147
+ url: str | None = None,
148
+ notes: str | None = None,
149
+ otp: str | None = None,
150
+ string: dict[str, str] | None = None,
151
+ uuid: _uuid.UUID | None = None,
152
+ tags: list[str] | None = None,
153
+ autotype_enabled: bool | None = None,
154
+ autotype_sequence: str | None = None,
155
+ autotype_window: str | None = None,
156
+ first: bool = False,
157
+ history: bool = False,
158
+ regex: bool = False,
159
+ flags: str | None = None,
160
+ ) -> list[Entry] | Entry | None: ...
161
+ def add_entry(
162
+ self,
163
+ destination_group: Group,
164
+ title: str | None,
165
+ username: str | None,
166
+ password: str | None,
167
+ url: str | None = None,
168
+ notes: str | None = None,
169
+ expiry_time: datetime | None = None,
170
+ tags: list[str] | str | None = None,
171
+ otp: str | None = None,
172
+ icon: str | None = None,
173
+ force_creation: bool = False,
174
+ ) -> Entry: ...
175
+ def delete_entry(self, entry: Entry) -> None: ...
176
+ def move_entry(self, entry: Entry, destination_group: Group) -> None: ...
177
+ def trash_entry(self, entry: Entry) -> None: ...
178
+
179
+ # --- Attachments ---
180
+
181
+ def find_attachments(
182
+ self,
183
+ recursive: bool = True,
184
+ path: list[str] | None = None,
185
+ element: Entry | Group | None = None,
186
+ *,
187
+ id: int | None = None,
188
+ filename: str | None = None,
189
+ first: bool = False,
190
+ history: bool = False,
191
+ regex: bool = False,
192
+ flags: str | None = None,
193
+ ) -> list[Attachment] | Attachment | None: ...
194
+ @property
195
+ def attachments(self) -> list[Attachment]: ...
196
+ @property
197
+ def binaries(self) -> list[bytes]: ...
198
+ def add_binary(
199
+ self, data: bytes, compressed: bool = True, protected: bool = True
200
+ ) -> int: ...
201
+ def delete_binary(self, id: int) -> None: ...
202
+
203
+ # --- Misc ---
204
+
205
+ def deref(self, value: str | None) -> str | _uuid.UUID | None: ...
206
+ def _encode_time(self, value: datetime) -> str: ...
207
+ def _decode_time(self, text: str) -> datetime: ...
208
+
209
+ # --- Credentials ---
210
+
211
+ @property
212
+ def password(self) -> str | None: ...
213
+ @password.setter
214
+ def password(self, password: str | None) -> None: ...
215
+ @property
216
+ def keyfile(self) -> str | Path | None: ...
217
+ @keyfile.setter
218
+ def keyfile(self, keyfile: str | Path | None) -> None: ...
219
+ @property
220
+ def credchange_required_days(self) -> int | None: ...
221
+ @credchange_required_days.setter
222
+ def credchange_required_days(self, days: int) -> None: ...
223
+ @property
224
+ def credchange_recommended_days(self) -> int | None: ...
225
+ @credchange_recommended_days.setter
226
+ def credchange_recommended_days(self, days: int) -> None: ...
227
+ @property
228
+ def credchange_date(self) -> datetime | None: ...
229
+ @credchange_date.setter
230
+ def credchange_date(self, date: datetime) -> None: ...
231
+ @property
232
+ def credchange_required(self) -> bool: ...
233
+ @property
234
+ def credchange_recommended(self) -> bool: ...
235
+
236
+ def create_database(
237
+ filename: str | Path | IOBase,
238
+ password: str | None = None,
239
+ keyfile: str | Path | None = None,
240
+ transformed_key: bytes | None = None,
241
+ ) -> PyKeePass: ...
242
+ def debug_setup() -> None: ...