moat-src 0.8.2__py3-none-any.whl → 0.8.4__py3-none-any.whl

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,3 @@
1
+ from __future__ import annotations
2
+
3
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
@@ -0,0 +1,146 @@
1
+ project:
2
+ authors:
3
+ - email: matthias@urlichs.de
4
+ name: Matthias Urlichs
5
+ classifiers:
6
+ - 'Intended Audience :: Developers'
7
+ - 'Programming Language :: Python :: 3'
8
+ - 'Framework :: AsyncIO'
9
+ - 'Framework :: Trio'
10
+ - 'Framework :: Trio'
11
+ - 'Intended Audience :: Developers'
12
+ - 'License :: OSI Approved'
13
+ - 'Development Status :: 4 - Beta'
14
+ dependencies:
15
+ - anyio ~= 3.0
16
+ description: REPLACE ME
17
+ dynamic:
18
+ - version
19
+ keywords:
20
+ - MoaT
21
+ license:
22
+ file: LICENSE.txt
23
+ name: SUBUNDER
24
+ readme: README.rst
25
+ requires-python: '>=3.8'
26
+ urls:
27
+ homepage: https://m-o-a-t.org
28
+ repository: https://github.com/M-o-a-T/SUBNAME
29
+ tool:
30
+ pytest:
31
+ ini_options:
32
+ log_cli_level: DEBUG
33
+ ruff:
34
+ lint:
35
+ select:
36
+ - ALL
37
+ ignore:
38
+ - ANN
39
+ - PTH
40
+ - PERF
41
+ - D105
42
+ - D107
43
+ - A003
44
+ - S101
45
+ - RUF001
46
+ - RUF002
47
+ - PLW1514
48
+ - D2
49
+ - D3
50
+ - D4
51
+ - T2
52
+ - FBT
53
+ - TRY003
54
+ - EM10
55
+ - PLR
56
+ - C
57
+ - RET50
58
+ - TD
59
+ - FIX
60
+ - N
61
+ - ERA
62
+ - BLE001
63
+ explicit-preview-rules: true
64
+ flake8-comprehensions:
65
+ allow-dict-calls-with-keyword-arguments: true
66
+ flake8-builtins:
67
+ builtins-ignorelist:
68
+ - id
69
+ - help
70
+ isort:
71
+ no-lines-before:
72
+ - future
73
+ required-imports:
74
+ - "from __future__ import annotations"
75
+ section-order:
76
+ - future
77
+ - typing
78
+ - standard-library
79
+ - first-party
80
+ - upy
81
+ - moat
82
+ - local-folder
83
+ - third-party
84
+ extra-standard-library:
85
+ - pytest
86
+ - anyio
87
+ force-to-top:
88
+ - moat.util
89
+ sections:
90
+ moat:
91
+ - moat
92
+ upy:
93
+ - micropython
94
+ - machine
95
+ - esp
96
+ typing:
97
+ - typing
98
+ preview: true
99
+ line-length: 99
100
+ black:
101
+ line-length: 99
102
+ flake8:
103
+ max-line-length: 99
104
+ ignore:
105
+ - E123
106
+ - E127
107
+ - E203
108
+ - E231
109
+ - E402
110
+ - E502
111
+ - E731
112
+ - F401 # covered by pylint
113
+ - F841 # covered by pylint
114
+ - W503
115
+ setuptools:
116
+ packages:
117
+ - SUBDOT
118
+ package-data:
119
+ "*": [ "*.yaml" ]
120
+ setuptools_scm: {}
121
+ pylint:
122
+ messages_control:
123
+ disable:
124
+ - fixme
125
+ - invalid-name
126
+ - no-else-continue
127
+ - no-else-return
128
+ - superfluous-parens
129
+ - too-few-public-methods
130
+ - too-many-arguments
131
+ - too-many-branches
132
+ - too-many-instance-attributes
133
+ - too-many-locals
134
+ - too-many-nested-blocks
135
+ - too-many-return-statements
136
+ - too-many-statements
137
+ - ungrouped-imports
138
+ - unspecified-encoding
139
+ - use-dict-literal
140
+ - wrong-import-order
141
+ tox:
142
+ tox:
143
+ isolated_build: True
144
+ envlist:
145
+ - check
146
+
@@ -0,0 +1,77 @@
1
+ build-system:
2
+ build-backend: setuptools.build_meta
3
+ requires:
4
+ - setuptools
5
+ - wheel
6
+ - setuptools-scm
7
+ project:
8
+ classifiers:
9
+ - 'Intended Audience :: Developers'
10
+ - 'Programming Language :: Python :: 3'
11
+ - 'Framework :: AsyncIO'
12
+ - 'Framework :: Trio'
13
+ - 'Framework :: AnyIO'
14
+ - 'Intended Audience :: Developers'
15
+ - 'License :: OSI Approved'
16
+ - 'Development Status :: 4 - Beta'
17
+ dependencies:
18
+ - anyio ~= 3.0
19
+ dynamic:
20
+ - version
21
+ keywords:
22
+ - MoaT
23
+ license:
24
+ file: LICENSE.txt
25
+ requires-python: '>=3.8'
26
+ urls:
27
+ homepage: https://m-o-a-t.org
28
+ name: SUBNAME
29
+ tool:
30
+ moat:
31
+ fixup: |
32
+ try:
33
+ toml["tool"]["tox"]["tox"]["envlist"].remove("py39")
34
+ except(KeyError,ValueError):
35
+ pass
36
+ flake8:
37
+ max-line-length: 99
38
+ ignore:
39
+ - W503
40
+ - E231
41
+ - E203
42
+
43
+ isort:
44
+ line_length: 99
45
+ multi_line_output: 3
46
+ trailing_comma: DELETE
47
+ profile: black
48
+ setuptools_scm: {}
49
+
50
+ tox:
51
+ tox:
52
+ isolated_build: True
53
+ envlist:
54
+ - check
55
+ - py310
56
+
57
+ testenv:
58
+ setenv:
59
+ - "PYTHONPATH = {env:PYTHONPATH}{:}{toxinidir}"
60
+ deps:
61
+ - pytest
62
+ - trio
63
+ commands:
64
+ - python3 -mpytest tests/
65
+
66
+ "testenv:check":
67
+ commands:
68
+ - black --check moat tests
69
+ - flake8p moat tests
70
+ - pylint moat tests
71
+ deps:
72
+ - flake8
73
+ - flake8-pyproject
74
+ - black
75
+ - pylint
76
+ - pytest
77
+
@@ -0,0 +1,65 @@
1
+ """
2
+ This Trio inspector is geared towards figuring out why the *censored* a
3
+ task is cancelled when no exception shows up.
4
+
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import inspect
10
+ import logging
11
+
12
+ from asyncscope import scope as sc
13
+
14
+ logger = logging.getLogger("trio.inspect")
15
+
16
+
17
+ def debug(*a):
18
+ "logging helper"
19
+ s = sc.get()
20
+ (logger if s is None else s.logger).debug(*a)
21
+
22
+
23
+ class CancelTracer:
24
+ """A Trio inspect module that helps tracking cancel scopes"""
25
+
26
+ # pylint: disable=missing-function-docstring,protected-access
27
+ def __init__(self):
28
+ pass
29
+
30
+ def skip(self, scope):
31
+ if scope._stack is None:
32
+ return True
33
+ if scope._stack[5].f_code.co_name == "connect_tcp":
34
+ return True
35
+ return False
36
+
37
+ def scope_entered(self, scope):
38
+ scope._stack = s = []
39
+ f = inspect.currentframe().f_back
40
+ while f:
41
+ s.append(f)
42
+ f = f.f_back
43
+
44
+ if self.skip(scope):
45
+ return
46
+
47
+ debug("EnterCS %r", scope)
48
+
49
+ def scope_exited(self, scope):
50
+ if self.skip(scope):
51
+ return
52
+ debug("ExitCS %r", scope)
53
+
54
+ def scope_cancelled(self, scope, reason):
55
+ if self.skip(scope):
56
+ return
57
+ # if reason.value == 0:
58
+ # breakpoint()
59
+ debug("KillCS %r %s", scope, reason.name)
60
+
61
+ def task_spawned(self, task):
62
+ debug("EnterT %r", task)
63
+
64
+ def task_exited(self, task):
65
+ debug("ExitT %r", task)
@@ -0,0 +1,89 @@
1
+ """
2
+ MoaT test support
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import io
8
+ import logging
9
+ import shlex
10
+ import sys
11
+ from contextlib import contextmanager
12
+
13
+ from asyncscope import main_scope, scope
14
+ from moat.util import OptCtx, attrdict, wrap_main # pylint:disable=no-name-in-module
15
+
16
+ logger = logging.getLogger(__name__)
17
+
18
+
19
+ async def run(*args, expect_exit=0, do_stdout=True):
20
+ """Call a MoaT command handler"""
21
+ args = ("-c", "/dev/null", *args)
22
+ CFG = {} # load_cfg("moat")
23
+
24
+ if do_stdout:
25
+ CFG["_stdout"] = out = io.StringIO()
26
+ logger.debug(" moat %s", " ".join(shlex.quote(str(x)) for x in args))
27
+ try:
28
+ res = None
29
+ async with (
30
+ OptCtx(main_scope(name="run") if scope.get() is None else None),
31
+ scope.using_scope(),
32
+ ):
33
+ res = await wrap_main(
34
+ args=args,
35
+ wrap=True,
36
+ CFG=CFG,
37
+ cfg=False,
38
+ name="moat",
39
+ sub_pre="moat",
40
+ sub_post="_main.cli",
41
+ )
42
+ if res is None:
43
+ res = attrdict()
44
+ return res
45
+ except SystemExit as exc:
46
+ res = exc
47
+ assert exc.code == expect_exit, exc.code
48
+ return exc
49
+ except Exception as exc:
50
+ while isinstance(exc, ExceptionGroup) and len(exc.exceptions) == 1:
51
+ exc = exc.exceptions[0]
52
+ raise exc
53
+ except BaseException as exc:
54
+ res = exc
55
+ raise
56
+ else:
57
+ assert expect_exit == 0
58
+ return res
59
+ finally:
60
+ if do_stdout:
61
+ if res is not None:
62
+ res.stdout = out.getvalue()
63
+ CFG["_stdout"] = sys.stdout
64
+
65
+
66
+ class DidNotRaise(Exception):
67
+ pass
68
+
69
+
70
+ @contextmanager
71
+ def raises(*exc):
72
+ """
73
+ Like pytest.raises, but handles exception groups
74
+ """
75
+ res = attrdict()
76
+ try:
77
+ yield res
78
+ except exc as e:
79
+ res.value = e
80
+ except ExceptionGroup as e:
81
+ while isinstance(e, ExceptionGroup) and len(e.exceptions) == 1:
82
+ e = e.exceptions[0]
83
+ res.value = e
84
+ if isinstance(e, exc):
85
+ return
86
+ raise
87
+ else:
88
+ res.value = None
89
+ raise DidNotRaise(exc)