Skip to content
Snippets Groups Projects
Commit d1631724 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

refactor: deduplication + fixed PyPy's deploy

parent 2e071518
No related branches found
No related tags found
No related merge requests found
......@@ -131,7 +131,7 @@ jobs:
before_script:
- sudo apt-get update
- sudo apt-get install -y patchelf
- pypy3 -m pip install wheel auditwheel twine doctor-wheel cython
- pypy3 -m pip install -U wheel auditwheel twine doctor-wheel cython
script:
- pypy3 setup.py bdist_wheel
- cd dist
......
FROM python:3.8
RUN apt-get update && \
apt-get install -y patchelf
RUN python -m pip install Cython pytest coverage pytest-cov auditwheel doctor-wheel twine
RUN python -m pip install Cython pytest coverage pytest-cov
WORKDIR /tmp/compile
ADD . /tmp/compile/
......
......@@ -28,3 +28,5 @@ Alternatively, you can
and I'll do my best to compile a wheel for you.
In order to do that you must have `Cython` installed.
Run the Dockerfile to launch unit tests locally.
Changelog
=========
v2.9
----
* minor refactor: code deduplication
v2.8
----
......
......@@ -341,7 +341,7 @@ cdef class MiniJSONEncoder:
self.use_double = use_double
self.use_strict_order = use_strict_order
def should_double_be_used(self, y) -> bool:
def should_double_be_used(self, y: float) -> bool:
"""
A function that you are meant to overload that will decide on a per-case basis
which representation should be used for given number.
......@@ -514,18 +514,17 @@ cdef class MiniJSONEncoder:
cio.write(b'\x12')
cio.write(STRUCT_L.pack(length))
length = 5
data = data.items()
if self.use_strict_order:
items = list(data.items())
items.sort()
for field_name, elem in items:
cio.write(bytearray([len(field_name)]))
cio.write(field_name.encode('utf-8'))
length += self.dump(elem, cio)
else:
for field_name, elem in data.items():
cio.write(bytearray([len(field_name)]))
cio.write(field_name.encode('utf-8'))
length += self.dump(elem, cio)
data = list(data)
data.sort() # sort implicitly will sort it by first value, which is the key
for field_name, elem in data:
cio.write(bytearray([len(field_name)]))
cio.write(field_name.encode('utf-8'))
length += self.dump(elem, cio)
return length
else:
if length <= 0xF:
......@@ -542,16 +541,13 @@ cdef class MiniJSONEncoder:
cio.write(b'\x13')
cio.write(STRUCT_L.pack(length))
offset = 5
data = data.items()
if self.use_strict_order:
items = list(data.items())
items.sort()
for key, value in items:
offset += self.dump(key, cio)
offset += self.dump(value, cio)
else:
for key, value in data.items():
offset += self.dump(key, cio)
offset += self.dump(value, cio)
data = list(data)
data.sort() # sort implicitly will sort it by first value, which is the key
for key, value in data:
offset += self.dump(key, cio)
offset += self.dump(value, cio)
return offset
else:
v = self.default(data)
......
# coding: utf-8
[metadata]
version = 2.8
version = 2.9a1
name = minijson
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment