libres 1.2.0__tar.gz → 1.4.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.
- {libres-1.2.0 → libres-1.4.0}/HISTORY.rst +23 -0
- {libres-1.2.0/src/libres.egg-info → libres-1.4.0}/PKG-INFO +28 -5
- {libres-1.2.0 → libres-1.4.0}/README.rst +1 -1
- {libres-1.2.0 → libres-1.4.0}/pyproject.toml +17 -17
- {libres-1.2.0 → libres-1.4.0}/src/libres/__init__.py +1 -1
- {libres-1.2.0 → libres-1.4.0}/src/libres/context/core.py +2 -2
- {libres-1.2.0 → libres-1.4.0}/src/libres/context/registry.py +2 -2
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/allocation.py +1 -1
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/queries.py +1 -1
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/scheduler.py +14 -5
- {libres-1.2.0 → libres-1.4.0/src/libres.egg-info}/PKG-INFO +28 -5
- {libres-1.2.0 → libres-1.4.0}/src/libres.egg-info/requires.txt +1 -1
- {libres-1.2.0 → libres-1.4.0}/tests/test_scheduler.py +9 -4
- {libres-1.2.0 → libres-1.4.0}/tests/test_session.py +9 -3
- {libres-1.2.0 → libres-1.4.0}/LICENSE +0 -0
- {libres-1.2.0 → libres-1.4.0}/MANIFEST.in +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/Makefile +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/_static/custom.css +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/_static/favicon.ico +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/_static/logo.svg +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/api.rst +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/concepts.rst +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/conf.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/customizations.rst +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/faq.rst +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/index.rst +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/requirements.txt +0 -0
- {libres-1.2.0 → libres-1.4.0}/docs/under_the_hood.rst +0 -0
- {libres-1.2.0 → libres-1.4.0}/setup.cfg +0 -0
- {libres-1.2.0 → libres-1.4.0}/setup.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/.gitignore +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/context/__init__.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/context/exposure.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/context/session.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/context/settings.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/__init__.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/__init__.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/base.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/blocker.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/other.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/reservation.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/reserved_slot.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/timespan.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/timestamp.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/types/__init__.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/types/json_type.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/types/utcdatetime.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/db/models/types/uuid_type.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/modules/__init__.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/modules/errors.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/modules/events.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/modules/rasterizer.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/modules/utils.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres/py.typed +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres.egg-info/SOURCES.txt +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres.egg-info/dependency_links.txt +0 -0
- {libres-1.2.0 → libres-1.4.0}/src/libres.egg-info/top_level.txt +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_allocation.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_registry.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_reservation.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_reserved_slot.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_scheduler_blockers.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_test.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_types.py +0 -0
- {libres-1.2.0 → libres-1.4.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
---------
|
|
3
3
|
|
|
4
|
+
1.4.0 (15.10.2026)
|
|
5
|
+
~~~~~~~~~~~~~~~~~~~
|
|
6
|
+
|
|
7
|
+
- Adds support for SQLAlchemy 2.1
|
|
8
|
+
[Daverball]
|
|
9
|
+
|
|
10
|
+
- Drops support for SQLAlchemy 2.0
|
|
11
|
+
[Daverball]
|
|
12
|
+
|
|
13
|
+
1.3.0 (15.10.2026)
|
|
14
|
+
~~~~~~~~~~~~~~~~~~~
|
|
15
|
+
|
|
16
|
+
- Adds Python 3.15 support
|
|
17
|
+
[Daverball]
|
|
18
|
+
|
|
19
|
+
- Drops Python 3.10 support
|
|
20
|
+
[Daverball]
|
|
21
|
+
|
|
22
|
+
- Fixes `ZeroDivisionError` in `Scheduler.availability` if there
|
|
23
|
+
are blocking resources, but there are no allocations in the
|
|
24
|
+
specified time period.
|
|
25
|
+
[Daverball]
|
|
26
|
+
|
|
4
27
|
1.2.0 (13.08.2026)
|
|
5
28
|
~~~~~~~~~~~~~~~~~~~
|
|
6
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libres
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A library to reserve things
|
|
5
5
|
Author-email: Denis Krienbühl <denis@href.ch>
|
|
6
6
|
Maintainer-email: Seantis GmbH <info@seantis.ch>
|
|
@@ -12,27 +12,27 @@ Classifier: Intended Audience :: Developers
|
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
20
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
21
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
22
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
23
|
Description-Content-Type: text/x-rst
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
Requires-Dist: python-dateutil
|
|
26
26
|
Requires-Dist: pytz
|
|
27
27
|
Requires-Dist: sedate>=1.0.0
|
|
28
|
-
Requires-Dist: SQLAlchemy<2.
|
|
28
|
+
Requires-Dist: SQLAlchemy<2.2.0,>=2.1.0
|
|
29
29
|
Dynamic: license-file
|
|
30
30
|
|
|
31
31
|
Libres
|
|
32
32
|
======
|
|
33
33
|
|
|
34
34
|
Libres is a reservations management library to reserve things like tables at
|
|
35
|
-
a restaurant or tickets at an event. It works with Python 3.
|
|
35
|
+
a restaurant or tickets at an event. It works with Python 3.11+
|
|
36
36
|
and requires Postgresql 9.2+.
|
|
37
37
|
|
|
38
38
|
`Documentation <http://libres.readthedocs.org/en/latest/>`_ | `Source <http://github.com/seantis/libres/>`_ | `Bugs <http://github.com/seantis/libres/issues>`_
|
|
@@ -116,6 +116,29 @@ After this, create a new release on Github.
|
|
|
116
116
|
Changelog
|
|
117
117
|
---------
|
|
118
118
|
|
|
119
|
+
1.4.0 (15.10.2026)
|
|
120
|
+
~~~~~~~~~~~~~~~~~~~
|
|
121
|
+
|
|
122
|
+
- Adds support for SQLAlchemy 2.1
|
|
123
|
+
[Daverball]
|
|
124
|
+
|
|
125
|
+
- Drops support for SQLAlchemy 2.0
|
|
126
|
+
[Daverball]
|
|
127
|
+
|
|
128
|
+
1.3.0 (15.10.2026)
|
|
129
|
+
~~~~~~~~~~~~~~~~~~~
|
|
130
|
+
|
|
131
|
+
- Adds Python 3.15 support
|
|
132
|
+
[Daverball]
|
|
133
|
+
|
|
134
|
+
- Drops Python 3.10 support
|
|
135
|
+
[Daverball]
|
|
136
|
+
|
|
137
|
+
- Fixes `ZeroDivisionError` in `Scheduler.availability` if there
|
|
138
|
+
are blocking resources, but there are no allocations in the
|
|
139
|
+
specified time period.
|
|
140
|
+
[Daverball]
|
|
141
|
+
|
|
119
142
|
1.2.0 (13.08.2026)
|
|
120
143
|
~~~~~~~~~~~~~~~~~~~
|
|
121
144
|
|
|
@@ -2,7 +2,7 @@ Libres
|
|
|
2
2
|
======
|
|
3
3
|
|
|
4
4
|
Libres is a reservations management library to reserve things like tables at
|
|
5
|
-
a restaurant or tickets at an event. It works with Python 3.
|
|
5
|
+
a restaurant or tickets at an event. It works with Python 3.11+
|
|
6
6
|
and requires Postgresql 9.2+.
|
|
7
7
|
|
|
8
8
|
`Documentation <http://libres.readthedocs.org/en/latest/>`_ | `Source <http://github.com/seantis/libres/>`_ | `Bugs <http://github.com/seantis/libres/issues>`_
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
name = "libres"
|
|
7
7
|
dynamic = ["version", "readme"]
|
|
8
8
|
description = "A library to reserve things"
|
|
9
|
-
requires-python = ">=3.
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
10
|
authors = [
|
|
11
11
|
{ name = "Denis Krienbühl", email = "denis@href.ch" },
|
|
12
12
|
]
|
|
@@ -22,11 +22,11 @@ classifiers = [
|
|
|
22
22
|
"Operating System :: OS Independent",
|
|
23
23
|
"Programming Language :: Python",
|
|
24
24
|
"Programming Language :: Python :: 3",
|
|
25
|
-
"Programming Language :: Python :: 3.10",
|
|
26
25
|
"Programming Language :: Python :: 3.11",
|
|
27
26
|
"Programming Language :: Python :: 3.12",
|
|
28
27
|
"Programming Language :: Python :: 3.13",
|
|
29
28
|
"Programming Language :: Python :: 3.14",
|
|
29
|
+
"Programming Language :: Python :: 3.15",
|
|
30
30
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
31
31
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
32
32
|
]
|
|
@@ -34,7 +34,7 @@ dependencies = [
|
|
|
34
34
|
"python-dateutil",
|
|
35
35
|
"pytz",
|
|
36
36
|
"sedate >= 1.0.0",
|
|
37
|
-
"SQLAlchemy >= 2.
|
|
37
|
+
"SQLAlchemy >= 2.1.0, < 2.2.0",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
[project.urls]
|
|
@@ -73,7 +73,7 @@ lint = [
|
|
|
73
73
|
]
|
|
74
74
|
test = [
|
|
75
75
|
"jsonpickle",
|
|
76
|
-
"
|
|
76
|
+
"psycopg[binary]",
|
|
77
77
|
"pytest",
|
|
78
78
|
"pytest-codecov[git]",
|
|
79
79
|
"testing.postgresql",
|
|
@@ -100,7 +100,7 @@ branch = true
|
|
|
100
100
|
source = ["src"]
|
|
101
101
|
|
|
102
102
|
[tool.bumpversion]
|
|
103
|
-
current_version = "1.
|
|
103
|
+
current_version = "1.4.0"
|
|
104
104
|
commit = true
|
|
105
105
|
message = "Release {new_version}"
|
|
106
106
|
tag = true
|
|
@@ -124,7 +124,7 @@ replace = """
|
|
|
124
124
|
"""
|
|
125
125
|
|
|
126
126
|
[tool.mypy]
|
|
127
|
-
python_version = "3.
|
|
127
|
+
python_version = "3.11"
|
|
128
128
|
namespace_packages = true
|
|
129
129
|
explicit_package_bases = true
|
|
130
130
|
strict = true
|
|
@@ -192,7 +192,7 @@ include = [
|
|
|
192
192
|
]
|
|
193
193
|
line-length = 79
|
|
194
194
|
indent-width = 4
|
|
195
|
-
target-version = "
|
|
195
|
+
target-version = "py311"
|
|
196
196
|
|
|
197
197
|
[tool.ruff.lint]
|
|
198
198
|
select = [
|
|
@@ -326,11 +326,11 @@ docstring-code-line-length = "dynamic"
|
|
|
326
326
|
[tool.tox]
|
|
327
327
|
requires = ["tox>=4.21"]
|
|
328
328
|
envlist = [
|
|
329
|
-
"3.10",
|
|
330
329
|
"3.11",
|
|
331
330
|
"3.12",
|
|
332
331
|
"3.13",
|
|
333
332
|
"3.14",
|
|
333
|
+
"3.15",
|
|
334
334
|
"flake8",
|
|
335
335
|
"ruff",
|
|
336
336
|
"bandit",
|
|
@@ -339,11 +339,11 @@ envlist = [
|
|
|
339
339
|
]
|
|
340
340
|
|
|
341
341
|
[tool.tox.gh.python]
|
|
342
|
-
"3.
|
|
343
|
-
"3.
|
|
344
|
-
"3.12" = ["3.12"]
|
|
342
|
+
"3.11" = ["3.11"]
|
|
343
|
+
"3.12" = ["3.12", "flake8", "bandit", "ruff", "mypy"]
|
|
345
344
|
"3.13" = ["3.13"]
|
|
346
345
|
"3.14" = ["3.14"]
|
|
346
|
+
"3.15" = ["3.15"]
|
|
347
347
|
|
|
348
348
|
[tool.tox.env_run_base]
|
|
349
349
|
use_develop = true
|
|
@@ -359,37 +359,37 @@ commands = [
|
|
|
359
359
|
],
|
|
360
360
|
]
|
|
361
361
|
[tool.tox.env.ruff]
|
|
362
|
-
base_python = ["python3.
|
|
362
|
+
base_python = ["python3.12"]
|
|
363
363
|
skip_install = true
|
|
364
364
|
dependency_groups = ["ruff"]
|
|
365
365
|
commands = [["ruff", "check"]]
|
|
366
366
|
|
|
367
367
|
[tool.tox.env.flake8]
|
|
368
|
-
base_python = ["python3.
|
|
368
|
+
base_python = ["python3.12"]
|
|
369
369
|
skip_install = true
|
|
370
370
|
dependency_groups = ["flake8"]
|
|
371
371
|
commands = [["flake8", "src{/}", "tests{/}"]]
|
|
372
372
|
|
|
373
373
|
[tool.tox.env.bandit]
|
|
374
|
-
base_python = ["python3.
|
|
374
|
+
base_python = ["python3.12"]
|
|
375
375
|
skip_install = true
|
|
376
376
|
dependency_groups = ["bandit"]
|
|
377
377
|
commands = [["bandit", "-q", "-c", "pyproject.toml", "-r", "src"]]
|
|
378
378
|
|
|
379
379
|
[tool.tox.env.mypy]
|
|
380
|
-
base_python = ["python3.
|
|
380
|
+
base_python = ["python3.12"]
|
|
381
381
|
skip_install = true
|
|
382
382
|
dependency_groups = ["mypy"]
|
|
383
383
|
commands = [
|
|
384
|
-
["mypy", "-p", "libres", "--python-version", "3.10"],
|
|
385
384
|
["mypy", "-p", "libres", "--python-version", "3.11"],
|
|
386
385
|
["mypy", "-p", "libres", "--python-version", "3.12"],
|
|
387
386
|
["mypy", "-p", "libres", "--python-version", "3.13"],
|
|
388
387
|
["mypy", "-p", "libres", "--python-version", "3.14"],
|
|
388
|
+
["mypy", "-p", "libres", "--python-version", "3.15"],
|
|
389
389
|
]
|
|
390
390
|
|
|
391
391
|
[tool.tox.env.report]
|
|
392
|
-
base_python = ["python3.
|
|
392
|
+
base_python = ["python3.12"]
|
|
393
393
|
skip_install = true
|
|
394
394
|
ignore_errors = true
|
|
395
395
|
ignore_outcome = true
|
|
@@ -14,7 +14,7 @@ from typing import Literal
|
|
|
14
14
|
from typing import TYPE_CHECKING
|
|
15
15
|
if TYPE_CHECKING:
|
|
16
16
|
from collections.abc import Callable
|
|
17
|
-
from collections.abc import
|
|
17
|
+
from collections.abc import Generator
|
|
18
18
|
from sqlalchemy.orm import Session
|
|
19
19
|
from sqlalchemy.orm.session import SessionTransaction
|
|
20
20
|
from typing import TypeAlias
|
|
@@ -164,7 +164,7 @@ class Context:
|
|
|
164
164
|
return f"<Libres Context(name='{self.name}')>"
|
|
165
165
|
|
|
166
166
|
@contextmanager
|
|
167
|
-
def as_current_context(self) ->
|
|
167
|
+
def as_current_context(self) -> Generator[None]:
|
|
168
168
|
with self.registry.context(self.name):
|
|
169
169
|
yield
|
|
170
170
|
|
|
@@ -11,7 +11,7 @@ from libres.context.core import Context
|
|
|
11
11
|
from typing import TYPE_CHECKING
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from collections.abc import Callable
|
|
14
|
-
from collections.abc import
|
|
14
|
+
from collections.abc import Generator
|
|
15
15
|
from uuid import UUID
|
|
16
16
|
|
|
17
17
|
|
|
@@ -143,7 +143,7 @@ class Registry:
|
|
|
143
143
|
self.local.current_context = self.get_context(name)
|
|
144
144
|
|
|
145
145
|
@contextmanager
|
|
146
|
-
def context(self, name: str) ->
|
|
146
|
+
def context(self, name: str) -> Generator[Context]:
|
|
147
147
|
previous = self.current_context.name
|
|
148
148
|
self.switch_context(name)
|
|
149
149
|
try:
|
|
@@ -36,7 +36,7 @@ if TYPE_CHECKING:
|
|
|
36
36
|
from sedate.types import TzInfoOrName
|
|
37
37
|
from sqlalchemy.orm import Query
|
|
38
38
|
from typing import NamedTuple
|
|
39
|
-
from
|
|
39
|
+
from typing import Self
|
|
40
40
|
|
|
41
41
|
from libres.db.models import ReservedSlot
|
|
42
42
|
from libres.modules.rasterizer import Raster
|
|
@@ -521,7 +521,7 @@ class Queries(ContextServicesMixin):
|
|
|
521
521
|
|
|
522
522
|
# first get the session ids which are expired
|
|
523
523
|
query: Query[tuple[UUID, datetime, datetime | None]]
|
|
524
|
-
query = self.session.query(
|
|
524
|
+
query = self.session.query(
|
|
525
525
|
Reservation.session_id,
|
|
526
526
|
func.max(Reservation.created),
|
|
527
527
|
func.max(Reservation.modified)
|
|
@@ -33,10 +33,14 @@ if TYPE_CHECKING:
|
|
|
33
33
|
from collections.abc import Collection
|
|
34
34
|
from collections.abc import Iterable
|
|
35
35
|
from collections.abc import Iterator
|
|
36
|
+
from collections.abc import Sequence
|
|
36
37
|
from sedate.types import DateLike
|
|
38
|
+
from sqlalchemy.engine import Row
|
|
37
39
|
from sqlalchemy.orm import Query
|
|
40
|
+
from typing import NotRequired
|
|
38
41
|
from typing import TypeAlias
|
|
39
|
-
from
|
|
42
|
+
from typing import TypedDict
|
|
43
|
+
from typing import Self
|
|
40
44
|
|
|
41
45
|
from libres.context.core import Context
|
|
42
46
|
from libres.modules.rasterizer import Raster
|
|
@@ -417,12 +421,12 @@ class Scheduler(ContextServicesMixin):
|
|
|
417
421
|
def allocation_dates_by_group(
|
|
418
422
|
self,
|
|
419
423
|
group: UUID
|
|
420
|
-
) -> list[
|
|
424
|
+
) -> list[Row[datetime, datetime]]:
|
|
421
425
|
|
|
422
426
|
return self.allocations_by_group(group).with_entities(
|
|
423
427
|
Allocation._start,
|
|
424
428
|
Allocation._end
|
|
425
|
-
).
|
|
429
|
+
).all()
|
|
426
430
|
|
|
427
431
|
def allocation_mirrors_by_master(
|
|
428
432
|
self,
|
|
@@ -861,6 +865,8 @@ class Scheduler(ContextServicesMixin):
|
|
|
861
865
|
for allocation, availability, _ in allocations:
|
|
862
866
|
total += availability
|
|
863
867
|
count += allocation.quota
|
|
868
|
+
if not count:
|
|
869
|
+
return 0.0
|
|
864
870
|
return total / count
|
|
865
871
|
|
|
866
872
|
def move_allocation(
|
|
@@ -937,7 +943,10 @@ class Scheduler(ContextServicesMixin):
|
|
|
937
943
|
if change.is_master: # (mirrors return the same values)
|
|
938
944
|
for pending in change.pending_reservations.with_entities(
|
|
939
945
|
Reservation.start, Reservation.end):
|
|
940
|
-
|
|
946
|
+
# FIXME: Technically start/end can be None, we may
|
|
947
|
+
# want to remove this ability, since we don't
|
|
948
|
+
# use it anywhere anymore
|
|
949
|
+
if not new.contains(pending.start, pending.end):
|
|
941
950
|
raise errors.AffectedPendingReservationError(
|
|
942
951
|
pending
|
|
943
952
|
)
|
|
@@ -1454,7 +1463,7 @@ class Scheduler(ContextServicesMixin):
|
|
|
1454
1463
|
# write out the slots
|
|
1455
1464
|
slots_to_reserve = []
|
|
1456
1465
|
|
|
1457
|
-
dates:
|
|
1466
|
+
dates: Sequence[_dtrange]
|
|
1458
1467
|
if reservation.target_type == 'group':
|
|
1459
1468
|
dates = self.allocation_dates_by_group(reservation.target)
|
|
1460
1469
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libres
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A library to reserve things
|
|
5
5
|
Author-email: Denis Krienbühl <denis@href.ch>
|
|
6
6
|
Maintainer-email: Seantis GmbH <info@seantis.ch>
|
|
@@ -12,27 +12,27 @@ Classifier: Intended Audience :: Developers
|
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
20
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
21
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
22
|
-
Requires-Python: >=3.
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
23
|
Description-Content-Type: text/x-rst
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
Requires-Dist: python-dateutil
|
|
26
26
|
Requires-Dist: pytz
|
|
27
27
|
Requires-Dist: sedate>=1.0.0
|
|
28
|
-
Requires-Dist: SQLAlchemy<2.
|
|
28
|
+
Requires-Dist: SQLAlchemy<2.2.0,>=2.1.0
|
|
29
29
|
Dynamic: license-file
|
|
30
30
|
|
|
31
31
|
Libres
|
|
32
32
|
======
|
|
33
33
|
|
|
34
34
|
Libres is a reservations management library to reserve things like tables at
|
|
35
|
-
a restaurant or tickets at an event. It works with Python 3.
|
|
35
|
+
a restaurant or tickets at an event. It works with Python 3.11+
|
|
36
36
|
and requires Postgresql 9.2+.
|
|
37
37
|
|
|
38
38
|
`Documentation <http://libres.readthedocs.org/en/latest/>`_ | `Source <http://github.com/seantis/libres/>`_ | `Bugs <http://github.com/seantis/libres/issues>`_
|
|
@@ -116,6 +116,29 @@ After this, create a new release on Github.
|
|
|
116
116
|
Changelog
|
|
117
117
|
---------
|
|
118
118
|
|
|
119
|
+
1.4.0 (15.10.2026)
|
|
120
|
+
~~~~~~~~~~~~~~~~~~~
|
|
121
|
+
|
|
122
|
+
- Adds support for SQLAlchemy 2.1
|
|
123
|
+
[Daverball]
|
|
124
|
+
|
|
125
|
+
- Drops support for SQLAlchemy 2.0
|
|
126
|
+
[Daverball]
|
|
127
|
+
|
|
128
|
+
1.3.0 (15.10.2026)
|
|
129
|
+
~~~~~~~~~~~~~~~~~~~
|
|
130
|
+
|
|
131
|
+
- Adds Python 3.15 support
|
|
132
|
+
[Daverball]
|
|
133
|
+
|
|
134
|
+
- Drops Python 3.10 support
|
|
135
|
+
[Daverball]
|
|
136
|
+
|
|
137
|
+
- Fixes `ZeroDivisionError` in `Scheduler.availability` if there
|
|
138
|
+
are blocking resources, but there are no allocations in the
|
|
139
|
+
specified time period.
|
|
140
|
+
[Daverball]
|
|
141
|
+
|
|
119
142
|
1.2.0 (13.08.2026)
|
|
120
143
|
~~~~~~~~~~~~~~~~~~~
|
|
121
144
|
|
|
@@ -5,12 +5,13 @@ import sedate
|
|
|
5
5
|
|
|
6
6
|
from copy import copy
|
|
7
7
|
from datetime import date, datetime, timedelta, time
|
|
8
|
+
from functools import partial
|
|
8
9
|
from libres.db.models import Reservation, Allocation
|
|
9
10
|
from libres.modules import errors, events
|
|
10
11
|
from libres.modules import utils
|
|
11
12
|
from operator import attrgetter
|
|
12
13
|
from unittest.mock import Mock
|
|
13
|
-
from sqlalchemy.exc import MultipleResultsFound, NoResultFound
|
|
14
|
+
from sqlalchemy.exc import MultipleResultsFound, NoResultFound
|
|
14
15
|
from uuid import uuid4 as new_uuid
|
|
15
16
|
|
|
16
17
|
|
|
@@ -433,6 +434,7 @@ def test_reserve_blocking_resources(
|
|
|
433
434
|
blocked_scheduler: Scheduler
|
|
434
435
|
) -> None:
|
|
435
436
|
|
|
437
|
+
assert blocked_scheduler.availability() == 0.0
|
|
436
438
|
assert scheduler.resource in blocked_scheduler.blocking_resources
|
|
437
439
|
|
|
438
440
|
# create an allocation on the blocking scheduler
|
|
@@ -484,6 +486,7 @@ def test_reserve_blocking_resources(
|
|
|
484
486
|
(25.0, True),
|
|
485
487
|
(50.0, False),
|
|
486
488
|
]
|
|
489
|
+
assert blocked_scheduler.availability() == 75.0
|
|
487
490
|
|
|
488
491
|
# reserving a slot that's partially blocked will fail
|
|
489
492
|
with pytest.raises(errors.AlreadyReservedError):
|
|
@@ -520,6 +523,7 @@ def test_reserve_blocking_resources(
|
|
|
520
523
|
(25.0, False),
|
|
521
524
|
(75.0, True),
|
|
522
525
|
]
|
|
526
|
+
assert blocked_scheduler.availability() == 25.0
|
|
523
527
|
|
|
524
528
|
|
|
525
529
|
def test_change_email(scheduler: Scheduler) -> None:
|
|
@@ -1906,6 +1910,7 @@ def test_quota_changes_advanced(scheduler: Scheduler) -> None:
|
|
|
1906
1910
|
def test_availability(scheduler: Scheduler) -> None:
|
|
1907
1911
|
start = datetime(2011, 1, 1, 15, 0)
|
|
1908
1912
|
end = datetime(2011, 1, 1, 16, 0)
|
|
1913
|
+
assert not scheduler.availability()
|
|
1909
1914
|
|
|
1910
1915
|
a = scheduler.allocate(
|
|
1911
1916
|
(start, end), raster=15, partly_available=True)[0]
|
|
@@ -2091,7 +2096,7 @@ def test_data_coding(scheduler: Scheduler) -> None:
|
|
|
2091
2096
|
end = datetime(2014, 1, 30, 19, 0)
|
|
2092
2097
|
|
|
2093
2098
|
# this won't work as json doesn't do datetimes by default
|
|
2094
|
-
with pytest.raises(
|
|
2099
|
+
with pytest.raises(TypeError, match=r'not JSON serializable'):
|
|
2095
2100
|
scheduler.allocate((start, end), data=data)
|
|
2096
2101
|
|
|
2097
2102
|
scheduler.rollback()
|
|
@@ -2102,8 +2107,8 @@ def test_data_coding(scheduler: Scheduler) -> None:
|
|
|
2102
2107
|
|
|
2103
2108
|
def session_provider(context: Context) -> SessionProvider:
|
|
2104
2109
|
return SessionProvider(context.get_setting('dsn'), engine_config=dict(
|
|
2105
|
-
json_serializer=jsonpickle.encode,
|
|
2106
|
-
json_deserializer=jsonpickle.decode
|
|
2110
|
+
json_serializer=partial(jsonpickle.encode, keys=True),
|
|
2111
|
+
json_deserializer=partial(jsonpickle.decode, keys=True)
|
|
2107
2112
|
))
|
|
2108
2113
|
|
|
2109
2114
|
# setting the service again will get rid of the existing cached value
|
|
@@ -7,7 +7,7 @@ from datetime import datetime
|
|
|
7
7
|
from libres.context.session import SessionProvider
|
|
8
8
|
from libres.db.models import Allocation
|
|
9
9
|
from libres.db.scheduler import Scheduler
|
|
10
|
-
from
|
|
10
|
+
from psycopg.errors import OperationalError
|
|
11
11
|
from threading import Thread
|
|
12
12
|
from uuid import uuid4 as new_uuid
|
|
13
13
|
|
|
@@ -105,7 +105,10 @@ def test_collision(scheduler: Scheduler) -> None:
|
|
|
105
105
|
exceptions = (t1.exception, t2.exception)
|
|
106
106
|
|
|
107
107
|
def is_rollback(ex: Exception | None) -> bool:
|
|
108
|
-
return
|
|
108
|
+
return (
|
|
109
|
+
isinstance(err := getattr(ex, 'orig', None), OperationalError)
|
|
110
|
+
and (err.sqlstate or '').startswith('40')
|
|
111
|
+
)
|
|
109
112
|
|
|
110
113
|
def is_nothing(ex: Exception | None) -> bool:
|
|
111
114
|
return not is_rollback(ex)
|
|
@@ -147,7 +150,10 @@ def test_non_collision(scheduler: Scheduler) -> None:
|
|
|
147
150
|
exceptions = (t1.exception, t2.exception)
|
|
148
151
|
|
|
149
152
|
def is_rollback(ex: Exception | None) -> bool:
|
|
150
|
-
return
|
|
153
|
+
return (
|
|
154
|
+
isinstance(err := getattr(ex, 'orig', None), OperationalError)
|
|
155
|
+
and (err.sqlstate or '').startswith('40')
|
|
156
|
+
)
|
|
151
157
|
|
|
152
158
|
rollbacks = list(filter(is_rollback, exceptions))
|
|
153
159
|
assert len(rollbacks) == 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|