mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-13 19:04:16 +00:00
Update setuptools and black (#498)
* Use setuptools * Use black==22.1.0
This commit is contained in:
parent
89ea57747e
commit
cb50b2081b
13 changed files with 83 additions and 84 deletions
|
|
@ -1,5 +1,4 @@
|
|||
# coding: utf-8
|
||||
from ._version import version
|
||||
from .exceptions import *
|
||||
from .ext import ExtType, Timestamp
|
||||
|
||||
|
|
@ -7,6 +6,10 @@ import os
|
|||
import sys
|
||||
|
||||
|
||||
version = (1, 0, 4, 'dev')
|
||||
__version__ = "1.0.4dev"
|
||||
|
||||
|
||||
if os.environ.get("MSGPACK_PUREPYTHON") or sys.version_info[0] == 2:
|
||||
from .fallback import Packer, unpackb, Unpacker
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
version = (1, 0, 3)
|
||||
|
|
@ -59,7 +59,7 @@ class Timestamp(object):
|
|||
raise TypeError("seconds must be an interger")
|
||||
if not isinstance(nanoseconds, int_types):
|
||||
raise TypeError("nanoseconds must be an integer")
|
||||
if not (0 <= nanoseconds < 10 ** 9):
|
||||
if not (0 <= nanoseconds < 10**9):
|
||||
raise ValueError(
|
||||
"nanoseconds must be a non-negative integer less than 999999999."
|
||||
)
|
||||
|
|
@ -143,7 +143,7 @@ class Timestamp(object):
|
|||
:type unix_float: int or float.
|
||||
"""
|
||||
seconds = int(unix_sec // 1)
|
||||
nanoseconds = int((unix_sec % 1) * 10 ** 9)
|
||||
nanoseconds = int((unix_sec % 1) * 10**9)
|
||||
return Timestamp(seconds, nanoseconds)
|
||||
|
||||
def to_unix(self):
|
||||
|
|
@ -161,7 +161,7 @@ class Timestamp(object):
|
|||
:param int unix_ns: Posix timestamp in nanoseconds.
|
||||
:rtype: Timestamp
|
||||
"""
|
||||
return Timestamp(*divmod(unix_ns, 10 ** 9))
|
||||
return Timestamp(*divmod(unix_ns, 10**9))
|
||||
|
||||
def to_unix_nano(self):
|
||||
"""Get the timestamp as a unixtime in nanoseconds.
|
||||
|
|
@ -169,7 +169,7 @@ class Timestamp(object):
|
|||
:returns: posix timestamp in nanoseconds
|
||||
:rtype: int
|
||||
"""
|
||||
return self.seconds * 10 ** 9 + self.nanoseconds
|
||||
return self.seconds * 10**9 + self.nanoseconds
|
||||
|
||||
def to_datetime(self):
|
||||
"""Get the timestamp as a UTC datetime.
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ class Unpacker(object):
|
|||
self._buf_checkpoint = 0
|
||||
|
||||
if not max_buffer_size:
|
||||
max_buffer_size = 2 ** 31 - 1
|
||||
max_buffer_size = 2**31 - 1
|
||||
if max_str_len == -1:
|
||||
max_str_len = max_buffer_size
|
||||
if max_bin_len == -1:
|
||||
|
|
@ -800,20 +800,20 @@ class Packer(object):
|
|||
raise OverflowError("Integer value out of range")
|
||||
if check(obj, (bytes, bytearray)):
|
||||
n = len(obj)
|
||||
if n >= 2 ** 32:
|
||||
if n >= 2**32:
|
||||
raise ValueError("%s is too large" % type(obj).__name__)
|
||||
self._pack_bin_header(n)
|
||||
return self._buffer.write(obj)
|
||||
if check(obj, unicode):
|
||||
obj = obj.encode("utf-8", self._unicode_errors)
|
||||
n = len(obj)
|
||||
if n >= 2 ** 32:
|
||||
if n >= 2**32:
|
||||
raise ValueError("String is too large")
|
||||
self._pack_raw_header(n)
|
||||
return self._buffer.write(obj)
|
||||
if check(obj, memoryview):
|
||||
n = len(obj) * obj.itemsize
|
||||
if n >= 2 ** 32:
|
||||
if n >= 2**32:
|
||||
raise ValueError("Memoryview is too large")
|
||||
self._pack_bin_header(n)
|
||||
return self._buffer.write(obj)
|
||||
|
|
@ -895,7 +895,7 @@ class Packer(object):
|
|||
return ret
|
||||
|
||||
def pack_array_header(self, n):
|
||||
if n >= 2 ** 32:
|
||||
if n >= 2**32:
|
||||
raise ValueError
|
||||
self._pack_array_header(n)
|
||||
if self._autoreset:
|
||||
|
|
@ -904,7 +904,7 @@ class Packer(object):
|
|||
return ret
|
||||
|
||||
def pack_map_header(self, n):
|
||||
if n >= 2 ** 32:
|
||||
if n >= 2**32:
|
||||
raise ValueError
|
||||
self._pack_map_header(n)
|
||||
if self._autoreset:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue