Skip to content

Commit

Permalink
Document duplicate key
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo committed Aug 19, 2024
1 parent 19bd736 commit 8df9561
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/jsonyx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (C) 2024 Nice Zombies
# TODO(Nice Zombies): add changelog
"""jsonyx module for JSON manipulation."""
from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/jsonyx/_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class DuplicateKey(str):
"""Duplicate key.
>>> import jsonyx as json
>>> {"key": "value 1", json.DuplicateKey("key"): "value 2"}
>>> {'key': 'value 1', json.DuplicateKey('key'): 'value 2'}
{'key': 'value 1', 'key': 'value 2'}
"""

Expand Down
8 changes: 7 additions & 1 deletion src/jsonyx/_speedups.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ static Py_hash_t duplicatekey_hash(PyUnicodeObject *self) {
static PyTypeObject PyDuplicateKeyType = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "jsonyx.DuplicateKey",
.tp_doc = PyDoc_STR("Duplicate key"),
.tp_doc = PyDoc_STR(
"Duplicate key.\n"
"\n"
">>> import jsonyx as json\n"
">>> {'key': 'value 1', json.DuplicateKey('key'): 'value 2'}\n"
"{'key': 'value 1', 'key': 'value 2'}\n"
),
.tp_hash = (hashfunc)duplicatekey_hash,
};

Expand Down

0 comments on commit 8df9561

Please sign in to comment.