Skip to content

Commit 8deb843

Browse files
authored
Merge pull request #74 from Kijewski/pr-typing
Fix type hints for optional arguments
2 parents 8441390 + c0cc1cd commit 8deb843

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
**1.6.5 (2023-12-04)**
4+
5+
* Fix type hints for optional arguments
6+
37
**1.6.4 (2023-07-31)**
48

59
* Update to Cython 3

requirements-readthedocs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# keep synchronous to setup.cfg
22
# keep synchronous to src/VERSION.inc
3-
pyjson5 == 1.6.4
3+
pyjson5 == 1.6.5
44

55
# keep synchronous to requirements-dev.txt
66
docutils == 0.19.*

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
# keep synchronous to requirements-readthedocs.txt
33
# keep synchronous to src/VERSION.inc
4-
version = 1.6.4
4+
version = 1.6.5
55

66
name = pyjson5
77
description = JSON5 serializer and parser for Python 3 written in Cython.

src/VERSION.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"1.6.4"
1+
"1.6.5"

src/pyjson5/__init__.pyi

+20-20
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ class Options:
4545
self,
4646
*,
4747
quotationmark: Optional[str] = ...,
48-
tojson: Optional[str],
49-
mappingtypes: Optional[Tuple[type, ...]],
48+
tojson: Optional[str] = ...,
49+
mappingtypes: Optional[Tuple[type, ...]] = ...,
5050
) -> None: ...
5151
def update(
5252
self,
5353
*,
5454
quotationmark: Optional[str] = ...,
55-
tojson: Optional[str],
56-
mappingtypes: Optional[Tuple[type, ...]],
55+
tojson: Optional[str] = ...,
56+
mappingtypes: Optional[Tuple[type, ...]] = ...,
5757
) -> Options:
5858
"""Creates a new Options instance by modifying some members."""
5959

@@ -86,7 +86,7 @@ def decode_callback(
8686
cb: Callable[..., Union[str, bytes, bytearray, int, None]],
8787
maxdepth: Optional[int] = ...,
8888
some: bool = ...,
89-
args: Optional[Iterable[Any]] = [],
89+
args: Optional[Iterable[Any]] = ...,
9090
) -> Any:
9191
"""Decodes JSON5 serialized data by invoking a callback."""
9292

@@ -102,8 +102,8 @@ def encode(
102102
*,
103103
options: Optional[Options] = ...,
104104
quotationmark: Optional[str] = ...,
105-
tojson: Optional[str],
106-
mappingtypes: Optional[Tuple[type, ...]],
105+
tojson: Optional[str] = ...,
106+
mappingtypes: Optional[Tuple[type, ...]] = ...,
107107
) -> str:
108108
"""Serializes a Python object to a JSON5 compatible string."""
109109
...
@@ -113,9 +113,9 @@ def encode_bytes(
113113
*,
114114
options: Optional[Options] = ...,
115115
quotationmark: Optional[str] = ...,
116-
tojson: Optional[str],
117-
mappingtypes: Optional[Tuple[type, ...]],
118-
) -> str:
116+
tojson: Optional[str] = ...,
117+
mappingtypes: Optional[Tuple[type, ...]] = ...,
118+
) -> bytes:
119119
"""Serializes a Python object to a JSON5 compatible bytes string."""
120120

121121
@overload
@@ -126,8 +126,8 @@ def encode_callback(
126126
*,
127127
options: Optional[Options] = ...,
128128
quotationmark: Optional[str] = ...,
129-
tojson: Optional[str],
130-
mappingtypes: Optional[Tuple[type, ...]],
129+
tojson: Optional[str] = ...,
130+
mappingtypes: Optional[Tuple[type, ...]] = ...,
131131
) -> _CallbackStr:
132132
"""Serializes a Python object into a callback function."""
133133

@@ -139,8 +139,8 @@ def encode_callback(
139139
*,
140140
options: Optional[Options] = ...,
141141
quotationmark: Optional[str] = ...,
142-
tojson: Optional[str],
143-
mappingtypes: Optional[Tuple[type, ...]],
142+
tojson: Optional[str] = ...,
143+
mappingtypes: Optional[Tuple[type, ...]] = ...,
144144
) -> _CallbackBytes: ...
145145
@overload
146146
def encode_io(
@@ -150,8 +150,8 @@ def encode_io(
150150
*,
151151
options: Optional[Options] = ...,
152152
quotationmark: Optional[str] = ...,
153-
tojson: Optional[str],
154-
mappingtypes: Optional[Tuple[type, ...]],
153+
tojson: Optional[str] = ...,
154+
mappingtypes: Optional[Tuple[type, ...]] = ...,
155155
) -> _SupportsWriteBytes:
156156
"""Serializes a Python object into a file-object."""
157157

@@ -163,16 +163,16 @@ def encode_io(
163163
*,
164164
options: Optional[Options] = ...,
165165
quotationmark: Optional[str] = ...,
166-
tojson: Optional[str],
167-
mappingtypes: Optional[Tuple[type, ...]],
166+
tojson: Optional[str] = ...,
167+
mappingtypes: Optional[Tuple[type, ...]] = ...,
168168
) -> _SupportsWriteStr: ...
169169
def encode_noop(
170170
data: Any,
171171
*,
172172
options: Optional[Options] = ...,
173173
quotationmark: Optional[str] = ...,
174-
tojson: Optional[str],
175-
mappingtypes: Optional[Tuple[type, ...]],
174+
tojson: Optional[str] = ...,
175+
mappingtypes: Optional[Tuple[type, ...]] = ...,
176176
) -> bool:
177177
"""Test if the input is serializable."""
178178

0 commit comments

Comments
 (0)