forked from balisujohn/localwriter
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdeal_shim.py
More file actions
51 lines (35 loc) · 1.24 KB
/
Copy pathdeal_shim.py
File metadata and controls
51 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# WriterAgent - AI Writing Assistant for LibreOffice
# Copyright (c) 2026 KeithCu
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Deal contract shim.
Provides actual `deal` decorators when deal is installed, or no-op stubs
when running under standard LibreOffice Python runtime where deal is absent.
"""
from typing import Any
deal: Any
try:
import deal as _deal # type: ignore[no-redef]
deal = _deal
except ImportError:
class _DealStub:
"""No-op stub for deal contract decorators when deal is not installed."""
def pre(self, *args, **kwargs):
return lambda f: f
def post(self, *args, **kwargs):
return lambda f: f
def inv(self, *args, **kwargs):
return lambda f: f
def pure(self, f=None, *args, **kwargs):
return f if f is not None else (lambda fn: fn)
def chain(self, *args, **kwargs):
return lambda f: f
def raises(self, *args, **kwargs):
return lambda f: f
def example(self, *args, **kwargs):
return lambda f: f
def ensure(self, *args, **kwargs):
return lambda f: f
def reason(self, *args, **kwargs):
return lambda f: f
deal = _DealStub()