move project metadata to pyproject.toml (#555)

also: replace flake8 by ruff.
This commit is contained in:
TW 2023-09-05 03:51:04 +02:00 committed by GitHub
parent 7b75b4f368
commit 423c6df265
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 57 additions and 54 deletions

View file

@ -11,11 +11,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#import os
#import sys
#sys.path.insert(0, os.path.abspath('..'))
# -- General configuration -----------------------------------------------------

View file

@ -2,7 +2,6 @@ from .exceptions import *
from .ext import ExtType, Timestamp
import os
import sys
version = (1, 0, 5)

View file

@ -1,6 +1,5 @@
from collections import namedtuple
import datetime
import sys
import struct
@ -20,8 +19,9 @@ class ExtType(namedtuple("ExtType", "code data")):
class Timestamp:
"""Timestamp represents the Timestamp extension type in msgpack.
When built with Cython, msgpack uses C methods to pack and unpack `Timestamp`. When using pure-Python
msgpack, :func:`to_bytes` and :func:`from_bytes` are used to pack and unpack `Timestamp`.
When built with Cython, msgpack uses C methods to pack and unpack `Timestamp`.
When using pure-Python msgpack, :func:`to_bytes` and :func:`from_bytes` are used to pack and
unpack `Timestamp`.
This class is immutable: Do not override seconds and nanoseconds.
"""
@ -39,7 +39,7 @@ class Timestamp:
Number of nanoseconds to add to `seconds` to get fractional time.
Maximum is 999_999_999. Default is 0.
Note: Negative times (before the UNIX epoch) are represented as negative seconds + positive ns.
Note: Negative times (before the UNIX epoch) are represented as neg. seconds + pos. ns.
"""
if not isinstance(seconds, int):
raise TypeError("seconds must be an integer")

View file

@ -530,7 +530,7 @@ class Unpacker:
key = self._unpack(EX_CONSTRUCT)
if self._strict_map_key and type(key) not in (str, bytes):
raise ValueError("%s is not allowed for map key" % str(type(key)))
if type(key) is str:
if isinstance(key, str):
key = sys.intern(key)
ret[key] = self._unpack(EX_CONSTRUCT)
if self._object_hook is not None:

View file

@ -7,7 +7,52 @@ requires = [
]
build-backend = "setuptools.build_meta"
[project]
name = "msgpack"
dynamic = ["version"]
license = {text="Apache 2.0"}
authors = [{name="Inada Naoki", email="songofacandy@gmail.com"}]
description = "MessagePack serializer"
readme = "README.md"
#keywords = ["python", "msgpack", "messagepack", "serializer", "serialization", "binary"]
#requires-python = ">=3.8"
classifiers = [
# "Development Status :: 5 - Production/Stable",
# "Operating System :: OS Independent",
# "Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
]
[project.urls]
Homepage = "https://msgpack.org/"
Documentation = "https://msgpack-python.readthedocs.io/"
Repository = "https://github.com/msgpack/msgpack-python/"
Tracker = "https://github.com/msgpack/msgpack-python/issues"
#Changelog = "https://github.com/msgpack/msgpack-python/blob/main/ChangeLog.rst"
[tool.setuptools.dynamic]
version = {attr = "msgpack.__version__"}
[tool.black]
line-length = 100
target-version = ["py37"]
skip_string_normalization = true
[tool.ruff]
line-length = 100
target-version = "py38"
ignore = []
[tool.ruff.per-file-ignores]
"msgpack/__init__.py" = ["F401", "F403"]
"msgpack/fallback.py" = ["E731"]
"test/test_seq.py" = ["E501"]

View file

@ -1,32 +0,0 @@
[metadata]
name = msgpack
version = attr: msgpack.__version__
#version = attr: msgpack.version
license = Apache 2.0
author = Inada Naoki
author_email = songofacandy@gmail.com
description = MessagePack serializer
long_description = file: README.md
long_description_content_type = text/markdown
url = https://msgpack.org/
project_urls =
Documentation = https://msgpack-python.readthedocs.io/
Source = https://github.com/msgpack/msgpack-python
Tracker = https://github.com/msgpack/msgpack-python/issues
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
[flake8]
max_line_length = 100

View file

@ -1,8 +1,6 @@
#!/usr/bin/env python
import io
import os
import sys
from glob import glob
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python
import sys
import pytest
from msgpack import packb, unpackb

View file

@ -1,9 +1,7 @@
#!/usr/bin/env python
import pytest
from array import array
from msgpack import packb, unpackb
import sys
def make_array(f, data):

View file

@ -33,7 +33,7 @@ def test_decode_pairs_hook():
prod_sum = 1 * 2 + 3 * 4
unpacked = unpackb(
packed,
object_pairs_hook=lambda l: sum(k * v for k, v in l),
object_pairs_hook=lambda lst: sum(k * v for k, v in lst),
use_list=1,
strict_map_key=False,
)
@ -48,7 +48,7 @@ def test_only_one_obj_hook():
def test_bad_hook():
with raises(TypeError):
packed = packb([3, 1 + 2j], default=lambda o: o)
unpacked = unpackb(packed, use_list=1)
unpackb(packed, use_list=1)
def _arr_to_str(arr):

View file

@ -3,12 +3,10 @@
from collections import OrderedDict
from io import BytesIO
import struct
import sys
import pytest
from pytest import raises, xfail
from msgpack import packb, unpackb, Unpacker, Packer, pack
from msgpack import packb, unpackb, Unpacker, Packer
def check(data, use_list=False):

View file

@ -34,7 +34,7 @@ def test_exceeding_unpacker_read_size():
read_count = 0
for idx, o in enumerate(unpacker):
assert type(o) == bytes
assert isinstance(o, bytes)
assert o == gen_binary_data(idx)
read_count += 1

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python
from msgpack import packb, unpackb
from msgpack import packb
from collections import namedtuple

View file

@ -1,5 +1,4 @@
import pytest
import sys
import datetime
import msgpack
from msgpack.ext import Timestamp