Skip to content

Commit cb50b20

Browse files
authored
Update setuptools and black (#498)
* Use setuptools * Use black==22.1.0
1 parent 89ea577 commit cb50b20

File tree

13 files changed

+83
-84
lines changed

13 files changed

+83
-84
lines changed

.github/workflows/black.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
architecture: 'x64'
1818

1919
- name: Checkout
20-
uses: actions/checkout@v1
20+
uses: actions/checkout@v2
2121

2222
- name: Black Code Formatter
2323
run: |
24-
pip install black
25-
black --diff --check msgpack/ test/ setup.py
24+
pip install black==22.1.0
25+
black -S --diff --check msgpack/ test/ setup.py

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ all: cython
44

55
.PHONY: black
66
black:
7-
black msgpack/ test/ setup.py
7+
black -S msgpack/ test/ setup.py
88

99
.PHONY: cython
1010
cython:

msgpack/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# coding: utf-8
2-
from ._version import version
32
from .exceptions import *
43
from .ext import ExtType, Timestamp
54

65
import os
76
import sys
87

98

9+
version = (1, 0, 4, 'dev')
10+
__version__ = "1.0.4dev"
11+
12+
1013
if os.environ.get("MSGPACK_PUREPYTHON") or sys.version_info[0] == 2:
1114
from .fallback import Packer, unpackb, Unpacker
1215
else:

msgpack/_version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

msgpack/ext.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, seconds, nanoseconds=0):
5959
raise TypeError("seconds must be an interger")
6060
if not isinstance(nanoseconds, int_types):
6161
raise TypeError("nanoseconds must be an integer")
62-
if not (0 <= nanoseconds < 10 ** 9):
62+
if not (0 <= nanoseconds < 10**9):
6363
raise ValueError(
6464
"nanoseconds must be a non-negative integer less than 999999999."
6565
)
@@ -143,7 +143,7 @@ def from_unix(unix_sec):
143143
:type unix_float: int or float.
144144
"""
145145
seconds = int(unix_sec // 1)
146-
nanoseconds = int((unix_sec % 1) * 10 ** 9)
146+
nanoseconds = int((unix_sec % 1) * 10**9)
147147
return Timestamp(seconds, nanoseconds)
148148

149149
def to_unix(self):
@@ -161,15 +161,15 @@ def from_unix_nano(unix_ns):
161161
:param int unix_ns: Posix timestamp in nanoseconds.
162162
:rtype: Timestamp
163163
"""
164-
return Timestamp(*divmod(unix_ns, 10 ** 9))
164+
return Timestamp(*divmod(unix_ns, 10**9))
165165

166166
def to_unix_nano(self):
167167
"""Get the timestamp as a unixtime in nanoseconds.
168168
169169
:returns: posix timestamp in nanoseconds
170170
:rtype: int
171171
"""
172-
return self.seconds * 10 ** 9 + self.nanoseconds
172+
return self.seconds * 10**9 + self.nanoseconds
173173

174174
def to_datetime(self):
175175
"""Get the timestamp as a UTC datetime.

msgpack/fallback.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def __init__(
318318
self._buf_checkpoint = 0
319319

320320
if not max_buffer_size:
321-
max_buffer_size = 2 ** 31 - 1
321+
max_buffer_size = 2**31 - 1
322322
if max_str_len == -1:
323323
max_str_len = max_buffer_size
324324
if max_bin_len == -1:
@@ -800,20 +800,20 @@ def _pack(
800800
raise OverflowError("Integer value out of range")
801801
if check(obj, (bytes, bytearray)):
802802
n = len(obj)
803-
if n >= 2 ** 32:
803+
if n >= 2**32:
804804
raise ValueError("%s is too large" % type(obj).__name__)
805805
self._pack_bin_header(n)
806806
return self._buffer.write(obj)
807807
if check(obj, unicode):
808808
obj = obj.encode("utf-8", self._unicode_errors)
809809
n = len(obj)
810-
if n >= 2 ** 32:
810+
if n >= 2**32:
811811
raise ValueError("String is too large")
812812
self._pack_raw_header(n)
813813
return self._buffer.write(obj)
814814
if check(obj, memoryview):
815815
n = len(obj) * obj.itemsize
816-
if n >= 2 ** 32:
816+
if n >= 2**32:
817817
raise ValueError("Memoryview is too large")
818818
self._pack_bin_header(n)
819819
return self._buffer.write(obj)
@@ -895,7 +895,7 @@ def pack_map_pairs(self, pairs):
895895
return ret
896896

897897
def pack_array_header(self, n):
898-
if n >= 2 ** 32:
898+
if n >= 2**32:
899899
raise ValueError
900900
self._pack_array_header(n)
901901
if self._autoreset:
@@ -904,7 +904,7 @@ def pack_array_header(self, n):
904904
return ret
905905

906906
def pack_map_header(self, n):
907-
if n >= 2 ** 32:
907+
if n >= 2**32:
908908
raise ValueError
909909
self._pack_map_header(n)
910910
if self._autoreset:

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Also declared in pyproject.toml, if updating here please also update there
22
Cython~=0.29.13
3+
4+
# dev only tools. no need to add pyproject
5+
black==22.1.0

setup.cfg

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[metadata]
2+
name = msgpack
3+
#version = attr: msgpack.__version__
4+
version = attr: msgpack.version
5+
license = Apache 2.0
6+
author = Inada Naoki
7+
author_email = songofacandy@gmail.com
8+
description = MessagePack serializer
9+
long_description = file: README.md
10+
long_description_content_type = text/markdown
11+
url = https://msgpack.org/
12+
13+
project_urls =
14+
Documentation = https://msgpack-python.readthedocs.io/
15+
Source = https://github.com/msgpack/msgpack-python
16+
Tracker = https://github.com/msgpack/msgpack-python/issues
17+
18+
classifiers =
19+
Programming Language :: Python :: 3
20+
Programming Language :: Python :: 3.6
21+
Programming Language :: Python :: 3.7
22+
Programming Language :: Python :: 3.8
23+
Programming Language :: Python :: 3.9
24+
Programming Language :: Python :: 3.10
25+
Programming Language :: Python :: Implementation :: CPython
26+
Programming Language :: Python :: Implementation :: PyPy
27+
Intended Audience :: Developers
28+
License :: OSI Approved :: Apache Software License
29+
30+
[flake8]
31+
max_line_length = 100
32+

setup.py

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import os
55
import sys
66
from glob import glob
7-
from distutils.command.sdist import sdist
87
from setuptools import setup, Extension
9-
10-
from distutils.command.build_ext import build_ext
8+
from setuptools.command.build_ext import build_ext
9+
from setuptools.command.sdist import sdist
1110

1211

1312
PYPY = hasattr(sys, "pypy_version_info")
@@ -65,12 +64,6 @@ def build_extension(self, ext):
6564
print(e)
6665

6766

68-
exec(open("msgpack/_version.py").read())
69-
70-
version_str = ".".join(str(x) for x in version[:3])
71-
if len(version) > 3 and version[3] != "final":
72-
version_str += version[3]
73-
7467
# Cython is required for sdist
7568
class Sdist(sdist):
7669
def __init__(self, *args, **kwargs):
@@ -99,39 +92,8 @@ def __init__(self, *args, **kwargs):
9992
del libraries, macros
10093

10194

102-
desc = "MessagePack (de)serializer."
103-
with io.open("README.md", encoding="utf-8") as f:
104-
long_desc = f.read()
105-
del f
106-
10795
setup(
108-
name="msgpack",
109-
author="Inada Naoki",
110-
author_email="songofacandy@gmail.com",
111-
version=version_str,
11296
cmdclass={"build_ext": BuildExt, "sdist": Sdist},
11397
ext_modules=ext_modules,
11498
packages=["msgpack"],
115-
description=desc,
116-
long_description=long_desc,
117-
long_description_content_type="text/markdown",
118-
url="https://msgpack.org/",
119-
project_urls={
120-
"Documentation": "https://msgpack-python.readthedocs.io/",
121-
"Source": "https://github.com/msgpack/msgpack-python",
122-
"Tracker": "https://github.com/msgpack/msgpack-python/issues",
123-
},
124-
license="Apache 2.0",
125-
classifiers=[
126-
"Programming Language :: Python :: 3",
127-
"Programming Language :: Python :: 3.6",
128-
"Programming Language :: Python :: 3.7",
129-
"Programming Language :: Python :: 3.8",
130-
"Programming Language :: Python :: 3.9",
131-
"Programming Language :: Python :: 3.10",
132-
"Programming Language :: Python :: Implementation :: CPython",
133-
"Programming Language :: Python :: Implementation :: PyPy",
134-
"Intended Audience :: Developers",
135-
"License :: OSI Approved :: Apache Software License",
136-
],
13799
)

test/test_limits.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@
1616

1717

1818
def test_integer():
19-
x = -(2 ** 63)
19+
x = -(2**63)
2020
assert unpackb(packb(x)) == x
2121
with pytest.raises(PackOverflowError):
2222
packb(x - 1)
2323

24-
x = 2 ** 64 - 1
24+
x = 2**64 - 1
2525
assert unpackb(packb(x)) == x
2626
with pytest.raises(PackOverflowError):
2727
packb(x + 1)
2828

2929

3030
def test_array_header():
3131
packer = Packer()
32-
packer.pack_array_header(2 ** 32 - 1)
32+
packer.pack_array_header(2**32 - 1)
3333
with pytest.raises(PackValueError):
34-
packer.pack_array_header(2 ** 32)
34+
packer.pack_array_header(2**32)
3535

3636

3737
def test_map_header():
3838
packer = Packer()
39-
packer.pack_map_header(2 ** 32 - 1)
39+
packer.pack_map_header(2**32 - 1)
4040
with pytest.raises(PackValueError):
41-
packer.pack_array_header(2 ** 32)
41+
packer.pack_array_header(2**32)
4242

4343

4444
def test_max_str_len():

0 commit comments

Comments
 (0)