Skip to content

Commit e117948

Browse files
authored
Merge pull request #62 from Kijewski/pr-issue-61
Fix typing for _SupportsWrite
2 parents fe70ed0 + fcd7a8d commit e117948

25 files changed

+493
-407
lines changed

.github/workflows/ci.yml

+38-10
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@ jobs:
1111
- ubuntu-latest
1212
- macos-latest
1313
- windows-latest
14-
python: [
15-
'3.5',
16-
# '3.6', '3.7', '3.8', '3.9', # it takes too much GitHub action time to run tests on all versions in between
17-
'3.10',
18-
]
19-
include:
20-
- os: ubuntu-latest
21-
python: pypy-3.7
22-
23-
name: Python ${{ matrix.python }} on ${{ matrix.os }}
14+
python:
15+
- '3.8'
16+
- '3.11'
2417

2518
steps:
2619
- uses: actions/checkout@v3
@@ -56,3 +49,38 @@ jobs:
5649

5750
- name: Run "JSON is a Minefield" suite
5851
run: python run-minefield-test.py
52+
53+
lint:
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- uses: actions/checkout@v3
58+
with:
59+
submodules: true
60+
61+
- name: Cache pip
62+
uses: actions/cache@v3
63+
with:
64+
key: lint--${{ hashFiles('./requirements*.txt', './Makefile') }}
65+
restore-keys: lint--
66+
path: ~/.cache/pip
67+
68+
- name: Setup python
69+
uses: actions/setup-python@v4
70+
with:
71+
python-version: '3.11'
72+
73+
- name: Display Python version
74+
run: python -c 'import sys; print(sys.version)'
75+
76+
- name: Update pip
77+
run: python -m pip install -U pip wheel setuptools
78+
79+
- name: Install requirements
80+
run: python -m pip install -Ur requirements-dev.txt
81+
82+
- name: Compile project
83+
run: make install
84+
85+
- name: Run black
86+
run: python -m black --check ./*.py ./src/

.github/workflows/codeql-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Cache pip
3232
uses: actions/cache@v3
3333
with:
34-
key: codeql-analysis--${{ github.event.inputs.os }}--${{ github.event.inputs.python }}--${{ hashFiles('./requirements.txt') }}
34+
key: codeql-analysis--${{ github.event.inputs.os }}--${{ github.event.inputs.python }}--${{ hashFiles('./requirements-dev.txt') }}
3535
path: ~/.cache/pip
3636

3737
- name: Setup python
@@ -48,7 +48,7 @@ jobs:
4848
run: python -m pip install -U pip wheel setuptools
4949

5050
- name: Install requirements
51-
run: python -m pip install -Ur requirements.txt
51+
run: python -m pip install -Ur requirements-dev.txt
5252

5353
- name: Compile
5454
run: make bdist_wheel

CHANGELOG.md

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

3+
**1.6.3**
4+
5+
* Fix typing for `dump()` ([#61](https://github.com/Kijewski/pyjson5/issues/61))
6+
37
**1.6.2**
48

59
* Update to Unicode 15.0.0

Makefile

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
all: sdist bdist_wheel docs
1+
all: sdist wheel docs
22

33
.DELETE_ON_ERROR:
44

5-
.PHONY: all sdist bdist_wheel clean docs prepare test install
5+
.PHONY: all sdist wheel clean docs prepare test install
66

77
export PYTHONUTF8 := 1
88
export PYTHONIOENCODING := UTF-8
@@ -34,14 +34,14 @@ pyjson5.cpp: pyjson5.pyx $(wildcard src/*.pyx) $(wildcard src/*.hpp)
3434
prepare: pyjson5.cpp ${FILES}
3535

3636
sdist: prepare
37-
rm -f -- dist/pyjson5-*.tar.gz
38-
python setup.py sdist
37+
-rm -- dist/pyjson5-*.tar.gz
38+
python -m build --sdist
3939

40-
bdist_wheel: pyjson5.cpp ${FILES} | sdist
41-
rm -f -- dist/pyjson5-*.whl
42-
python setup.py bdist_wheel
40+
wheel: prepare
41+
-rm -- dist/pyjson5-*.whl
42+
python -m build --wheel
4343

44-
install: bdist_wheel
44+
install: wheel
4545
pip install --force dist/pyjson5-*.whl
4646

4747
docs: install $(wildcard docs/* docs/*/*)
@@ -51,9 +51,9 @@ clean:
5151
[ ! -d build/ ] || rm -r -- build/
5252
[ ! -d dist/ ] || rm -r -- dist/
5353
[ ! -d pyjson5.egg-info/ ] || rm -r -- pyjson5.egg-info/
54-
rm -f -- pyjson5.*.so python5.cpp
54+
-rm -- pyjson5.*.so python5.cpp
5555

56-
test: bdist_wheel
56+
test: wheel
5757
pip install --force dist/pyjson5-*.whl
5858
python run-minefield-test.py
5959
python run-tests.py

docs/conf.py

+7-31
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
'myst_parser',
1717
]
1818

19+
language = "en"
20+
1921
templates_path = ['_templates']
2022
source_suffix = '.rst'
2123
master_doc = 'index'
2224

23-
project = u'PyJSON5'
24-
copyright = u'2018-2022, René Kijewski'
25-
author = u'René Kijewski'
25+
project = 'PyJSON5'
26+
copyright = '2018-2023, René Kijewski'
27+
author = 'René Kijewski'
2628

2729
with open('../src/VERSION.inc', 'rt') as f:
2830
version = eval(f.read().strip())
@@ -33,41 +35,15 @@
3335
pygments_style = 'sphinx'
3436
todo_include_todos = False
3537

36-
html_theme = 'sphinx_rtd_theme'
37-
html_theme_options = {
38-
'navigation_depth': -1,
39-
}
40-
html_sidebars = {
41-
'**': [
42-
'localtoc.html',
43-
'searchbox.html',
44-
]
45-
}
38+
html_theme = 'furo'
4639
htmlhelp_basename = 'PyJSON5doc'
4740

48-
latex_elements = {}
49-
latex_documents = [
50-
(master_doc, 'PyJSON5.tex', u'PyJSON5 Documentation',
51-
u'René Kijewski', 'manual'),
52-
]
53-
54-
man_pages = [
55-
(master_doc, 'pyjson5', u'PyJSON5 Documentation',
56-
[author], 1)
57-
]
58-
59-
texinfo_documents = [
60-
(master_doc, 'PyJSON5', u'PyJSON5 Documentation',
61-
author, 'PyJSON5', 'One line description of project.',
62-
'Miscellaneous'),
63-
]
64-
6541
display_toc = True
6642
autodoc_default_flags = ['members']
6743
autosummary_generate = True
6844

6945
intersphinx_mapping = {
70-
'python': ('https://docs.python.org/3.10', None),
46+
'python': ('https://docs.python.org/3.11', None),
7147
}
7248

7349
inheritance_graph_attrs = {

docs/decoder.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,26 @@ Decoder Exceptions
5959
pyjson5.Json5ExtraData
6060
pyjson5.Json5IllegalType
6161

62-
.. autoclass:: pyjson5.Json5DecoderException
62+
.. autoexception:: pyjson5.Json5DecoderException
6363
:members:
6464
:inherited-members:
6565

66-
.. autoclass:: pyjson5.Json5NestingTooDeep
66+
.. autoexception:: pyjson5.Json5NestingTooDeep
6767
:members:
6868
:inherited-members:
6969

70-
.. autoclass:: pyjson5.Json5EOF
70+
.. autoexception:: pyjson5.Json5EOF
7171
:members:
7272
:inherited-members:
7373

74-
.. autoclass:: pyjson5.Json5IllegalCharacter
74+
.. autoexception:: pyjson5.Json5IllegalCharacter
7575
:members:
7676
:inherited-members:
7777

78-
.. autoclass:: pyjson5.Json5ExtraData
78+
.. autoexception:: pyjson5.Json5ExtraData
7979
:members:
8080
:inherited-members:
8181

82-
.. autoclass:: pyjson5.Json5IllegalType
82+
.. autoexception:: pyjson5.Json5IllegalType
8383
:members:
8484
:inherited-members:

docs/encoder.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ Encoder Exceptions
6464
pyjson5.Json5EncoderException
6565
pyjson5.Json5UnstringifiableType
6666

67-
.. autoclass:: pyjson5.Json5EncoderException
67+
.. autoexception:: pyjson5.Json5EncoderException
6868
:members:
6969
:inherited-members:
7070

71-
.. autoclass:: pyjson5.Json5UnstringifiableType
71+
.. autoexception:: pyjson5.Json5UnstringifiableType
7272
:members:
7373
:inherited-members:

docs/exceptions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ Exceptions
1212
pyjson5.Json5ExtraData
1313
pyjson5.Json5IllegalType
1414

15-
.. autoclass:: pyjson5.Json5Exception
15+
.. autoexception:: pyjson5.Json5Exception
1616
:members:
1717
:inherited-members:

make_decoder_recursive_select.py

+39-35
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,58 @@
88

99

1010
def generate(out):
11-
lst = ['DRS_fail'] * 128
12-
lst[ord('n')] = 'DRS_null'
13-
lst[ord('t')] = 'DRS_true'
14-
lst[ord('f')] = 'DRS_false'
15-
lst[ord('I')] = 'DRS_inf'
16-
lst[ord('N')] = 'DRS_nan'
17-
lst[ord('"')] = 'DRS_string'
18-
lst[ord("'")] = 'DRS_string'
19-
lst[ord('{')] = 'DRS_recursive'
20-
lst[ord('[')] = 'DRS_recursive'
21-
for c in '+-.0123456789':
22-
lst[ord(c)] = 'DRS_number'
23-
24-
print('#ifndef JSON5EncoderCpp_decoder_recursive_select', file=out)
25-
print('#define JSON5EncoderCpp_decoder_recursive_select', file=out)
11+
lst = ["DRS_fail"] * 128
12+
lst[ord("n")] = "DRS_null"
13+
lst[ord("t")] = "DRS_true"
14+
lst[ord("f")] = "DRS_false"
15+
lst[ord("I")] = "DRS_inf"
16+
lst[ord("N")] = "DRS_nan"
17+
lst[ord('"')] = "DRS_string"
18+
lst[ord("'")] = "DRS_string"
19+
lst[ord("{")] = "DRS_recursive"
20+
lst[ord("[")] = "DRS_recursive"
21+
for c in "+-.0123456789":
22+
lst[ord(c)] = "DRS_number"
23+
24+
print("#ifndef JSON5EncoderCpp_decoder_recursive_select", file=out)
25+
print("#define JSON5EncoderCpp_decoder_recursive_select", file=out)
2626
print(file=out)
27-
print('// GENERATED FILE', file=out)
28-
print('// All changes will be lost.', file=out)
27+
print("// GENERATED FILE", file=out)
28+
print("// All changes will be lost.", file=out)
2929
print(file=out)
30-
print('#include <cstdint>', file=out)
30+
print("#include <cstdint>", file=out)
3131
print(file=out)
32-
print('namespace JSON5EncoderCpp {', file=out)
33-
print('inline namespace {', file=out)
32+
print("namespace JSON5EncoderCpp {", file=out)
33+
print("inline namespace {", file=out)
3434
print(file=out)
35-
print('enum DrsKind : std::uint8_t {', file=out)
36-
print(' DRS_fail, DRS_null, DRS_true, DRS_false, DRS_inf, DRS_nan, DRS_string, DRS_number, DRS_recursive', file=out)
37-
print('};', file=out)
35+
print("enum DrsKind : std::uint8_t {", file=out)
36+
print(
37+
" DRS_fail, DRS_null, DRS_true, DRS_false, DRS_inf, DRS_nan, DRS_string, DRS_number, DRS_recursive",
38+
file=out,
39+
)
40+
print("};", file=out)
3841
print(file=out)
39-
print('static const DrsKind drs_lookup[128] = {', file=out)
42+
print("static const DrsKind drs_lookup[128] = {", file=out)
4043
for chunk in chunked(lst, 8):
41-
print(' ', end='', file=out)
44+
print(" ", end="", file=out)
4245
for t in chunk:
43-
print(' ', t, ',', sep='', end='', file=out)
46+
print(" ", t, ",", sep="", end="", file=out)
4447
print(file=out)
45-
print('};', file=out)
48+
print("};", file=out)
4649
print(file=out)
47-
print('} // anonymous inline namespace', sep='', file=out)
48-
print('} // namespace JSON5EncoderCpp', sep='', file=out)
50+
print("} // anonymous inline namespace", sep="", file=out)
51+
print("} // namespace JSON5EncoderCpp", sep="", file=out)
4952
print(file=out)
50-
print('#endif', sep='', file=out)
53+
print("#endif", sep="", file=out)
5154

5255

53-
argparser = ArgumentParser(description='Generate src/_decoder_recursive_select.hpp')
54-
argparser.add_argument('input', nargs='?', type=Path, default=Path('src/_decoder_recursive_select.hpp'))
56+
argparser = ArgumentParser(description="Generate src/_decoder_recursive_select.hpp")
57+
argparser.add_argument(
58+
"input", nargs="?", type=Path, default=Path("src/_decoder_recursive_select.hpp")
59+
)
5560

56-
if __name__ == '__main__':
61+
if __name__ == "__main__":
5762
basicConfig(level=DEBUG)
5863
args = argparser.parse_args()
59-
with open(str(args.input.resolve()), 'wt') as out:
64+
with open(str(args.input.resolve()), "wt") as out:
6065
generate(out)
61-

0 commit comments

Comments
 (0)