python-json-logger 4.3.0.dev2__tar.gz → 4.3.0.dev4__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 (32) hide show
  1. {python_json_logger-4.3.0.dev2/src/python_json_logger.egg-info → python_json_logger-4.3.0.dev4}/PKG-INFO +1 -1
  2. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/pyproject.toml +6 -1
  3. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4/src/python_json_logger.egg-info}/PKG-INFO +1 -1
  4. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/python_json_logger.egg-info/SOURCES.txt +1 -2
  5. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/core.py +11 -3
  6. python_json_logger-4.3.0.dev2/tests/test_release.py +0 -184
  7. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/LICENSE +0 -0
  8. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/MANIFEST.in +0 -0
  9. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/README.md +0 -0
  10. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/scripts/benchmark_plots.py +0 -0
  11. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/scripts/benchmark_report.py +0 -0
  12. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/setup.cfg +0 -0
  13. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/python_json_logger.egg-info/dependency_links.txt +0 -0
  14. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/python_json_logger.egg-info/top_level.txt +0 -0
  15. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/__init__.py +0 -0
  16. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/defaults.py +0 -0
  17. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/exception.py +0 -0
  18. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/json.py +0 -0
  19. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/jsonlogger.py +0 -0
  20. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/msgspec.py +0 -0
  21. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/orjson.py +0 -0
  22. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/py.typed +0 -0
  23. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/src/pythonjsonlogger/utils.py +0 -0
  24. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/__init__.py +0 -0
  25. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_benchmark_report.py +0 -0
  26. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_cookbook.py +0 -0
  27. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_deprecation.py +0 -0
  28. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_dictconfig.py +0 -0
  29. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_formatters.py +0 -0
  30. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_missing.py +0 -0
  31. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_publish_docs.py +0 -0
  32. {python_json_logger-4.3.0.dev2 → python_json_logger-4.3.0.dev4}/tests/test_quickstart.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-json-logger
3
- Version: 4.3.0.dev2
3
+ Version: 4.3.0.dev4
4
4
  Summary: JSON Log Formatter for the Python Logging Package
5
5
  Author-email: Zakaria Zajac <zak@madzak.com>, Nicholas Hairs <info+python-json-logger@nicholashairs.com>
6
6
  Maintainer-email: Nicholas Hairs <info+python-json-logger@nicholashairs.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-json-logger"
7
- version = "4.3.0.dev2"
7
+ version = "4.3.0.dev4"
8
8
  description = "JSON Log Formatter for the Python Logging Package"
9
9
  authors = [
10
10
  {name = "Zakaria Zajac", email = "zak@madzak.com"},
@@ -83,6 +83,11 @@ include = ["pythonjsonlogger*"]
83
83
  [tool.setuptools.package-data]
84
84
  pythonjsonlogger = ["py.typed"]
85
85
 
86
+ [tool.nopt]
87
+ allow-dirty = []
88
+ dev-release-branches = ["main"]
89
+ github-release-types = ["dev", "pre", "final"]
90
+
86
91
  [tool.black]
87
92
  line-length = 100
88
93
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-json-logger
3
- Version: 4.3.0.dev2
3
+ Version: 4.3.0.dev4
4
4
  Summary: JSON Log Formatter for the Python Logging Package
5
5
  Author-email: Zakaria Zajac <zak@madzak.com>, Nicholas Hairs <info+python-json-logger@nicholashairs.com>
6
6
  Maintainer-email: Nicholas Hairs <info+python-json-logger@nicholashairs.com>
@@ -26,5 +26,4 @@ tests/test_dictconfig.py
26
26
  tests/test_formatters.py
27
27
  tests/test_missing.py
28
28
  tests/test_publish_docs.py
29
- tests/test_quickstart.py
30
- tests/test_release.py
29
+ tests/test_quickstart.py
@@ -98,10 +98,18 @@ def merge_record_extra(
98
98
  """
99
99
  if rename_fields is None:
100
100
  rename_fields = {}
101
- for key, value in record.__dict__.items():
101
+ record_dict = record.__dict__
102
+ for key in record_dict:
103
+ if key in reserved:
104
+ continue
102
105
  # this allows to have numeric keys
103
- if key not in reserved and not (hasattr(key, "startswith") and key.startswith("_")):
104
- target[rename_fields.get(key, key)] = value
106
+ # an exact str check is faster than hasattr() for the common case
107
+ if type(key) is str: # pylint: disable=unidiomatic-typecheck
108
+ if key.startswith("_"):
109
+ continue
110
+ elif hasattr(key, "startswith") and key.startswith("_"):
111
+ continue
112
+ target[rename_fields.get(key, key)] = record_dict[key]
105
113
  return target
106
114
 
107
115
 
@@ -1,184 +0,0 @@
1
- """Unit tests for release policy; no external build, Git, or API integration tests."""
2
-
3
- import hashlib
4
- import importlib.util
5
- import json
6
- from pathlib import Path
7
-
8
- import pytest
9
-
10
- pytest.importorskip("tomllib")
11
- ROOT = Path(__file__).parents[1]
12
- SPEC = importlib.util.spec_from_file_location("release", ROOT / "scripts/release.py")
13
- assert SPEC is not None and SPEC.loader is not None
14
- release = importlib.util.module_from_spec(SPEC)
15
- SPEC.loader.exec_module(release)
16
-
17
-
18
- def changelog(stamp: str = "2026-10-28", body: str = "### Added\n- A feature.") -> str:
19
- return f"# Changes\n\n## [4.3.0](compare) - {stamp}\n\n{body}\n\n## [4.2.0](old) - 2026-08-15\nOld\n"
20
-
21
-
22
- @pytest.mark.parametrize(
23
- "tag,version",
24
- [
25
- ("v4.3.0", "4.3.0"),
26
- ("v4.3.0.rc1", "4.3.0rc1"),
27
- ("v4.3.0.dev1", "4.3.0.dev1"),
28
- ("v4.3.0.post1", "4.3.0.post1"),
29
- ],
30
- )
31
- def test_release_info(tag: str, version: str) -> None:
32
- actual, notes = release.release_info(tag, version, changelog())
33
- assert actual == version
34
- assert notes == changelog().split("\n\n", 1)[1].split("## [4.2.0]", 1)[0].rstrip() + "\n"
35
- return None
36
-
37
-
38
- @pytest.mark.parametrize(
39
- "tag",
40
- [
41
- "4.3.0",
42
- "v4.3",
43
- "v04.3.0",
44
- "v4.3.0rc1",
45
- "v4.3.0.rc01",
46
- "v4.3.0\n",
47
- "vladamir/test-the-new-thing",
48
- "v4.3.0a1",
49
- "v4.3.0.rc1.extra",
50
- ],
51
- )
52
- def test_invalid_tags(tag: str) -> None:
53
- with pytest.raises(ValueError):
54
- release.release_info(tag, "4.3.0", changelog())
55
- return None
56
-
57
-
58
- @pytest.mark.parametrize(
59
- "text",
60
- [
61
- changelog(body="### Added\n"),
62
- changelog() + changelog(),
63
- changelog().replace("[4.3.0]", "[4.4.0]"),
64
- changelog(stamp="UNRELEASED"),
65
- changelog(stamp="2026-02-30"),
66
- ],
67
- )
68
- def test_invalid_changelog(text: str) -> None:
69
- with pytest.raises(ValueError):
70
- release.release_info("v4.3.0", "4.3.0", text)
71
- return None
72
-
73
-
74
- @pytest.mark.parametrize(
75
- "tag,version",
76
- [("v4.3.0", "4.3.0"), ("v4.3.0.rc1", "4.3.0rc1"), ("v4.3.0.post1", "4.3.0.post1")],
77
- )
78
- def test_non_development_requires_date(tag: str, version: str) -> None:
79
- with pytest.raises(ValueError, match="requires a changelog date"):
80
- release.release_info(tag, version, changelog("UNRELEASED"))
81
- return None
82
-
83
-
84
- def test_development_unreleased_and_version_mismatch() -> None:
85
- assert (
86
- release.release_info("v4.3.0.dev1", "4.3.0.dev1", changelog("UNRELEASED"))[0]
87
- == "4.3.0.dev1"
88
- )
89
- with pytest.raises(ValueError):
90
- release.release_info("v4.3.0", "4.3.0.dev1", changelog())
91
- return None
92
-
93
-
94
- def test_postrelease_preserves_original_date() -> None:
95
- text = changelog("2025-01-02")
96
- _, notes = release.release_info("v4.3.0.post1", "4.3.0.post1", text)
97
- assert notes.startswith("## [4.3.0](compare) - 2025-01-02\n")
98
- return None
99
-
100
-
101
- @pytest.mark.parametrize(
102
- "existing,expected",
103
- [
104
- ({}, {"wheel", "sdist"}),
105
- ({"wheel": "aaa"}, {"sdist"}),
106
- ({"wheel": "aaa", "sdist": "bbb"}, set()),
107
- ],
108
- )
109
- def test_missing_files(existing: dict[str, str], expected: set[str]) -> None:
110
- assert release.missing_files({"wheel": "aaa", "sdist": "bbb"}, existing) == expected
111
- return None
112
-
113
-
114
- @pytest.mark.parametrize("existing", [{"wheel": "wrong"}, {"unexpected": "aaa"}])
115
- def test_conflicting_pypi_files(existing: dict[str, str]) -> None:
116
- with pytest.raises(ValueError, match="conflict"):
117
- release.missing_files({"wheel": "aaa", "sdist": "bbb"}, existing)
118
- return None
119
-
120
-
121
- def test_bundle_identity_and_checksums(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
122
- directory = tmp_path / "dist"
123
- directory.mkdir()
124
- # Treat distributions as opaque bytes: this checks our retained-file policy.
125
- files = {"package.whl": b"wheel bytes", "package.tar.gz": b"sdist bytes"}
126
- for name, content in files.items():
127
- (directory / name).write_bytes(content)
128
- (tmp_path / "SHA256SUMS.json").write_text(
129
- json.dumps({name: hashlib.sha256(content).hexdigest() for name, content in files.items()})
130
- )
131
- (tmp_path / "release.json").write_text(json.dumps({"tag": "v4.3.0", "commit": "abc"}))
132
- monkeypatch.setenv("GITHUB_REF_NAME", "v4.3.0")
133
- monkeypatch.setenv("GITHUB_SHA", "wrong")
134
- with pytest.raises(ValueError, match="commit mismatch"):
135
- release.verify_bundle(tmp_path)
136
- monkeypatch.setenv("GITHUB_SHA", "abc")
137
- assert set(release.verify_bundle(tmp_path)) == {"package.whl", "package.tar.gz"}
138
- (directory / "package.whl").write_bytes(b"corrupted")
139
- with pytest.raises(ValueError, match="checksum mismatch"):
140
- release.verify_bundle(tmp_path)
141
- return None
142
-
143
-
144
- def test_workflow_permissions_and_order() -> None:
145
- yaml = pytest.importorskip("yaml")
146
- text = (ROOT / ".github/workflows/release.yml").read_text()
147
- workflow = yaml.load(text, Loader=yaml.BaseLoader)
148
- assert "python - <<" not in text
149
- assert workflow["on"] == {"push": {"tags": ["v[0-9]*.[0-9]*.[0-9]*"]}}
150
- assert workflow["permissions"] == {"contents": "read"}
151
- jobs = workflow["jobs"]
152
- for job, dependency in (
153
- ("ci", "validate"),
154
- ("draft", "build"),
155
- ("select", "draft"),
156
- ("publish", "select"),
157
- ):
158
- assert jobs[job]["needs"] == dependency
159
- for name, job in jobs.items():
160
- permissions = job.get("permissions", {})
161
- assert (permissions.get("contents") == "write") == (name in ("draft", "publish"))
162
- assert (permissions.get("id-token") == "write") == (name == "publish")
163
- for step in job.get("steps", []):
164
- if "uses" in step:
165
- assert len(step["uses"].split("@")[1]) == 40
166
- assert jobs["publish"]["environment"]["name"] == "pypi"
167
- assert not any("scripts/" in step.get("run", "") for step in jobs["publish"]["steps"])
168
- steps = jobs["publish"]["steps"]
169
- assert "gh release edit" in steps[-2]["run"]
170
- assert "pypa/gh-action-pypi-publish@" in steps[-1]["uses"]
171
- assert not any("checkout" in step.get("uses", "") for step in jobs["publish"]["steps"])
172
- return None
173
-
174
-
175
- @pytest.mark.parametrize("date", ["2025-01-02", "2026-01-02"])
176
- def test_postrelease_date_policy(date: str) -> None:
177
- original = "## [4.2.0](compare) - 2025-01-02\n\n- Original changes.\n"
178
- post = f"## [4.2.0](compare) - {date}\n\n- Extra post-release changes.\n"
179
- if date == "2025-01-02":
180
- release.validate_post_date(post, original)
181
- else:
182
- with pytest.raises(ValueError, match="retain the base release date"):
183
- release.validate_post_date(post, original)
184
- return None