pyfracturedjson 2.1.1__tar.gz → 2.2.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.
Files changed (38) hide show
  1. pyfracturedjson-2.2.1/.github/workflows/publish.yaml +36 -0
  2. pyfracturedjson-2.2.1/CHANGELOG.md +42 -0
  3. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/Cargo.lock +11 -12
  4. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/Cargo.toml +7 -5
  5. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/PKG-INFO +12 -3
  6. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/README.md +10 -2
  7. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/fracturedjson/__init__.py +10 -3
  8. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/fracturedjson/_rust_wrapper.pyi +2 -1
  9. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/pyproject.toml +1 -0
  10. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/src/lib.rs +4 -2
  11. pyfracturedjson-2.2.1/tests/JSONs/max_prop_name_padding_0.json +53 -0
  12. pyfracturedjson-2.2.1/tests/JSONs/max_prop_name_padding_24.json +53 -0
  13. pyfracturedjson-2.2.1/tests/JSONs/number_list_alignment_decimal.json +53 -0
  14. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/common.py +6 -1
  15. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/test_basic_output.py +1 -1
  16. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/test_builtin_wrapper.py +3 -4
  17. pyfracturedjson-2.1.1/.github/workflows/publish.yml +0 -265
  18. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/.gitignore +0 -0
  19. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/LICENSE +0 -0
  20. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/compact_array_complexity_-1.json +0 -0
  21. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/compact_array_complexity_0.json +0 -0
  22. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/compact_array_complexity_1.json +0 -0
  23. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/default_settings.json +0 -0
  24. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/indent_2.json +0 -0
  25. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/indent_3.json +0 -0
  26. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/inline_complexity_-1.json +0 -0
  27. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/inline_complexity_0.json +0 -0
  28. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/inline_complexity_1.json +0 -0
  29. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/line_len_100.json +0 -0
  30. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/line_len_40.json +0 -0
  31. /pyfracturedjson-2.1.1/tests/JSONs/number_list_alignment_decimal.json → /pyfracturedjson-2.2.1/tests/JSONs/max_prop_name_padding_10.json +0 -0
  32. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/number_list_alignment_left.json +0 -0
  33. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/number_list_alignment_normalize.json +0 -0
  34. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/number_list_alignment_right.json +0 -0
  35. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/table_row_complexity_-1.json +0 -0
  36. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/table_row_complexity_0.json +0 -0
  37. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/tests/JSONs/table_row_complexity_1.json +0 -0
  38. {pyfracturedjson-2.1.1 → pyfracturedjson-2.2.1}/uv.lock +0 -0
@@ -0,0 +1,36 @@
1
+ name: publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v[0-9]+.[0-9]+.[0-9]+'
7
+ branches:
8
+ - dev
9
+ - develop
10
+
11
+ jobs:
12
+ publish:
13
+ permissions:
14
+ id-token: write
15
+ contents: write
16
+ attestations: write
17
+ uses: g-b-f/workflows/.github/workflows/maturin_publish.yaml@v2
18
+ with:
19
+ package-name: pyFracturedJSON
20
+ smoke-test-script: |
21
+ from fracturedjson import dumps
22
+
23
+ expected="""{
24
+ "abcd" : "abcd",
25
+ "long_list": [
26
+ "thing_0", "thing_1", "thing_2", "thing_3", "thing_4", "thing_5", "thing_6", "thing_7", "thing_8",
27
+ "thing_9", "thing_10", "thing_11", "thing_12", "thing_13", "thing_14", "thing_15", "thing_16", "thing_17",
28
+ "thing_18", "thing_19"
29
+ ]
30
+ }
31
+ """
32
+ long_list = [f"thing_{i}" for i in range(20)]
33
+ actual = dumps({"abcd": "abcd", "long_list": long_list})
34
+ assert actual == expected, f"unexpected format:\n\nexpected:\n{expected}\nactual:\n{actual}"
35
+ secrets:
36
+ PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+
7
+ ## [2.2.0] - 2026-06-18
8
+
9
+ ### Added
10
+
11
+ - `max_prop_name_padding` option
12
+
13
+ ## [2.1.1] - 2026-06-03
14
+
15
+ ### Added
16
+
17
+ - Support for android
18
+ - `aarch64-linux-android`
19
+ - `x86_64-linux-android`
20
+
21
+ ## [2.1.0] - 2026-06-03
22
+
23
+ ### Added
24
+
25
+ - More options
26
+ - `max_inline_complexity`
27
+ - `max_compact_array_complexity`
28
+ - `max_table_row_complexity`
29
+ - `number_list_alignment`
30
+ - Licence file
31
+
32
+ ## [2.0.0] - 2026-02-26
33
+
34
+ ### Fixed
35
+
36
+ - Package not being correctly uploaded to PyPi
37
+
38
+ ## [1.0.0] - 2026-02-04
39
+
40
+ ### Added
41
+
42
+ - Wrapper functions to mirror the builtin `json` library
@@ -168,7 +168,7 @@ dependencies = [
168
168
 
169
169
  [[package]]
170
170
  name = "pyfracturedjson"
171
- version = "2.1.1"
171
+ version = "2.2.1"
172
172
  dependencies = [
173
173
  "fracturedjson",
174
174
  "pyo3",
@@ -176,9 +176,9 @@ dependencies = [
176
176
 
177
177
  [[package]]
178
178
  name = "pyo3"
179
- version = "0.28.0"
179
+ version = "0.29.3"
180
180
  source = "registry+https://github.com/rust-lang/crates.io-index"
181
- checksum = "fcf3ccafdf54c050be48a3a086d372f77ba6615f5057211607cd30e5ac5cec6d"
181
+ checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
182
182
  dependencies = [
183
183
  "libc",
184
184
  "once_cell",
@@ -190,18 +190,18 @@ dependencies = [
190
190
 
191
191
  [[package]]
192
192
  name = "pyo3-build-config"
193
- version = "0.28.0"
193
+ version = "0.29.3"
194
194
  source = "registry+https://github.com/rust-lang/crates.io-index"
195
- checksum = "972720a441c91fd9c49f212a1d2d74c6e3803b231ebc8d66c51efbd7ccab11c8"
195
+ checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
196
196
  dependencies = [
197
197
  "target-lexicon",
198
198
  ]
199
199
 
200
200
  [[package]]
201
201
  name = "pyo3-ffi"
202
- version = "0.28.0"
202
+ version = "0.29.3"
203
203
  source = "registry+https://github.com/rust-lang/crates.io-index"
204
- checksum = "5994456d9dab8934d600d3867571b6410f24fbd6002570ad56356733eb54859b"
204
+ checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
205
205
  dependencies = [
206
206
  "libc",
207
207
  "pyo3-build-config",
@@ -209,9 +209,9 @@ dependencies = [
209
209
 
210
210
  [[package]]
211
211
  name = "pyo3-macros"
212
- version = "0.28.0"
212
+ version = "0.29.3"
213
213
  source = "registry+https://github.com/rust-lang/crates.io-index"
214
- checksum = "11ce9cc8d81b3c4969748807604d92b4eef363c5bb82b1a1bdb34ec6f1093a18"
214
+ checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
215
215
  dependencies = [
216
216
  "proc-macro2",
217
217
  "pyo3-macros-backend",
@@ -221,13 +221,12 @@ dependencies = [
221
221
 
222
222
  [[package]]
223
223
  name = "pyo3-macros-backend"
224
- version = "0.28.0"
224
+ version = "0.29.3"
225
225
  source = "registry+https://github.com/rust-lang/crates.io-index"
226
- checksum = "eaf4b60036a154d23282679b658e3cc7d88d3b8c9a40b43824785f232d2e1b98"
226
+ checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
227
227
  dependencies = [
228
228
  "heck",
229
229
  "proc-macro2",
230
- "pyo3-build-config",
231
230
  "quote",
232
231
  "syn",
233
232
  ]
@@ -1,12 +1,14 @@
1
1
  [package]
2
2
  name = "pyfracturedjson"
3
- version = "2.1.1"
3
+ version = "2.2.1"
4
4
  edition = "2024"
5
5
  license = "MIT"
6
6
  readme = "README.md"
7
7
 
8
- [package.metadata.maturin]
9
- compatibility = "abi3"
8
+ [features]
9
+ default = ["abi3-py39"]
10
+ abi3-py39 = ["pyo3/abi3-py39"]
11
+ abi3-py314 = ["pyo3/abi3-py314"]
10
12
 
11
13
  [lib]
12
14
  name = "_rust_wrapper"
@@ -16,5 +18,5 @@ crate-type = ["cdylib"]
16
18
  fracturedjson = "0.1.1"
17
19
 
18
20
  [dependencies.pyo3]
19
- version = "0.28.0"
20
- features = ["extension-module", "abi3-py39"]
21
+ version = "0.29"
22
+ features = ["extension-module"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyfracturedjson
3
- Version: 2.1.1
3
+ Version: 2.2.1
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -10,13 +10,22 @@ Keywords: json,formatter,fracturedjson,compact,readable
10
10
  License-Expression: MIT
11
11
  Requires-Python: >=3.9
12
12
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
13
+ Project-URL: Changelog, https://github.com/g-b-f/pyFracturedJSON/blob/master/CHANGELOG.md
13
14
  Project-URL: Repository, https://github.com/g-b-f/pyFracturedJSON
14
15
 
16
+ <div align="center">
17
+
15
18
  # pyFracturedJSON
16
19
 
17
- Adds [FracturedJSON](https://github.com/j-brooke/FracturedJson) support to python,
18
- allowing you to create JSON that is both compact and readable.
20
+ **Adds [FracturedJSON](https://github.com/j-brooke/FracturedJson) support to python,
21
+ letting you create JSON that is both compact and readable.**
19
22
 
23
+ <a href="https://pypi.org/project/pyfracturedjson">
24
+ <img alt="PyPI Version" src="https://img.shields.io/pypi/v/pyfracturedjson?cacheSeconds=3600">
25
+ <img alt="minimum python version" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpypi.org%2Fpypi%2Fpyfracturedjson%2Fjson&query=%24.info.requires_python&label=requires%20python&cacheSeconds=3600">
26
+ </a>
27
+ </div>
28
+ </br>
20
29
 
21
30
  You can trivially use it as a drop-in replacement for the built-in `json` module:
22
31
 
@@ -1,8 +1,16 @@
1
+ <div align="center">
2
+
1
3
  # pyFracturedJSON
2
4
 
3
- Adds [FracturedJSON](https://github.com/j-brooke/FracturedJson) support to python,
4
- allowing you to create JSON that is both compact and readable.
5
+ **Adds [FracturedJSON](https://github.com/j-brooke/FracturedJson) support to python,
6
+ letting you create JSON that is both compact and readable.**
5
7
 
8
+ <a href="https://pypi.org/project/pyfracturedjson">
9
+ <img alt="PyPI Version" src="https://img.shields.io/pypi/v/pyfracturedjson?cacheSeconds=3600">
10
+ <img alt="minimum python version" src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpypi.org%2Fpypi%2Fpyfracturedjson%2Fjson&query=%24.info.requires_python&label=requires%20python&cacheSeconds=3600">
11
+ </a>
12
+ </div>
13
+ </br>
6
14
 
7
15
  You can trivially use it as a drop-in replacement for the built-in `json` module:
8
16
 
@@ -1,8 +1,12 @@
1
1
  import json
2
2
  from collections.abc import Iterator
3
3
  from typing import Callable
4
+ from typing import TYPE_CHECKING
4
5
 
5
- import _rust_wrapper
6
+ if TYPE_CHECKING:
7
+ from fracturedjson import _rust_wrapper # type: ignore[reportMissingModuleSource]
8
+ else:
9
+ import _rust_wrapper
6
10
 
7
11
 
8
12
  class Encoder(json.encoder.JSONEncoder):
@@ -21,6 +25,7 @@ class Encoder(json.encoder.JSONEncoder):
21
25
  max_compact_array_complexity = 2,
22
26
  max_table_row_complexity = 2,
23
27
  number_list_alignment= "decimal",
28
+ max_prop_name_padding = 16,
24
29
  **kwargs
25
30
  ):
26
31
  super().__init__(
@@ -42,6 +47,7 @@ class Encoder(json.encoder.JSONEncoder):
42
47
  self.max_compact_array_complexity = max_compact_array_complexity
43
48
  self.max_table_row_complexity = max_table_row_complexity
44
49
  self.number_list_alignment = number_list_alignment
50
+ self.max_prop_name_padding = max_prop_name_padding
45
51
 
46
52
 
47
53
 
@@ -54,7 +60,8 @@ class Encoder(json.encoder.JSONEncoder):
54
60
  max_inline_complexity = self.max_inline_complexity,
55
61
  max_compact_array_complexity = self.max_compact_array_complexity,
56
62
  max_table_row_complexity = self.max_table_row_complexity,
57
- number_list_alignment = self.number_list_alignment
63
+ number_list_alignment = self.number_list_alignment,
64
+ max_prop_name_padding = self.max_prop_name_padding
58
65
  )
59
66
  return formatted
60
67
 
@@ -228,5 +235,5 @@ def loads(fp, *, cls=None, object_hook=None, parse_float=None,
228
235
  return json.loads(fp, cls=cls, object_hook=object_hook, parse_float=parse_float,
229
236
  parse_int=parse_int, parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
230
237
 
231
- def detect_encoding(b):
238
+ def detect_encoding(b: bytes | bytearray):
232
239
  return json.detect_encoding(b)
@@ -8,7 +8,8 @@ def reformat_string(
8
8
  max_inline_complexity:int,
9
9
  max_compact_array_complexity:int,
10
10
  max_table_row_complexity:int,
11
- number_list_alignment:str
11
+ number_list_alignment:str,
12
+ max_prop_name_padding:int
12
13
  ) -> str:
13
14
  """Reformat a JSON string.
14
15
 
@@ -17,6 +17,7 @@ dynamic = ["version"]
17
17
 
18
18
  [project.urls]
19
19
  Repository = "https://github.com/g-b-f/pyFracturedJSON"
20
+ Changelog = "https://github.com/g-b-f/pyFracturedJSON/blob/master/CHANGELOG.md"
20
21
 
21
22
  [build-system]
22
23
  requires = ["maturin>=1.11,<2.0"]
@@ -4,12 +4,13 @@ use fracturedjson::{Formatter, NumberListAlignment};
4
4
  #[pyfunction]
5
5
  fn reformat_string(
6
6
  input: String,
7
- indent:usize,
7
+ indent: usize,
8
8
  line_length: usize,
9
9
  max_inline_complexity: isize,
10
10
  max_compact_array_complexity: isize,
11
11
  max_table_row_complexity: isize,
12
- number_list_alignment: &str
12
+ number_list_alignment: &str,
13
+ max_prop_name_padding: usize
13
14
  ) -> String {
14
15
  let mut formatter = Formatter::new();
15
16
  formatter.options.max_total_line_length = line_length;
@@ -17,6 +18,7 @@ fn reformat_string(
17
18
  formatter.options.max_inline_complexity = max_inline_complexity;
18
19
  formatter.options.max_compact_array_complexity = max_compact_array_complexity;
19
20
  formatter.options.max_table_row_complexity = max_table_row_complexity;
21
+ formatter.options.max_prop_name_padding = max_prop_name_padding;
20
22
 
21
23
  match number_list_alignment {
22
24
  "left" => formatter.options.number_list_alignment = NumberListAlignment::Left,
@@ -0,0 +1,53 @@
1
+ {
2
+ "BasicObject": {
3
+ "ModuleId": "armor",
4
+ "Name": "",
5
+ "Locations": [
6
+ [11, 2], [11, 3], [11, 4], [11, 5], [11, 6], [11, 7], [11, 8], [11, 9], [11, 10], [11, 11],
7
+ [11, 12], [11, 13], [11, 14], [ 1, 14], [ 1, 13], [ 1, 12], [ 1, 11], [ 1, 10], [ 1, 9], [ 1, 8],
8
+ [ 1, 7], [ 1, 6], [ 1, 5], [ 1, 4], [ 1, 3], [ 1, 2], [ 4, 2], [ 5, 2], [ 6, 2], [ 7, 2],
9
+ [ 8, 2], [ 8, 3], [ 7, 3], [ 6, 3], [ 5, 3], [ 4, 3], [ 0, 4], [ 0, 5], [ 0, 6], [ 0, 7],
10
+ [ 0, 8], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4]
11
+ ],
12
+ "Orientation": "Fore",
13
+ "Seed": 272691529
14
+ },
15
+ "SimilarArrays": {
16
+ "Katherine": ["blue", "lightblue", "black" ],
17
+ "Logan" : ["yellow", "blue", "black", "red"],
18
+ "Erik" : ["red", "purple" ],
19
+ "Jean" : ["lightgreen", "yellow", "black" ]
20
+ },
21
+ "SimilarObjects": [
22
+ { "type": "turret", "hp": 400, "loc": {"x": 47, "y": -4}, "flags": "S" },
23
+ { "type": "assassin", "hp": 80, "loc": {"x": 12, "y": 6}, "flags": "Q" },
24
+ { "type": "berserker", "hp": 150, "loc": {"x": 0, "y": 0} },
25
+ { "type": "pittrap", "loc": {"x": 10, "y": -14}, "flags": "S,I" }
26
+ ],
27
+ "NumberAlignmentTests": [
28
+ {"a": 123.456 , "b": 0 , "c": 0 },
29
+ {"a": 234567.8 , "b": 0 , "c": 0 },
30
+ {"a": 3 , "b": 0.0 , "c": 700.0},
31
+ {"a": null , "b": 0.2 , "c": 800.0},
32
+ {"a": 5.6789, "b": 0.35, "c": 0 }
33
+ ],
34
+ "InlineComplexityTests": {
35
+ "Subthing1": {"X": 55, "Y": 19, "Z": -4},
36
+ "Subthing2": { "Q": null, "W": [-2, -1, 0, 1] },
37
+ "Distraction": [[], null, null]
38
+ },
39
+ "CompactArrayComplexityTest_1": [
40
+ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
41
+ 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
42
+ 197, 199
43
+ ],
44
+ "CompactArrayComplexityTest_2": [
45
+ [19, 2], [ 3, 8], [14, 0], [ 9, 9], [ 9, 9], [ 0, 3], [10, 1], [ 9, 1], [ 9, 2], [ 6, 13], [18, 5],
46
+ [ 4, 11], [12, 2]
47
+ ],
48
+ "TableRowComplexityTests": {
49
+ "Rect" : { "position": {"x": -44, "y": 3.4 }, "color": [0, 255, 255] },
50
+ "Point": { "position": { "y": 22.0, "z": 3} },
51
+ "Oval" : { "position": null, "color": "#7f3e96" }
52
+ }
53
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "BasicObject" : {
3
+ "ModuleId" : "armor",
4
+ "Name" : "",
5
+ "Locations" : [
6
+ [11, 2], [11, 3], [11, 4], [11, 5], [11, 6], [11, 7], [11, 8], [11, 9], [11, 10], [11, 11],
7
+ [11, 12], [11, 13], [11, 14], [ 1, 14], [ 1, 13], [ 1, 12], [ 1, 11], [ 1, 10], [ 1, 9], [ 1, 8],
8
+ [ 1, 7], [ 1, 6], [ 1, 5], [ 1, 4], [ 1, 3], [ 1, 2], [ 4, 2], [ 5, 2], [ 6, 2], [ 7, 2],
9
+ [ 8, 2], [ 8, 3], [ 7, 3], [ 6, 3], [ 5, 3], [ 4, 3], [ 0, 4], [ 0, 5], [ 0, 6], [ 0, 7],
10
+ [ 0, 8], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4]
11
+ ],
12
+ "Orientation": "Fore",
13
+ "Seed" : 272691529
14
+ },
15
+ "SimilarArrays" : {
16
+ "Katherine": ["blue", "lightblue", "black" ],
17
+ "Logan" : ["yellow", "blue", "black", "red"],
18
+ "Erik" : ["red", "purple" ],
19
+ "Jean" : ["lightgreen", "yellow", "black" ]
20
+ },
21
+ "SimilarObjects" : [
22
+ { "type": "turret", "hp": 400, "loc": {"x": 47, "y": -4}, "flags": "S" },
23
+ { "type": "assassin", "hp": 80, "loc": {"x": 12, "y": 6}, "flags": "Q" },
24
+ { "type": "berserker", "hp": 150, "loc": {"x": 0, "y": 0} },
25
+ { "type": "pittrap", "loc": {"x": 10, "y": -14}, "flags": "S,I" }
26
+ ],
27
+ "NumberAlignmentTests" : [
28
+ {"a": 123.456 , "b": 0 , "c": 0 },
29
+ {"a": 234567.8 , "b": 0 , "c": 0 },
30
+ {"a": 3 , "b": 0.0 , "c": 700.0},
31
+ {"a": null , "b": 0.2 , "c": 800.0},
32
+ {"a": 5.6789, "b": 0.35, "c": 0 }
33
+ ],
34
+ "InlineComplexityTests" : {
35
+ "Subthing1" : {"X": 55, "Y": 19, "Z": -4},
36
+ "Subthing2" : { "Q": null, "W": [-2, -1, 0, 1] },
37
+ "Distraction": [[], null, null]
38
+ },
39
+ "CompactArrayComplexityTest_1": [
40
+ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
41
+ 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
42
+ 197, 199
43
+ ],
44
+ "CompactArrayComplexityTest_2": [
45
+ [19, 2], [ 3, 8], [14, 0], [ 9, 9], [ 9, 9], [ 0, 3], [10, 1], [ 9, 1], [ 9, 2], [ 6, 13], [18, 5],
46
+ [ 4, 11], [12, 2]
47
+ ],
48
+ "TableRowComplexityTests" : {
49
+ "Rect" : { "position": {"x": -44, "y": 3.4 }, "color": [0, 255, 255] },
50
+ "Point": { "position": { "y": 22.0, "z": 3} },
51
+ "Oval" : { "position": null, "color": "#7f3e96" }
52
+ }
53
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "BasicObject": {
3
+ "ModuleId" : "armor",
4
+ "Name" : "",
5
+ "Locations" : [
6
+ [11, 2], [11, 3], [11, 4], [11, 5], [11, 6], [11, 7], [11, 8], [11, 9], [11, 10], [11, 11],
7
+ [11, 12], [11, 13], [11, 14], [ 1, 14], [ 1, 13], [ 1, 12], [ 1, 11], [ 1, 10], [ 1, 9], [ 1, 8],
8
+ [ 1, 7], [ 1, 6], [ 1, 5], [ 1, 4], [ 1, 3], [ 1, 2], [ 4, 2], [ 5, 2], [ 6, 2], [ 7, 2],
9
+ [ 8, 2], [ 8, 3], [ 7, 3], [ 6, 3], [ 5, 3], [ 4, 3], [ 0, 4], [ 0, 5], [ 0, 6], [ 0, 7],
10
+ [ 0, 8], [12, 8], [12, 7], [12, 6], [12, 5], [12, 4]
11
+ ],
12
+ "Orientation": "Fore",
13
+ "Seed" : 272691529
14
+ },
15
+ "SimilarArrays": {
16
+ "Katherine": ["blue", "lightblue", "black" ],
17
+ "Logan" : ["yellow", "blue", "black", "red"],
18
+ "Erik" : ["red", "purple" ],
19
+ "Jean" : ["lightgreen", "yellow", "black" ]
20
+ },
21
+ "SimilarObjects": [
22
+ { "type": "turret", "hp": 400, "loc": {"x": 47, "y": -4}, "flags": "S" },
23
+ { "type": "assassin", "hp": 80, "loc": {"x": 12, "y": 6}, "flags": "Q" },
24
+ { "type": "berserker", "hp": 150, "loc": {"x": 0, "y": 0} },
25
+ { "type": "pittrap", "loc": {"x": 10, "y": -14}, "flags": "S,I" }
26
+ ],
27
+ "NumberAlignmentTests": [
28
+ {"a": 123.456 , "b": 0 , "c": 0 },
29
+ {"a": 234567.8 , "b": 0 , "c": 0 },
30
+ {"a": 3 , "b": 0.0 , "c": 700.0},
31
+ {"a": null , "b": 0.2 , "c": 800.0},
32
+ {"a": 5.6789, "b": 0.35, "c": 0 }
33
+ ],
34
+ "InlineComplexityTests": {
35
+ "Subthing1" : {"X": 55, "Y": 19, "Z": -4},
36
+ "Subthing2" : { "Q": null, "W": [-2, -1, 0, 1] },
37
+ "Distraction": [[], null, null]
38
+ },
39
+ "CompactArrayComplexityTest_1": [
40
+ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
41
+ 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
42
+ 197, 199
43
+ ],
44
+ "CompactArrayComplexityTest_2": [
45
+ [19, 2], [ 3, 8], [14, 0], [ 9, 9], [ 9, 9], [ 0, 3], [10, 1], [ 9, 1], [ 9, 2], [ 6, 13], [18, 5],
46
+ [ 4, 11], [12, 2]
47
+ ],
48
+ "TableRowComplexityTests": {
49
+ "Rect" : { "position": {"x": -44, "y": 3.4 }, "color": [0, 255, 255] },
50
+ "Point": { "position": { "y": 22.0, "z": 3} },
51
+ "Oval" : { "position": null, "color": "#7f3e96" }
52
+ }
53
+ }
@@ -1,12 +1,13 @@
1
1
  import json
2
- from pathlib import Path
3
2
  import sys
3
+ from pathlib import Path
4
4
 
5
5
  root = Path(__file__).parent.parent
6
6
  sys.path.append(str(root))
7
7
 
8
8
  from fracturedjson import Encoder
9
9
 
10
+
10
11
  def read_file(filename:str) -> tuple[str, dict]:
11
12
  file = Path(__file__).parent / filename
12
13
  file_contents = file.read_text()
@@ -41,6 +42,10 @@ _params: list[paramType] = [
41
42
  ("number_list_alignment_decimal.json", {"number_list_alignment":"decimal"}),
42
43
  ("number_list_alignment_right.json", {"number_list_alignment":"right"}),
43
44
  ("number_list_alignment_normalize.json", {"number_list_alignment":"normalize"}),
45
+
46
+ ("max_prop_name_padding_0.json", {"max_prop_name_padding":0}),
47
+ ("max_prop_name_padding_10.json", {"max_prop_name_padding":10}),
48
+ ("max_prop_name_padding_24.json", {"max_prop_name_padding":24}),
44
49
  ]
45
50
 
46
51
  JSONS_DIR = "JSONs/"
@@ -4,9 +4,9 @@ from pathlib import Path
4
4
  import pytest
5
5
 
6
6
  from fracturedjson import Encoder
7
-
8
7
  from tests.common import params, read_file
9
8
 
9
+
10
10
  @pytest.mark.parametrize(("filename", "kwargs"), params)
11
11
  def test_roundtrip(filename:str, kwargs:dict):
12
12
  file_str, file_dict = read_file(filename)
@@ -1,12 +1,11 @@
1
- import json as builtin_json
2
1
  from pathlib import Path
3
2
 
4
3
  import pytest
5
4
 
6
5
  import fracturedjson as json
7
-
8
6
  from tests.common import params, read_file
9
7
 
8
+
10
9
  @pytest.mark.parametrize(("filename", "kwargs"), params)
11
10
  def test_dumps(filename:str, kwargs:dict):
12
11
  file_str, file_dict = read_file(filename)
@@ -22,14 +21,14 @@ def test_dump(filename:str, kwargs:dict, tmp_path:Path):
22
21
  assert file.read_text() == file_str
23
22
 
24
23
  @pytest.mark.parametrize(("filename", "kwargs"), params)
25
- def test_load(filename:str, kwargs:dict, tmp_path:Path):
24
+ def test_load(filename:str, kwargs:dict):
26
25
  file_str, file_dict = read_file(filename)
27
26
  with open(Path(__file__).parent / filename) as f:
28
27
  data = json.load(f)
29
28
  assert file_dict == data
30
29
 
31
30
  @pytest.mark.parametrize(("filename", "kwargs"), params)
32
- def test_loads(filename:str, kwargs:dict, tmp_path:Path):
31
+ def test_loads(filename:str, kwargs:dict):
33
32
  file_str, file_dict = read_file(filename)
34
33
  data = json.loads(file_str)
35
34
  assert file_dict == data
@@ -1,265 +0,0 @@
1
- name: publish
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v[0-9]+.[0-9]+.[0-9]+'
7
- branches:
8
- - dev
9
- - develop
10
-
11
- permissions:
12
- contents: read
13
-
14
- jobs:
15
- test:
16
- name: Test
17
- runs-on: ubuntu-latest
18
- steps:
19
- - uses: actions/checkout@v6
20
- - uses: actions/setup-python@v6
21
- with:
22
- python-version: '3.11'
23
- - name: Install uv
24
- uses: astral-sh/setup-uv@v7
25
- - name: Run tests
26
- run: uv run python -m pytest tests/
27
-
28
- linux:
29
- runs-on: ${{ matrix.platform.runner }}
30
- needs: test
31
- strategy:
32
- matrix:
33
- platform:
34
- - runner: ubuntu-22.04
35
- target: x86_64
36
- - runner: ubuntu-22.04
37
- target: x86
38
- - runner: ubuntu-22.04
39
- target: aarch64
40
- - runner: ubuntu-22.04
41
- target: armv7
42
- - runner: ubuntu-22.04
43
- target: s390x
44
- - runner: ubuntu-22.04
45
- target: ppc64le
46
- steps:
47
- - uses: actions/checkout@v6
48
- - uses: actions/setup-python@v6
49
- with:
50
- python-version: 3.x
51
- - name: Build wheels
52
- uses: PyO3/maturin-action@v1
53
- with:
54
- target: ${{ matrix.platform.target }}
55
- args: --release --out dist --find-interpreter
56
- sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
57
- manylinux: auto
58
- - name: Upload wheels
59
- uses: actions/upload-artifact@v5
60
- with:
61
- name: wheels-linux-${{ matrix.platform.target }}
62
- path: dist
63
-
64
- test_install:
65
- name: Test Install
66
- runs-on: ubuntu-latest
67
- needs: linux
68
- steps:
69
- - uses: actions/setup-python@v6
70
- with:
71
- python-version: '3.11'
72
-
73
- - name: Download wheel
74
- uses: actions/download-artifact@v4
75
- with:
76
- pattern: wheels-linux-*
77
- path: dist/
78
- merge-multiple: true
79
-
80
- - name: Install local wheel
81
- run: pip install --no-index --find-links=dist/ pyfracturedjson
82
-
83
- - name: Import and smoke test
84
- run: |
85
- python -c '
86
- from fracturedjson import dumps
87
-
88
- expected="""{
89
- "abcd" : "abcd",
90
- "long_list": [
91
- "thing_0", "thing_1", "thing_2", "thing_3", "thing_4", "thing_5", "thing_6", "thing_7", "thing_8",
92
- "thing_9", "thing_10", "thing_11", "thing_12", "thing_13", "thing_14", "thing_15", "thing_16", "thing_17",
93
- "thing_18", "thing_19"
94
- ]
95
- }
96
- """
97
- long_list = [f"thing_{i}" for i in range(20)]
98
- actual = dumps({"abcd": "abcd", "long_list": long_list})
99
- assert actual == expected, f"unexpected format:\n\nexpected:\n{expected}\nactual:\n{actual}"
100
- '
101
-
102
- musllinux:
103
- runs-on: ${{ matrix.platform.runner }}
104
- needs: test_install
105
- strategy:
106
- matrix:
107
- platform:
108
- - runner: ubuntu-22.04
109
- target: x86_64
110
- - runner: ubuntu-22.04
111
- target: x86
112
- - runner: ubuntu-22.04
113
- target: aarch64
114
- - runner: ubuntu-22.04
115
- target: armv7
116
- steps:
117
- - uses: actions/checkout@v6
118
- - uses: actions/setup-python@v6
119
- with:
120
- python-version: 3.x
121
- - name: Build wheels
122
- uses: PyO3/maturin-action@v1
123
- with:
124
- target: ${{ matrix.platform.target }}
125
- args: --release --out dist --find-interpreter
126
- sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
127
- manylinux: musllinux_1_2
128
- - name: Upload wheels
129
- uses: actions/upload-artifact@v5
130
- with:
131
- name: wheels-musllinux-${{ matrix.platform.target }}
132
- path: dist
133
-
134
- windows:
135
- runs-on: ${{ matrix.platform.runner }}
136
- needs: test_install
137
- strategy:
138
- matrix:
139
- platform:
140
- - runner: windows-latest
141
- target: x64
142
- python_arch: x64
143
- - runner: windows-latest
144
- target: x86
145
- python_arch: x86
146
- - runner: windows-11-arm
147
- target: aarch64
148
- python_arch: arm64
149
- steps:
150
- - uses: actions/checkout@v6
151
- - uses: actions/setup-python@v6
152
- with:
153
- python-version: '3.13'
154
- architecture: ${{ matrix.platform.python_arch }}
155
- - name: Build wheels
156
- uses: PyO3/maturin-action@v1
157
- with:
158
- target: ${{ matrix.platform.target }}
159
- args: --release --out dist --find-interpreter
160
- sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
161
- - name: Upload wheels
162
- uses: actions/upload-artifact@v5
163
- with:
164
- name: wheels-windows-${{ matrix.platform.target }}
165
- path: dist
166
-
167
- macos:
168
- runs-on: ${{ matrix.platform.runner }}
169
- needs: test_install
170
- strategy:
171
- matrix:
172
- platform:
173
- - runner: macos-15-intel
174
- target: x86_64
175
- - runner: macos-latest
176
- target: aarch64
177
- steps:
178
- - uses: actions/checkout@v6
179
- - uses: actions/setup-python@v6
180
- with:
181
- python-version: 3.x
182
- - name: Build wheels
183
- uses: PyO3/maturin-action@v1
184
- with:
185
- target: ${{ matrix.platform.target }}
186
- args: --release --out dist --find-interpreter
187
- sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
188
- - name: Upload wheels
189
- uses: actions/upload-artifact@v5
190
- with:
191
- name: wheels-macos-${{ matrix.platform.target }}
192
- path: dist
193
-
194
- android:
195
- runs-on: ubuntu-latest
196
- needs: test_install
197
- strategy:
198
- matrix:
199
- platform:
200
- - aarch64-linux-android
201
- - x86_64-linux-android
202
- # - armv7-linux-androideabi
203
- steps:
204
- - uses: actions/checkout@v6
205
- - uses: actions/setup-python@v6
206
- with:
207
- python-version: 3.x
208
- - name: Build wheels
209
- uses: PyO3/maturin-action@v1
210
- with:
211
- target: ${{ matrix.platform }}
212
- args: --release --out dist -i python3.12
213
- sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
214
- - name: Upload wheels
215
- uses: actions/upload-artifact@v5
216
- with:
217
- name: wheels-android-${{ matrix.platform }}
218
- path: dist
219
-
220
- sdist:
221
- runs-on: ubuntu-latest
222
- needs: test_install
223
- steps:
224
- - uses: actions/checkout@v6
225
- - name: Build sdist
226
- uses: PyO3/maturin-action@v1
227
- with:
228
- command: sdist
229
- args: --out dist
230
- - name: Upload sdist
231
- uses: actions/upload-artifact@v5
232
- with:
233
- name: wheels-sdist
234
- path: dist
235
-
236
- release:
237
- name: Release
238
- runs-on: ubuntu-latest
239
- needs: [linux, musllinux, windows, macos, android, sdist, test_install]
240
- if: startsWith(github.ref, 'refs/tags/v')
241
- permissions:
242
- id-token: write
243
- contents: write
244
- attestations: write
245
-
246
- steps:
247
- - name: Download wheels
248
- uses: actions/download-artifact@v5
249
- with:
250
- pattern: wheels-*
251
- path: dist
252
- merge-multiple: true
253
-
254
- - name: Generate artifact attestation
255
- uses: actions/attest-build-provenance@v3
256
- with:
257
- subject-path: 'dist/*'
258
-
259
- - name: Install uv
260
- uses: astral-sh/setup-uv@v7
261
-
262
- - name: Publish to PyPI
263
- run: uv publish dist/*
264
- env:
265
- UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
File without changes
File without changes