py4web-debug-tools 1.2.0__tar.gz → 1.2.2__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.
Files changed (21) hide show
  1. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/.gitignore +2 -1
  2. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/CHANGELOG.md +12 -0
  3. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/PKG-INFO +3 -3
  4. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/pyproject.toml +2 -2
  5. py4web_debug_tools-1.2.2/src/py4web_debug/__about__.py +1 -0
  6. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/core.py +2 -1
  7. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/debugbar.py +1 -2
  8. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/dumping.py +10 -20
  9. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/internals.py +12 -4
  10. py4web_debug_tools-1.2.0/src/py4web_debug/__about__.py +0 -1
  11. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/README.md +0 -0
  12. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/__init__.py +0 -0
  13. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/_internals.py +0 -0
  14. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/env.py +0 -0
  15. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/py.typed +0 -0
  16. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/templates/debugbar.html +0 -0
  17. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/templates/dumpdie.html +0 -0
  18. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/templates/error_default.html +0 -0
  19. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/templates/fancy_dumpdie.html +0 -0
  20. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/types.py +0 -0
  21. {py4web_debug_tools-1.2.0 → py4web_debug_tools-1.2.2}/src/py4web_debug/wsgi.py +0 -0
@@ -4,4 +4,5 @@ apps
4
4
  build
5
5
  dist
6
6
  *.egg-info
7
- .idea
7
+ .idea
8
+ .env
@@ -2,6 +2,18 @@
2
2
 
3
3
  <!--next-version-placeholder-->
4
4
 
5
+ ## v1.2.2 (2024-11-20)
6
+
7
+ ### Fix
8
+
9
+ * Replace 'self' with 'patch_py4' for better stability ([`6987942`](https://github.com/trialandsuccess/py4web-debug-tools/commit/6987942347b993cf767166b6f3dac90e75989130))
10
+
11
+ ## v1.2.1 (2024-11-20)
12
+
13
+ ### Fix
14
+
15
+ * Allow logger to be set to False in case you're using py4webs default logger (PY4WEB_ERRORLOG=:stderr) ([`43639f3`](https://github.com/trialandsuccess/py4web-debug-tools/commit/43639f377d92b2f8b96bbdb31f61251fde95f831))
16
+
5
17
  ## v1.2.0 (2023-11-06)
6
18
  ### Feature
7
19
  * Allow custom `error_logger` for tools.enable ([`a8301bc`](https://github.com/trialandsuccess/py4web-debug-tools/commit/a8301bc1762984fc5af420075acdc09e97bcc378))
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: py4web-debug-tools
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Debug Tools for py4web
5
5
  Project-URL: Documentation, https://github.com/trialandsuccess/py4web-debug-tools#readme
6
6
  Project-URL: Issues, https://github.com/trialandsuccess/py4web-debug-tools/issues
7
7
  Project-URL: Source, https://github.com/trialandsuccess/py4web-debug-tools
8
8
  Author-email: Robin van der Noord <contact@trialandsuccess.nl>
9
- License-Expression: MIT
9
+ License: MIT
10
10
  Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3.10
@@ -110,7 +110,9 @@ exclude = ["venv", ".bak"]
110
110
  [tool.ruff]
111
111
  target-version = "py311"
112
112
  line-length = 120
113
+ extend-exclude = ["*.bak/", "venv*/"]
113
114
 
115
+ [tool.ruff.lint]
114
116
  select = [
115
117
  "F", # pyflake error
116
118
  "E", # pycodestyle error
@@ -129,8 +131,6 @@ unfixable = [
129
131
  # Don't touch unused imports
130
132
  "F401",
131
133
  ]
132
- extend-exclude = ["*.bak/", "venv*/"]
133
-
134
134
  ignore = [
135
135
  "RUF013" # implicit Optional
136
136
  ]
@@ -0,0 +1 @@
1
+ __version__ = "1.2.2"
@@ -45,7 +45,8 @@ class DebugTools:
45
45
  # error screen settings:
46
46
  errorpage_enabled: bool = None, # value of 'enabled' is used by default
47
47
  errorpage_renderer: T_Renderer = None,
48
- error_logger: T_Logger = None,
48
+ # can be set to False to disable (e.g. when using PY4WEB_ERRORLOG: ":stderr"):
49
+ error_logger: T_Logger | typing.Literal[False] | None = None,
49
50
  # debugbar settings:
50
51
  debugbar_enabled: bool = None, # value of 'enabled' is used by default
51
52
  debugbar_fancy_rendering: bool = True,
@@ -160,8 +160,7 @@ def convert_for_debugbar(value: typing.Any) -> str:
160
160
  return _prune_long_values(value)
161
161
 
162
162
 
163
- class DummyDebugBar(TypedFixture):
164
- ...
163
+ class DummyDebugBar(TypedFixture): ...
165
164
 
166
165
 
167
166
  class DebugBar(TypedFixture):
@@ -10,35 +10,25 @@ from .env import is_debug
10
10
 
11
11
 
12
12
  class PossiblyAsDict(typing.Protocol):
13
- def as_dict(self) -> dict[str, typing.Any]:
14
- ...
13
+ def as_dict(self) -> dict[str, typing.Any]: ...
15
14
 
16
- def asdict(self) -> dict[str, typing.Any]:
17
- ...
15
+ def asdict(self) -> dict[str, typing.Any]: ...
18
16
 
19
- def _asdict(self) -> dict[str, typing.Any]:
20
- ...
17
+ def _asdict(self) -> dict[str, typing.Any]: ...
21
18
 
22
- def _as_dict(self) -> dict[str, typing.Any]:
23
- ...
19
+ def _as_dict(self) -> dict[str, typing.Any]: ...
24
20
 
25
- def to_dict(self) -> dict[str, typing.Any]:
26
- ...
21
+ def to_dict(self) -> dict[str, typing.Any]: ...
27
22
 
28
- def todict(self) -> dict[str, typing.Any]:
29
- ...
23
+ def todict(self) -> dict[str, typing.Any]: ...
30
24
 
31
- def _todict(self) -> dict[str, typing.Any]:
32
- ...
25
+ def _todict(self) -> dict[str, typing.Any]: ...
33
26
 
34
- def _to_dict(self) -> dict[str, typing.Any]:
35
- ...
27
+ def _to_dict(self) -> dict[str, typing.Any]: ...
36
28
 
37
- def __json__(self) -> dict[str, typing.Any]:
38
- ...
29
+ def __json__(self) -> dict[str, typing.Any]: ...
39
30
 
40
- def as_list(self) -> list[typing.Any]:
41
- ...
31
+ def as_list(self) -> list[typing.Any]: ...
42
32
 
43
33
 
44
34
  class DDJsonEncoder(ConfigurableJsonEncoder):
@@ -120,9 +120,14 @@ T_Logger = typing.Callable[[ErrorSnapshot], None]
120
120
  class patch_py4:
121
121
  # THIS IS ONLY CALLED ONCE, WHEN tools.enable IS CALLED OR py4web_debug.wsgi IS USED!
122
122
  renderer: T_Renderer | None = None
123
- logger: T_Logger | None = None
123
+ logger: T_Logger | typing.Literal[False] | None = None
124
+
125
+ def __init__(_, renderer: T_Renderer = None, logger: T_Logger | bool | None = None):
126
+ # note: don't use self, use patch_py4 instead
127
+ if logger is True:
128
+ # use default logger:
129
+ logger = None
124
130
 
125
- def __init__(self, renderer: T_Renderer = None, logger: T_Logger = None):
126
131
  def custom_catch_errors(app_name: str, func: AnyFunc) -> typing.Callable[..., str]:
127
132
  """Catches and logs errors in an action; also sets request.app_name"""
128
133
 
@@ -148,7 +153,10 @@ class patch_py4:
148
153
  except Exception as e:
149
154
  err_code = 500
150
155
  snapshot = get_error_snapshot()
151
- (self.logger or default_error_logger)(snapshot)
156
+ if patch_py4.logger is not False:
157
+ # False - don't log
158
+ # None - default logger
159
+ (patch_py4.logger or default_error_logger)(snapshot)
152
160
 
153
161
  ticket_uuid = error_logger.log(request.app_name, snapshot) or "unknown"
154
162
  response.status = err_code
@@ -175,4 +183,4 @@ class patch_py4:
175
183
  # allows swapping renderer on the fly with tools.set_renderer():
176
184
  patch_py4.renderer = renderer
177
185
  _logger = getattr(patch_py4, "logger", None) or logger
178
- patch_py4.logger = staticmethod(_logger) if _logger else None
186
+ patch_py4.logger = staticmethod(_logger) if callable(_logger) else _logger
@@ -1 +0,0 @@
1
- __version__ = "1.2.0"