pylekto 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.
- pylekto-0.1.0/LICENSE +21 -0
- pylekto-0.1.0/PKG-INFO +102 -0
- pylekto-0.1.0/README.md +82 -0
- pylekto-0.1.0/pyproject.toml +142 -0
- pylekto-0.1.0/pyproject.toml.orig +134 -0
- pylekto-0.1.0/src/pylekto/__init__.py +41 -0
- pylekto-0.1.0/src/pylekto/_http.py +354 -0
- pylekto-0.1.0/src/pylekto/_lekto.py +3 -0
- pylekto-0.1.0/src/pylekto/_sse.py +43 -0
- pylekto-0.1.0/src/pylekto/client.py +155 -0
- pylekto-0.1.0/src/pylekto/exceptions.py +124 -0
- pylekto-0.1.0/src/pylekto/models.py +8244 -0
- pylekto-0.1.0/src/pylekto/py.typed +0 -0
- pylekto-0.1.0/src/pylekto/resources/__init__.py +59 -0
- pylekto-0.1.0/src/pylekto/resources/_base.py +14 -0
- pylekto-0.1.0/src/pylekto/resources/auth.py +19 -0
- pylekto-0.1.0/src/pylekto/resources/documents.py +724 -0
- pylekto-0.1.0/src/pylekto/resources/events.py +38 -0
- pylekto-0.1.0/src/pylekto/resources/health.py +24 -0
- pylekto-0.1.0/src/pylekto/resources/identifiers.py +60 -0
- pylekto-0.1.0/src/pylekto/resources/inbox.py +125 -0
- pylekto-0.1.0/src/pylekto/resources/lenses.py +96 -0
- pylekto-0.1.0/src/pylekto/resources/mail.py +286 -0
- pylekto-0.1.0/src/pylekto/resources/master_data.py +451 -0
- pylekto-0.1.0/src/pylekto/resources/open_identifiers.py +171 -0
- pylekto-0.1.0/src/pylekto/resources/operations.py +378 -0
- pylekto-0.1.0/src/pylekto/resources/relations.py +62 -0
- pylekto-0.1.0/src/pylekto/resources/rules.py +235 -0
- pylekto-0.1.0/src/pylekto/resources/search.py +149 -0
- pylekto-0.1.0/src/pylekto/resources/spaces.py +123 -0
- pylekto-0.1.0/src/pylekto/resources/users.py +126 -0
- pylekto-0.1.0/src/pylekto/resources/webhooks.py +226 -0
- pylekto-0.1.0/src/pylekto/types.py +126 -0
- pylekto-0.1.0/src/pylekto/webhooks.py +269 -0
pylekto-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tb1337
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pylekto-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pylekto
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async Python client for the Lekto DMS REST API
|
|
5
|
+
Keywords: lekto,dms,document-management,api-client,async
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Framework :: AsyncIO
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Dist: httpx2>=2.14
|
|
15
|
+
Requires-Dist: pydantic>=2.14
|
|
16
|
+
Requires-Python: >=3.14
|
|
17
|
+
Project-URL: Source Code, https://github.com/lektohq/pylekto
|
|
18
|
+
Project-URL: Bug Reports, https://github.com/lektohq/pylekto/issues
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# pylekto
|
|
22
|
+
|
|
23
|
+
Async Python client for the [Lekto](https://github.com/lektohq/lekto) DMS REST API.
|
|
24
|
+
|
|
25
|
+
> [!NOTE]
|
|
26
|
+
> pylekto is at its beginning: the client stands, the areas of the API follow one by one. So far
|
|
27
|
+
> it covers `auth` (who calls), `health`, `documents` (with uploads, downloads, facts, page
|
|
28
|
+
> edits, changes of many documents), `search`, `relations`, the master data (`contacts`,
|
|
29
|
+
> `document_types`, `tags`, `fields`), `spaces`, `users`, `identifiers`, the `open_identifiers`,
|
|
30
|
+
> the `inbox`, the `expected` documents, `lenses`, `rules` (with templates), `mailboxes`,
|
|
31
|
+
> `mail_rules`, `webhooks`, `push`, the `pipeline`, `jobs`, `automation`, the `classifier` and the
|
|
32
|
+
> `events` as they happen; `pylekto.webhooks` receives what Lekto sends to a webhook.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import asyncio
|
|
36
|
+
|
|
37
|
+
from pylekto import LektoClient
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
async def main() -> None:
|
|
41
|
+
async with LektoClient("https://lekto.example.com", "lekto_…") as lekto:
|
|
42
|
+
me = await lekto.auth.me()
|
|
43
|
+
print(me.user.username, me.token_scope)
|
|
44
|
+
|
|
45
|
+
async for document in lekto.documents.list(lane=["red"]):
|
|
46
|
+
print(document.title)
|
|
47
|
+
|
|
48
|
+
result = await lekto.search.page("electricity bill", limit=5)
|
|
49
|
+
print([hit.document.title for hit in result.items])
|
|
50
|
+
|
|
51
|
+
async for event in lekto.events.listen(): # until Lekto ends the stream
|
|
52
|
+
print(event.type, event.document_id)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
asyncio.run(main())
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- **Token only.** A personal API token from Lekto; its scope (`read`, `upload`, `read_write`)
|
|
59
|
+
decides what the client may do.
|
|
60
|
+
- **Your own httpx2 client** if you like (`LektoClient(url, token, client=...)`): pylekto sends its
|
|
61
|
+
requests with it and leaves it open.
|
|
62
|
+
- **Errors raise.** Each subclass of `LektoError` says what went wrong; a refusal carries Lekto's
|
|
63
|
+
problem details with a reason code. pylekto repeats nothing: whether to try again is up to you.
|
|
64
|
+
- **One Lekto release.** pylekto speaks the API of `pylekto.LEKTO_VERSION`; its models are
|
|
65
|
+
generated from that release's OpenAPI description. While Lekto is in beta, each release may
|
|
66
|
+
change its API, so connecting to another version warns (`LektoVersionWarning`).
|
|
67
|
+
|
|
68
|
+
### Receiving webhooks
|
|
69
|
+
|
|
70
|
+
Lekto signs what it sends to a webhook (Standard Webhooks). In whatever web framework receives it:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from pylekto import webhooks
|
|
74
|
+
from pylekto.models import TaskAnswer
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async def receive(headers: dict[str, str], body: bytes) -> None:
|
|
78
|
+
webhooks.verify(headers, body, "whsec_…") # raises WebhookVerificationError
|
|
79
|
+
asked = webhooks.read_rule_ask(body) # or read_event, read_rule_send, read_propose …
|
|
80
|
+
task = webhooks.task(headers)
|
|
81
|
+
if task is not None:
|
|
82
|
+
await webhooks.answer(task, TaskAnswer(status="ok", answer={"paid": True}))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
|
|
87
|
+
Python 3.14 or newer.
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
Open the repository in its devcontainer (`.devcontainer/`); it runs `script/setup`, which
|
|
92
|
+
installs the dependencies and the Git hooks. Outside the devcontainer, `script/setup` creates a
|
|
93
|
+
local `.venv` first.
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
uv sync
|
|
97
|
+
uv run prek run --all-files # every check: Ruff, mypy, pytest with coverage, typos, yamllint
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT, see [LICENSE](LICENSE).
|
pylekto-0.1.0/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# pylekto
|
|
2
|
+
|
|
3
|
+
Async Python client for the [Lekto](https://github.com/lektohq/lekto) DMS REST API.
|
|
4
|
+
|
|
5
|
+
> [!NOTE]
|
|
6
|
+
> pylekto is at its beginning: the client stands, the areas of the API follow one by one. So far
|
|
7
|
+
> it covers `auth` (who calls), `health`, `documents` (with uploads, downloads, facts, page
|
|
8
|
+
> edits, changes of many documents), `search`, `relations`, the master data (`contacts`,
|
|
9
|
+
> `document_types`, `tags`, `fields`), `spaces`, `users`, `identifiers`, the `open_identifiers`,
|
|
10
|
+
> the `inbox`, the `expected` documents, `lenses`, `rules` (with templates), `mailboxes`,
|
|
11
|
+
> `mail_rules`, `webhooks`, `push`, the `pipeline`, `jobs`, `automation`, the `classifier` and the
|
|
12
|
+
> `events` as they happen; `pylekto.webhooks` receives what Lekto sends to a webhook.
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import asyncio
|
|
16
|
+
|
|
17
|
+
from pylekto import LektoClient
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def main() -> None:
|
|
21
|
+
async with LektoClient("https://lekto.example.com", "lekto_…") as lekto:
|
|
22
|
+
me = await lekto.auth.me()
|
|
23
|
+
print(me.user.username, me.token_scope)
|
|
24
|
+
|
|
25
|
+
async for document in lekto.documents.list(lane=["red"]):
|
|
26
|
+
print(document.title)
|
|
27
|
+
|
|
28
|
+
result = await lekto.search.page("electricity bill", limit=5)
|
|
29
|
+
print([hit.document.title for hit in result.items])
|
|
30
|
+
|
|
31
|
+
async for event in lekto.events.listen(): # until Lekto ends the stream
|
|
32
|
+
print(event.type, event.document_id)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
asyncio.run(main())
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **Token only.** A personal API token from Lekto; its scope (`read`, `upload`, `read_write`)
|
|
39
|
+
decides what the client may do.
|
|
40
|
+
- **Your own httpx2 client** if you like (`LektoClient(url, token, client=...)`): pylekto sends its
|
|
41
|
+
requests with it and leaves it open.
|
|
42
|
+
- **Errors raise.** Each subclass of `LektoError` says what went wrong; a refusal carries Lekto's
|
|
43
|
+
problem details with a reason code. pylekto repeats nothing: whether to try again is up to you.
|
|
44
|
+
- **One Lekto release.** pylekto speaks the API of `pylekto.LEKTO_VERSION`; its models are
|
|
45
|
+
generated from that release's OpenAPI description. While Lekto is in beta, each release may
|
|
46
|
+
change its API, so connecting to another version warns (`LektoVersionWarning`).
|
|
47
|
+
|
|
48
|
+
### Receiving webhooks
|
|
49
|
+
|
|
50
|
+
Lekto signs what it sends to a webhook (Standard Webhooks). In whatever web framework receives it:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from pylekto import webhooks
|
|
54
|
+
from pylekto.models import TaskAnswer
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def receive(headers: dict[str, str], body: bytes) -> None:
|
|
58
|
+
webhooks.verify(headers, body, "whsec_…") # raises WebhookVerificationError
|
|
59
|
+
asked = webhooks.read_rule_ask(body) # or read_event, read_rule_send, read_propose …
|
|
60
|
+
task = webhooks.task(headers)
|
|
61
|
+
if task is not None:
|
|
62
|
+
await webhooks.answer(task, TaskAnswer(status="ok", answer={"paid": True}))
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Requirements
|
|
66
|
+
|
|
67
|
+
Python 3.14 or newer.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
Open the repository in its devcontainer (`.devcontainer/`); it runs `script/setup`, which
|
|
72
|
+
installs the dependencies and the Git hooks. Outside the devcontainer, `script/setup` creates a
|
|
73
|
+
local `.venv` first.
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
uv sync
|
|
77
|
+
uv run prek run --all-files # every check: Ruff, mypy, pytest with coverage, typos, yamllint
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pylekto"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Async Python client for the Lekto DMS REST API"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"lekto",
|
|
10
|
+
"dms",
|
|
11
|
+
"document-management",
|
|
12
|
+
"api-client",
|
|
13
|
+
"async",
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
17
|
+
"Framework :: AsyncIO",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
"Typing :: Typed",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.14"
|
|
24
|
+
dependencies = [
|
|
25
|
+
"httpx2>=2.14",
|
|
26
|
+
"pydantic>=2.14",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
"Source Code" = "https://github.com/lektohq/pylekto"
|
|
31
|
+
"Bug Reports" = "https://github.com/lektohq/pylekto/issues"
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
"covdefaults>=2.3.0",
|
|
36
|
+
"datamodel-code-generator>=0.88.0",
|
|
37
|
+
"mypy>=2.4.1",
|
|
38
|
+
"prek>=0.5.9",
|
|
39
|
+
"pytest>=9.2.0",
|
|
40
|
+
"pytest-asyncio>=1.4.1",
|
|
41
|
+
"pytest-cov>=7.1.0",
|
|
42
|
+
"ruff>=0.17.3",
|
|
43
|
+
"typos>=1.51.1",
|
|
44
|
+
"yamllint>=1.38.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["uv_build>=0.11,<0.12"]
|
|
49
|
+
build-backend = "uv_build"
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
line-length = 100
|
|
53
|
+
target-version = "py314"
|
|
54
|
+
extend-exclude = ["src/pylekto/models.py"]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint]
|
|
57
|
+
select = ["ALL"]
|
|
58
|
+
ignore = [
|
|
59
|
+
"ANN401",
|
|
60
|
+
"CPY001",
|
|
61
|
+
"D203",
|
|
62
|
+
"D213",
|
|
63
|
+
"D417",
|
|
64
|
+
"PLR2004",
|
|
65
|
+
"PLR0913",
|
|
66
|
+
"RUF012",
|
|
67
|
+
"COM812",
|
|
68
|
+
"ISC001",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint.flake8-type-checking]
|
|
72
|
+
runtime-evaluated-base-classes = [
|
|
73
|
+
"pydantic.BaseModel",
|
|
74
|
+
"typing.TypedDict",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.flake8-pytest-style]
|
|
78
|
+
fixture-parentheses = false
|
|
79
|
+
mark-parentheses = false
|
|
80
|
+
|
|
81
|
+
[tool.ruff.lint.isort]
|
|
82
|
+
known-first-party = ["pylekto"]
|
|
83
|
+
|
|
84
|
+
[tool.ruff.lint.mccabe]
|
|
85
|
+
max-complexity = 25
|
|
86
|
+
|
|
87
|
+
[tool.mypy]
|
|
88
|
+
strict = true
|
|
89
|
+
files = [
|
|
90
|
+
"src",
|
|
91
|
+
"tests",
|
|
92
|
+
"script",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[tool.pytest.ini_options]
|
|
96
|
+
testpaths = ["tests"]
|
|
97
|
+
addopts = "--cov --cov-report=term --cov-report=xml"
|
|
98
|
+
asyncio_mode = "auto"
|
|
99
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
100
|
+
|
|
101
|
+
[tool.coverage.run]
|
|
102
|
+
plugins = ["covdefaults"]
|
|
103
|
+
source = ["pylekto"]
|
|
104
|
+
|
|
105
|
+
[tool.coverage.report]
|
|
106
|
+
fail_under = 95
|
|
107
|
+
show_missing = true
|
|
108
|
+
|
|
109
|
+
[tool.typos.default]
|
|
110
|
+
extend-ignore-re = [
|
|
111
|
+
"[A-Za-z0-9_-]*[A-Z][A-Za-z0-9_-]*[0-9][A-Za-z0-9_-]*",
|
|
112
|
+
"[A-Za-z0-9_-]*[0-9][A-Za-z0-9_-]*[A-Z][A-Za-z0-9_-]*",
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
[tool.typos.files]
|
|
116
|
+
extend-exclude = [
|
|
117
|
+
"uv.lock",
|
|
118
|
+
"openapi.json",
|
|
119
|
+
"src/pylekto/models.py",
|
|
120
|
+
"tests/snapshot/",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
[tool.datamodel-codegen]
|
|
124
|
+
input = "openapi.json"
|
|
125
|
+
input-file-type = "openapi"
|
|
126
|
+
output = "src/pylekto/models.py"
|
|
127
|
+
output-model-type = "pydantic_v2.BaseModel"
|
|
128
|
+
target-python-version = "3.14"
|
|
129
|
+
use-annotated = true
|
|
130
|
+
use-standard-collections = true
|
|
131
|
+
use-union-operator = true
|
|
132
|
+
field-constraints = true
|
|
133
|
+
enum-field-as-literal = "all"
|
|
134
|
+
collapse-root-models = true
|
|
135
|
+
use-type-alias = true
|
|
136
|
+
use-schema-description = true
|
|
137
|
+
use-field-description = true
|
|
138
|
+
disable-timestamp = true
|
|
139
|
+
formatters = ["ruff-format"]
|
|
140
|
+
custom-file-header = '''
|
|
141
|
+
# Generated by datamodel-codegen from openapi.json; do not edit. `uv run datamodel-codegen` writes it.
|
|
142
|
+
"""The models of Lekto's REST API: what it takes and what it answers."""'''
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pylekto"
|
|
3
|
+
# Set from the release's tag when it is built (.github/workflows/release.yml).
|
|
4
|
+
version = "0.1.0"
|
|
5
|
+
description = "Async Python client for the Lekto DMS REST API"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
keywords = ["lekto", "dms", "document-management", "api-client", "async"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
12
|
+
"Framework :: AsyncIO",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Programming Language :: Python :: 3.14",
|
|
15
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
16
|
+
"Typing :: Typed",
|
|
17
|
+
]
|
|
18
|
+
requires-python = ">=3.14"
|
|
19
|
+
# A library states lower bounds only; uv.lock pins the development environment.
|
|
20
|
+
dependencies = [
|
|
21
|
+
"httpx2>=2.14",
|
|
22
|
+
"pydantic>=2.14",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
"Source Code" = "https://github.com/lektohq/pylekto"
|
|
27
|
+
"Bug Reports" = "https://github.com/lektohq/pylekto/issues"
|
|
28
|
+
|
|
29
|
+
[dependency-groups]
|
|
30
|
+
dev = [
|
|
31
|
+
"covdefaults>=2.3.0",
|
|
32
|
+
"datamodel-code-generator>=0.88.0",
|
|
33
|
+
"mypy>=2.4.1",
|
|
34
|
+
"prek>=0.5.9",
|
|
35
|
+
"pytest>=9.2.0",
|
|
36
|
+
"pytest-asyncio>=1.4.1",
|
|
37
|
+
"pytest-cov>=7.1.0",
|
|
38
|
+
"ruff>=0.17.3",
|
|
39
|
+
"typos>=1.51.1",
|
|
40
|
+
"yamllint>=1.38.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["uv_build>=0.11,<0.12"]
|
|
45
|
+
build-backend = "uv_build"
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 100
|
|
49
|
+
target-version = "py314"
|
|
50
|
+
# Generated from Lekto's OpenAPI description; its text is Lekto's.
|
|
51
|
+
extend-exclude = ["src/pylekto/models.py"]
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint]
|
|
54
|
+
select = ["ALL"]
|
|
55
|
+
ignore = [
|
|
56
|
+
"ANN401", # Any is sometimes the honest type of a value
|
|
57
|
+
"CPY001", # no copyright notice in every file
|
|
58
|
+
"D203", # conflicts with D211
|
|
59
|
+
"D213", # conflicts with D212
|
|
60
|
+
"D417", # false positives
|
|
61
|
+
"PLR2004", # magic values in comparisons
|
|
62
|
+
"PLR0913", # too many arguments: not actionable without breaking the public API
|
|
63
|
+
"RUF012", # mutable class attributes without ClassVar
|
|
64
|
+
# Conflict with the Ruff formatter.
|
|
65
|
+
"COM812",
|
|
66
|
+
"ISC001",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
# pydantic reads the annotations of a model at run time; get_type_hints those of a TypedDict.
|
|
70
|
+
[tool.ruff.lint.flake8-type-checking]
|
|
71
|
+
runtime-evaluated-base-classes = ["pydantic.BaseModel", "typing.TypedDict"]
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint.flake8-pytest-style]
|
|
74
|
+
fixture-parentheses = false
|
|
75
|
+
mark-parentheses = false
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.isort]
|
|
78
|
+
known-first-party = ["pylekto"]
|
|
79
|
+
|
|
80
|
+
[tool.ruff.lint.mccabe]
|
|
81
|
+
max-complexity = 25
|
|
82
|
+
|
|
83
|
+
[tool.mypy]
|
|
84
|
+
strict = true
|
|
85
|
+
files = ["src", "tests", "script"]
|
|
86
|
+
|
|
87
|
+
[tool.pytest.ini_options]
|
|
88
|
+
testpaths = ["tests"]
|
|
89
|
+
addopts = "--cov --cov-report=term --cov-report=xml"
|
|
90
|
+
asyncio_mode = "auto"
|
|
91
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
92
|
+
|
|
93
|
+
[tool.coverage.run]
|
|
94
|
+
plugins = ["covdefaults"]
|
|
95
|
+
source = ["pylekto"]
|
|
96
|
+
|
|
97
|
+
[tool.coverage.report]
|
|
98
|
+
fail_under = 95
|
|
99
|
+
show_missing = true
|
|
100
|
+
|
|
101
|
+
[tool.typos.default]
|
|
102
|
+
# Keys and tokens (a push subscription's key): runs of base64url with a capital and a digit, which
|
|
103
|
+
# words and snake_case names have not.
|
|
104
|
+
extend-ignore-re = [
|
|
105
|
+
"[A-Za-z0-9_-]*[A-Z][A-Za-z0-9_-]*[0-9][A-Za-z0-9_-]*",
|
|
106
|
+
"[A-Za-z0-9_-]*[0-9][A-Za-z0-9_-]*[A-Z][A-Za-z0-9_-]*",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[tool.typos.files]
|
|
110
|
+
# Lekto's OpenAPI description, the models generated from it and the recorded answers hold Lekto's
|
|
111
|
+
# text: its examples and the German of its synthetic documents.
|
|
112
|
+
extend-exclude = ["uv.lock", "openapi.json", "src/pylekto/models.py", "tests/snapshot/"]
|
|
113
|
+
|
|
114
|
+
# The models from Lekto's OpenAPI description: `uv run datamodel-codegen` writes them again,
|
|
115
|
+
# script/update_openapi.py fetches the description of another Lekto release first.
|
|
116
|
+
[tool.datamodel-codegen]
|
|
117
|
+
input = "openapi.json"
|
|
118
|
+
input-file-type = "openapi"
|
|
119
|
+
output = "src/pylekto/models.py"
|
|
120
|
+
output-model-type = "pydantic_v2.BaseModel"
|
|
121
|
+
target-python-version = "3.14"
|
|
122
|
+
use-annotated = true
|
|
123
|
+
use-standard-collections = true
|
|
124
|
+
use-union-operator = true
|
|
125
|
+
field-constraints = true
|
|
126
|
+
enum-field-as-literal = "all"
|
|
127
|
+
collapse-root-models = true
|
|
128
|
+
use-type-alias = true
|
|
129
|
+
use-schema-description = true
|
|
130
|
+
use-field-description = true
|
|
131
|
+
disable-timestamp = true
|
|
132
|
+
formatters = ["ruff-format"]
|
|
133
|
+
custom-file-header = '''# Generated by datamodel-codegen from openapi.json; do not edit. `uv run datamodel-codegen` writes it.
|
|
134
|
+
"""The models of Lekto's REST API: what it takes and what it answers."""'''
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Async Python client for the Lekto DMS REST API."""
|
|
2
|
+
|
|
3
|
+
from pylekto import webhooks
|
|
4
|
+
from pylekto._lekto import LEKTO_VERSION
|
|
5
|
+
from pylekto.client import LektoClient
|
|
6
|
+
from pylekto.exceptions import (
|
|
7
|
+
LektoApiError,
|
|
8
|
+
LektoAuthenticationError,
|
|
9
|
+
LektoConflictError,
|
|
10
|
+
LektoConnectionError,
|
|
11
|
+
LektoError,
|
|
12
|
+
LektoForbiddenError,
|
|
13
|
+
LektoNotFoundError,
|
|
14
|
+
LektoRateLimitError,
|
|
15
|
+
LektoResponseError,
|
|
16
|
+
LektoServerError,
|
|
17
|
+
LektoTimeoutError,
|
|
18
|
+
LektoValidationError,
|
|
19
|
+
LektoVersionWarning,
|
|
20
|
+
WebhookVerificationError,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"LEKTO_VERSION",
|
|
25
|
+
"LektoApiError",
|
|
26
|
+
"LektoAuthenticationError",
|
|
27
|
+
"LektoClient",
|
|
28
|
+
"LektoConflictError",
|
|
29
|
+
"LektoConnectionError",
|
|
30
|
+
"LektoError",
|
|
31
|
+
"LektoForbiddenError",
|
|
32
|
+
"LektoNotFoundError",
|
|
33
|
+
"LektoRateLimitError",
|
|
34
|
+
"LektoResponseError",
|
|
35
|
+
"LektoServerError",
|
|
36
|
+
"LektoTimeoutError",
|
|
37
|
+
"LektoValidationError",
|
|
38
|
+
"LektoVersionWarning",
|
|
39
|
+
"WebhookVerificationError",
|
|
40
|
+
"webhooks",
|
|
41
|
+
]
|