Skip to content

Commit 3ed82e4

Browse files
authored
Merge pull request #7 from ZON-Format/copilot/update-file-extensions-to-zonf
Replace .zon format references with .zonf and update to v1.2.1
2 parents 3d0b09f + 2929e9c commit 3ed82e4

7 files changed

Lines changed: 35 additions & 35 deletions

File tree

zon-format/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "zon-format"
7-
version = "1.2.0"
8-
description = "Zero Overhead Notation v1.2.0 - Human-readable data format with 30%+ compression over JSON, now with adaptive encoding"
7+
version = "1.2.1"
8+
description = "Zero Overhead Notation v1.2.1 - Human-readable data format with 30%+ compression over JSON, now with adaptive encoding"
99
readme = "README.md"
1010
requires-python = ">=3.8"
1111
license = {text = "MIT"}

zon-format/src/zon/integrations/langchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def parse(self, text: str) -> Any:
5656
ValueError: If parsing fails
5757
"""
5858
try:
59-
cleaned = re.sub(r'```(zon|zonf)?', '', text).strip()
59+
cleaned = re.sub(r'```zonf?', '', text).strip()
6060
cleaned = cleaned.replace('```', '').strip()
6161
return decode(cleaned)
6262
except Exception as e:

zon-format/src/zon/integrations/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def chat(self, **kwargs) -> Any:
7171
response = self.client.chat.completions.create(**kwargs)
7272
content = response.choices[0].message.content or ''
7373

74-
cleaned = re.sub(r'```(zon|zonf)?', '', content).strip()
74+
cleaned = re.sub(r'```zonf?', '', content).strip()
7575
cleaned = cleaned.replace('```', '').strip()
7676

7777
return decode(cleaned)

zon-format/src/zon/tools/helpers.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
from ..binary import encode_binary
1111

1212

13-
def size(data: Any, format: Literal['zon', 'binary', 'json'] = 'zon') -> int:
13+
def size(data: Any, format: Literal['zonf', 'binary', 'json'] = 'zonf') -> int:
1414
"""Calculate the encoded size of data in different formats.
1515
1616
Args:
1717
data: Data to measure
18-
format: Format to use ('zon', 'binary', or 'json')
18+
format: Format to use ('zonf', 'binary', or 'json')
1919
2020
Returns:
2121
Size in bytes
2222
2323
Example:
2424
>>> data = {"name": "Alice", "age": 30}
25-
>>> size(data, 'zon')
25+
>>> size(data, 'zonf')
2626
45
2727
>>> size(data, 'json')
2828
28
2929
"""
30-
if format == 'zon':
30+
if format == 'zonf':
3131
return len(encode(data).encode('utf-8'))
3232
elif format == 'binary':
3333
return len(encode_binary(data))
@@ -52,7 +52,7 @@ def compare_formats(data: Any) -> Dict[str, Any]:
5252
>>> result['savings']['zon_vs_json']
5353
35.5
5454
"""
55-
zon_size = size(data, 'zon')
55+
zonf_size = size(data, 'zonf')
5656
binary_size = size(data, 'binary')
5757
json_size = size(data, 'json')
5858

@@ -64,13 +64,13 @@ def calc_savings(smaller: int, larger: int) -> float:
6464
return (1 - smaller / larger) * 100
6565

6666
return {
67-
'zon': zon_size,
67+
'zonf': zonf_size,
6868
'binary': binary_size,
6969
'json': json_size,
7070
'savings': {
71-
'zon_vs_json': calc_savings(zon_size, json_size),
71+
'zonf_vs_json': calc_savings(zonf_size, json_size),
7272
'binary_vs_json': calc_savings(binary_size, json_size),
73-
'binary_vs_zon': calc_savings(binary_size, zon_size)
73+
'binary_vs_zonf': calc_savings(binary_size, zonf_size)
7474
}
7575
}
7676

@@ -194,8 +194,8 @@ def compare(data1: Any, data2: Any) -> Dict[str, Any]:
194194
'equal': data1 == data2,
195195
'data1_type': type(data1).__name__,
196196
'data2_type': type(data2).__name__,
197-
'data1_size': size(data1, 'zon'),
198-
'data2_size': size(data2, 'zon')
197+
'data1_size': size(data1, 'zonf'),
198+
'data2_size': size(data2, 'zonf')
199199
}
200200

201201

@@ -220,7 +220,7 @@ def is_safe(data: Any, max_depth: int = 10, max_size: int = 1000000) -> Dict[str
220220
stats = analyze(data)
221221
depth = stats['depth']
222222

223-
encoded_size = size(data, 'zon')
223+
encoded_size = size(data, 'zonf')
224224

225225
safe = depth <= max_depth and encoded_size <= max_size
226226

zon-format/src/zon/versioning/versioning.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class ZonDocumentMetadata:
1919
schema_id: Optional[str] = None
2020
"""Optional schema identifier (e.g., "user-profile-v2")"""
2121

22-
encoding: str = 'zon'
23-
"""Encoding format used ("zon" | "zon-binary")"""
22+
encoding: str = 'zonf'
23+
"""Encoding format used ("zonf" | "zonb")"""
2424

2525
timestamp: Optional[int] = None
2626
"""Unix timestamp when document was created"""
@@ -48,7 +48,7 @@ def from_dict(cls, data: Dict[str, Any]) -> 'ZonDocumentMetadata':
4848
return cls(
4949
version=data['version'],
5050
schema_id=data.get('schemaId'),
51-
encoding=data.get('encoding', 'zon'),
51+
encoding=data.get('encoding', 'zonf'),
5252
timestamp=data.get('timestamp'),
5353
custom=data.get('custom', {})
5454
)
@@ -58,7 +58,7 @@ def embed_version(
5858
data: Any,
5959
version: str,
6060
schema_id: Optional[str] = None,
61-
encoding: str = 'zon'
61+
encoding: str = 'zonf'
6262
) -> Dict[str, Any]:
6363
"""Embeds version metadata into a data object.
6464
@@ -68,7 +68,7 @@ def embed_version(
6868
data: Data object to add metadata to
6969
version: Semantic version string (e.g., "1.0.0")
7070
schema_id: Optional schema identifier
71-
encoding: Encoding format ('zon' or 'zon-binary')
71+
encoding: Encoding format ('zonf' or 'zonb')
7272
7373
Returns:
7474
Data object with embedded metadata

zon-format/tests/unit/tools/test_helpers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
class TestSize:
88
"""Test size calculation"""
99

10-
def test_size_zon(self):
10+
def test_size_zonf(self):
1111
"""Test ZON size calculation"""
1212
data = {"name": "Alice", "age": 30}
13-
zon_size = size(data, 'zon')
14-
assert zon_size > 0
13+
zonf_size = size(data, 'zonf')
14+
assert zonf_size > 0
1515

1616
def test_size_binary(self):
1717
"""Test binary size calculation"""
@@ -43,7 +43,7 @@ def test_compare_formats_structure(self):
4343
data = {"test": "value"}
4444
result = compare_formats(data)
4545

46-
assert 'zon' in result
46+
assert 'zonf' in result
4747
assert 'binary' in result
4848
assert 'json' in result
4949
assert 'savings' in result
@@ -53,16 +53,16 @@ def test_compare_formats_savings(self):
5353
data = [{"id": i, "name": f"User{i}"} for i in range(10)]
5454
result = compare_formats(data)
5555

56-
assert 'zon_vs_json' in result['savings']
56+
assert 'zonf_vs_json' in result['savings']
5757
assert 'binary_vs_json' in result['savings']
58-
assert 'binary_vs_zon' in result['savings']
58+
assert 'binary_vs_zonf' in result['savings']
5959

6060
def test_compare_formats_all_positive_sizes(self):
6161
"""Test all sizes are positive"""
6262
data = {"users": [{"id": 1}]}
6363
result = compare_formats(data)
6464

65-
assert result['zon'] > 0
65+
assert result['zonf'] > 0
6666
assert result['binary'] > 0
6767
assert result['json'] > 0
6868

zon-format/tests/unit/versioning/test_versioning.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def test_embed_version_with_schema_id(self):
3535
def test_embed_version_with_encoding(self):
3636
"""Test embedding with encoding type"""
3737
data = {"test": "value"}
38-
versioned = embed_version(data, "1.0.0", encoding="zon-binary")
38+
versioned = embed_version(data, "1.0.0", encoding="zonb")
3939

40-
assert versioned['__zon_meta']['encoding'] == "zon-binary"
40+
assert versioned['__zon_meta']['encoding'] == "zonb"
4141

4242
def test_embed_version_adds_timestamp(self):
4343
"""Test that timestamp is added"""
@@ -86,10 +86,10 @@ def test_extract_version_from_invalid(self):
8686
def test_extract_version_preserves_encoding(self):
8787
"""Test that encoding is preserved"""
8888
data = {"test": "value"}
89-
versioned = embed_version(data, "1.0.0", encoding="zon-binary")
89+
versioned = embed_version(data, "1.0.0", encoding="zonb")
9090

9191
meta = extract_version(versioned)
92-
assert meta.encoding == "zon-binary"
92+
assert meta.encoding == "zonb"
9393

9494

9595
class TestVersionStripping:
@@ -184,29 +184,29 @@ def test_metadata_to_dict(self):
184184
meta = ZonDocumentMetadata(
185185
version="1.0.0",
186186
schema_id="test",
187-
encoding="zon",
187+
encoding="zonf",
188188
timestamp=1234567890
189189
)
190190

191191
d = meta.to_dict()
192192
assert d['version'] == "1.0.0"
193193
assert d['schemaId'] == "test"
194-
assert d['encoding'] == "zon"
194+
assert d['encoding'] == "zonf"
195195
assert d['timestamp'] == 1234567890
196196

197197
def test_metadata_from_dict(self):
198198
"""Test creating metadata from dict"""
199199
d = {
200200
'version': '2.0.0',
201201
'schemaId': 'user-profile',
202-
'encoding': 'zon-binary',
202+
'encoding': 'zonb',
203203
'timestamp': 9876543210
204204
}
205205

206206
meta = ZonDocumentMetadata.from_dict(d)
207207
assert meta.version == '2.0.0'
208208
assert meta.schema_id == 'user-profile'
209-
assert meta.encoding == 'zon-binary'
209+
assert meta.encoding == 'zonb'
210210
assert meta.timestamp == 9876543210
211211

212212
def test_metadata_roundtrip(self):

0 commit comments

Comments
 (0)