Skip to content

Commit 423c6df

Browse files
authoredSep 5, 2023
move project metadata to pyproject.toml (#555)
also: replace flake8 by ruff.
1 parent 7b75b4f commit 423c6df

14 files changed

+57
-54
lines changed
 

‎docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
15-
1614
# If extensions (or modules to document with autodoc) are in another directory,
1715
# add these directories to sys.path here. If the directory is relative to the
1816
# documentation root, use os.path.abspath to make it absolute, like shown here.
17+
#import os
18+
#import sys
1919
#sys.path.insert(0, os.path.abspath('..'))
2020

2121
# -- General configuration -----------------------------------------------------

‎msgpack/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from .ext import ExtType, Timestamp
33

44
import os
5-
import sys
65

76

87
version = (1, 0, 5)

‎msgpack/ext.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections import namedtuple
22
import datetime
3-
import sys
43
import struct
54

65

@@ -20,8 +19,9 @@ def __new__(cls, code, data):
2019
class Timestamp:
2120
"""Timestamp represents the Timestamp extension type in msgpack.
2221
23-
When built with Cython, msgpack uses C methods to pack and unpack `Timestamp`. When using pure-Python
24-
msgpack, :func:`to_bytes` and :func:`from_bytes` are used to pack and unpack `Timestamp`.
22+
When built with Cython, msgpack uses C methods to pack and unpack `Timestamp`.
23+
When using pure-Python msgpack, :func:`to_bytes` and :func:`from_bytes` are used to pack and
24+
unpack `Timestamp`.
2525
2626
This class is immutable: Do not override seconds and nanoseconds.
2727
"""
@@ -39,7 +39,7 @@ def __init__(self, seconds, nanoseconds=0):
3939
Number of nanoseconds to add to `seconds` to get fractional time.
4040
Maximum is 999_999_999. Default is 0.
4141
42-
Note: Negative times (before the UNIX epoch) are represented as negative seconds + positive ns.
42+
Note: Negative times (before the UNIX epoch) are represented as neg. seconds + pos. ns.
4343
"""
4444
if not isinstance(seconds, int):
4545
raise TypeError("seconds must be an integer")

‎msgpack/fallback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def _unpack(self, execute=EX_CONSTRUCT):
530530
key = self._unpack(EX_CONSTRUCT)
531531
if self._strict_map_key and type(key) not in (str, bytes):
532532
raise ValueError("%s is not allowed for map key" % str(type(key)))
533-
if type(key) is str:
533+
if isinstance(key, str):
534534
key = sys.intern(key)
535535
ret[key] = self._unpack(EX_CONSTRUCT)
536536
if self._object_hook is not None:

‎pyproject.toml

+45
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,52 @@ requires = [
77
]
88
build-backend = "setuptools.build_meta"
99

10+
[project]
11+
name = "msgpack"
12+
dynamic = ["version"]
13+
license = {text="Apache 2.0"}
14+
authors = [{name="Inada Naoki", email="songofacandy@gmail.com"}]
15+
description = "MessagePack serializer"
16+
readme = "README.md"
17+
#keywords = ["python", "msgpack", "messagepack", "serializer", "serialization", "binary"]
18+
#requires-python = ">=3.8"
19+
classifiers = [
20+
# "Development Status :: 5 - Production/Stable",
21+
# "Operating System :: OS Independent",
22+
# "Programming Language :: Python",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: Implementation :: CPython",
30+
"Programming Language :: Python :: Implementation :: PyPy",
31+
"Intended Audience :: Developers",
32+
"License :: OSI Approved :: Apache Software License",
33+
]
34+
35+
[project.urls]
36+
Homepage = "https://msgpack.org/"
37+
Documentation = "https://msgpack-python.readthedocs.io/"
38+
Repository = "https://github.com/msgpack/msgpack-python/"
39+
Tracker = "https://github.com/msgpack/msgpack-python/issues"
40+
#Changelog = "https://github.com/msgpack/msgpack-python/blob/main/ChangeLog.rst"
41+
42+
[tool.setuptools.dynamic]
43+
version = {attr = "msgpack.__version__"}
44+
1045
[tool.black]
1146
line-length = 100
1247
target-version = ["py37"]
1348
skip_string_normalization = true
49+
50+
[tool.ruff]
51+
line-length = 100
52+
target-version = "py38"
53+
ignore = []
54+
55+
[tool.ruff.per-file-ignores]
56+
"msgpack/__init__.py" = ["F401", "F403"]
57+
"msgpack/fallback.py" = ["E731"]
58+
"test/test_seq.py" = ["E501"]

‎setup.cfg

-32
This file was deleted.

‎setup.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env python
2-
import io
32
import os
43
import sys
5-
from glob import glob
64
from setuptools import setup, Extension
75
from setuptools.command.build_ext import build_ext
86
from setuptools.command.sdist import sdist

‎test/test_buffer.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env python
22

3-
import sys
4-
import pytest
53
from msgpack import packb, unpackb
64

75

‎test/test_memoryview.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/usr/bin/env python
22

3-
import pytest
43
from array import array
54
from msgpack import packb, unpackb
6-
import sys
75

86

97
def make_array(f, data):

‎test/test_obj.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_decode_pairs_hook():
3333
prod_sum = 1 * 2 + 3 * 4
3434
unpacked = unpackb(
3535
packed,
36-
object_pairs_hook=lambda l: sum(k * v for k, v in l),
36+
object_pairs_hook=lambda lst: sum(k * v for k, v in lst),
3737
use_list=1,
3838
strict_map_key=False,
3939
)
@@ -48,7 +48,7 @@ def test_only_one_obj_hook():
4848
def test_bad_hook():
4949
with raises(TypeError):
5050
packed = packb([3, 1 + 2j], default=lambda o: o)
51-
unpacked = unpackb(packed, use_list=1)
51+
unpackb(packed, use_list=1)
5252

5353

5454
def _arr_to_str(arr):

‎test/test_pack.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
from collections import OrderedDict
44
from io import BytesIO
55
import struct
6-
import sys
76

87
import pytest
9-
from pytest import raises, xfail
108

11-
from msgpack import packb, unpackb, Unpacker, Packer, pack
9+
from msgpack import packb, unpackb, Unpacker, Packer
1210

1311

1412
def check(data, use_list=False):

‎test/test_seq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_exceeding_unpacker_read_size():
3434

3535
read_count = 0
3636
for idx, o in enumerate(unpacker):
37-
assert type(o) == bytes
37+
assert isinstance(o, bytes)
3838
assert o == gen_binary_data(idx)
3939
read_count += 1
4040

‎test/test_subtype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from msgpack import packb, unpackb
3+
from msgpack import packb
44
from collections import namedtuple
55

66

‎test/test_timestamp.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pytest
2-
import sys
32
import datetime
43
import msgpack
54
from msgpack.ext import Timestamp

0 commit comments

Comments
 (0)