muffin 0.97.2__tar.gz → 0.98.1__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.
- {muffin-0.97.2 → muffin-0.98.1}/PKG-INFO +4 -9
- {muffin-0.97.2 → muffin-0.98.1}/muffin/app.py +7 -4
- {muffin-0.97.2 → muffin-0.98.1}/muffin/utils.py +20 -8
- {muffin-0.97.2 → muffin-0.98.1}/pyproject.toml +17 -17
- {muffin-0.97.2 → muffin-0.98.1}/README.rst +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/__init__.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/constants.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/errors.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/handler.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/manage.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/plugins.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/py.typed +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/pytest.py +0 -0
- {muffin-0.97.2 → muffin-0.98.1}/muffin/types.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: muffin
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.98.1
|
4
4
|
Summary: Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)
|
5
5
|
Home-page: https://github.com/klen/muffin
|
6
6
|
License: MIT
|
@@ -19,18 +19,13 @@ Classifier: Programming Language :: Python :: 3.8
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
22
|
-
Classifier: Programming Language :: Python :: 3
|
23
|
-
Classifier: Programming Language :: Python :: 3.10
|
24
|
-
Classifier: Programming Language :: Python :: 3.11
|
25
|
-
Classifier: Programming Language :: Python :: 3.8
|
26
|
-
Classifier: Programming Language :: Python :: 3.9
|
27
22
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
28
23
|
Classifier: Topic :: Internet :: WWW/HTTP
|
29
24
|
Provides-Extra: standard
|
30
|
-
Requires-Dist: asgi-tools (>=0
|
25
|
+
Requires-Dist: asgi-tools (>=0,<1)
|
31
26
|
Requires-Dist: gunicorn (>=20.1.0,<21.0.0) ; extra == "standard"
|
32
|
-
Requires-Dist: modconfig (>=1
|
33
|
-
Requires-Dist: ujson
|
27
|
+
Requires-Dist: modconfig (>=1,<2)
|
28
|
+
Requires-Dist: ujson
|
34
29
|
Requires-Dist: uvicorn[standard] (>=0.21.1,<0.22.0) ; extra == "standard"
|
35
30
|
Project-URL: Documentation, https://klen.github.io/muffin
|
36
31
|
Project-URL: Repository, https://github.com/klen/muffin
|
@@ -12,7 +12,7 @@ from asgi_tools._compat import aio_wait
|
|
12
12
|
from modconfig import Config
|
13
13
|
|
14
14
|
from muffin.constants import CONFIG_ENV_VARIABLE
|
15
|
-
from muffin.utils import import_submodules
|
15
|
+
from muffin.utils import import_submodules, logger
|
16
16
|
|
17
17
|
if TYPE_CHECKING:
|
18
18
|
from collections.abc import Awaitable
|
@@ -75,7 +75,7 @@ class Application(BaseApp):
|
|
75
75
|
self.manage = Manager(self)
|
76
76
|
|
77
77
|
# Setup logging
|
78
|
-
self.logger =
|
78
|
+
self.logger = logger
|
79
79
|
self.logger.setLevel(self.cfg.LOG_LEVEL)
|
80
80
|
self.logger.propagate = False
|
81
81
|
if not self.logger.handlers:
|
@@ -114,7 +114,7 @@ class Application(BaseApp):
|
|
114
114
|
await aio_wait(*bgtasks)
|
115
115
|
BACKGROUND_TASK.set(None)
|
116
116
|
|
117
|
-
def import_submodules(self, *submodules: str):
|
117
|
+
def import_submodules(self, *submodules: str, silent: bool = False):
|
118
118
|
"""Automatically import submodules.
|
119
119
|
|
120
120
|
.. code-block:: python
|
@@ -127,10 +127,13 @@ class Application(BaseApp):
|
|
127
127
|
# import only specific submodules (in specified order)
|
128
128
|
app.import_submodules('submodule1', 'submodule2')
|
129
129
|
|
130
|
+
# ignore import errors
|
131
|
+
app.import_submodules(silent=True)
|
132
|
+
|
130
133
|
"""
|
131
134
|
parent_frame = stack()[1][0]
|
132
135
|
package_name = parent_frame.f_locals["__name__"]
|
133
|
-
return import_submodules(package_name, *submodules)
|
136
|
+
return import_submodules(package_name, *submodules, silent=silent)
|
134
137
|
|
135
138
|
def run_after_response(self, *tasks: Awaitable):
|
136
139
|
"""Await the given awaitable after the response is completed.
|
@@ -13,6 +13,7 @@ from contextlib import suppress
|
|
13
13
|
from typing import TYPE_CHECKING, Callable, Coroutine, Dict, TypeVar
|
14
14
|
|
15
15
|
from asgi_tools.utils import is_awaitable, to_awaitable
|
16
|
+
from curio.task import logging
|
16
17
|
from sniffio import current_async_library
|
17
18
|
|
18
19
|
from muffin.errors import InvalidAppError
|
@@ -49,6 +50,8 @@ AIOLIBS["asyncio"] = asyncio
|
|
49
50
|
|
50
51
|
TV = TypeVar("TV")
|
51
52
|
|
53
|
+
logger = logging.getLogger("muffin")
|
54
|
+
|
52
55
|
|
53
56
|
def aio_lib() -> str:
|
54
57
|
"""Return first available async library."""
|
@@ -72,15 +75,24 @@ def aio_run(corofn: Callable[..., Coroutine[None, None, TV]], *args, **kwargs) -
|
|
72
75
|
return AIOLIBS[aiolib].run(lambda: corofn(*args, **kwargs))
|
73
76
|
|
74
77
|
|
75
|
-
def import_submodules(
|
76
|
-
|
78
|
+
def import_submodules(
|
79
|
+
package_name: str, *module_names: str, silent: bool = False
|
80
|
+
) -> Dict[str, ModuleType]:
|
81
|
+
"""Import all submodules by the given package name."""
|
77
82
|
package = sys.modules[package_name]
|
78
|
-
|
79
|
-
|
80
|
-
for
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
res = {}
|
84
|
+
for module_name in module_names or (
|
85
|
+
name for _, name, _ in pkgutil.walk_packages(package.__path__)
|
86
|
+
):
|
87
|
+
try:
|
88
|
+
res[module_name] = importlib.import_module(f"{package_name}.{module_name}")
|
89
|
+
except ImportError:
|
90
|
+
if not silent:
|
91
|
+
raise
|
92
|
+
|
93
|
+
logger.debug("Failed to import module: %s", f"{package_name}.{module_name}")
|
94
|
+
|
95
|
+
return res
|
84
96
|
|
85
97
|
|
86
98
|
def import_app(app_uri: str, *, reload: bool = False) -> Application:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "muffin"
|
3
|
-
version = "0.
|
3
|
+
version = "0.98.1"
|
4
4
|
description = "Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)"
|
5
5
|
readme = "README.rst"
|
6
6
|
license = "MIT"
|
@@ -24,20 +24,20 @@ classifiers = [
|
|
24
24
|
homepage = "https://github.com/klen/muffin"
|
25
25
|
repository = "https://github.com/klen/muffin"
|
26
26
|
documentation = "https://klen.github.io/muffin"
|
27
|
-
packages = [{include = "muffin"}]
|
27
|
+
packages = [{ include = "muffin" }]
|
28
28
|
|
29
29
|
[tool.poetry.urls]
|
30
30
|
changelog = "https://raw.githubusercontent.com/klen/muffin/master/CHANGELOG.md"
|
31
31
|
|
32
32
|
[tool.poetry.dependencies]
|
33
33
|
python = "^3.8"
|
34
|
-
asgi-tools = "^0
|
35
|
-
modconfig = "^1
|
36
|
-
ujson = "
|
34
|
+
asgi-tools = "^0"
|
35
|
+
modconfig = "^1"
|
36
|
+
ujson = "*"
|
37
37
|
|
38
38
|
# Optional
|
39
|
-
gunicorn = {version = "^20.1.0", optional = true}
|
40
|
-
uvicorn = {version = "^0.21.1", optional = true, extras = ["standard"]}
|
39
|
+
gunicorn = { version = "^20.1.0", optional = true }
|
40
|
+
uvicorn = { version = "^0.21.1", optional = true, extras = ["standard"] }
|
41
41
|
|
42
42
|
[tool.poetry.scripts]
|
43
43
|
muffin = "muffin.manage:cli"
|
@@ -52,20 +52,20 @@ standard = ["gunicorn", "uvicorn"]
|
|
52
52
|
optional = true
|
53
53
|
|
54
54
|
[tool.poetry.group.dev.dependencies]
|
55
|
-
aiofile = "
|
56
|
-
pytest = "
|
57
|
-
pytest-mypy = "
|
58
|
-
ruff = "
|
59
|
-
pytest-aio = {extras = ["curio", "trio"], version = "
|
60
|
-
pre-commit = "
|
55
|
+
aiofile = "*"
|
56
|
+
pytest = "*"
|
57
|
+
pytest-mypy = "*"
|
58
|
+
ruff = "*"
|
59
|
+
pytest-aio = { extras = ["curio", "trio"], version = "*" }
|
60
|
+
pre-commit = "*"
|
61
61
|
|
62
62
|
[tool.poetry.group.docs]
|
63
63
|
optional = true
|
64
64
|
|
65
65
|
[tool.poetry.group.docs.dependencies]
|
66
|
-
sphinx = "
|
67
|
-
pydata-sphinx-theme = "
|
68
|
-
sphinx-copybutton = "
|
66
|
+
sphinx = "*"
|
67
|
+
pydata-sphinx-theme = "*"
|
68
|
+
sphinx-copybutton = "*"
|
69
69
|
|
70
70
|
[tool.pytest.ini_options]
|
71
71
|
addopts = "-xsvl"
|
@@ -80,7 +80,7 @@ line-length = 100
|
|
80
80
|
target-version = "py38"
|
81
81
|
exclude = [".venv", "docs", "example"]
|
82
82
|
select = ["ALL"]
|
83
|
-
ignore = ["D", "UP", "ANN", "DJ", "EM", "RSE", "SLF", "RET", "S101", "PLR2004", "N804"]
|
83
|
+
ignore = ["D", "UP", "ANN", "DJ", "EM", "RSE", "SLF", "RET", "S101", "PLR2004", "N804", "COM"]
|
84
84
|
|
85
85
|
[tool.ruff.per-file-ignores]
|
86
86
|
"tests/*" = ["ARG", "TRY", "F", "PGH", "PLR", "PLW", "PTH", "SIM", "RET504", "T20"]
|
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
|