Skip to content

Commit

Permalink
move project metadata to pyproject.toml (#555)
Browse files Browse the repository at this point in the history
also: replace flake8 by ruff.
  • Loading branch information
ThomasWaldmann authored Sep 5, 2023
1 parent 7b75b4f commit 423c6df
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 54 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion msgpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .ext import ExtType, Timestamp

import os
import sys


version = (1, 0, 5)
Expand Down
8 changes: 4 additions & 4 deletions msgpack/ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import namedtuple
import datetime
import sys
import struct


Expand All @@ -20,8 +19,9 @@ def __new__(cls, 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.
"""
Expand All @@ -39,7 +39,7 @@ def __init__(self, seconds, nanoseconds=0):
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")
Expand Down
2 changes: 1 addition & 1 deletion msgpack/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def _unpack(self, execute=EX_CONSTRUCT):
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:
Expand Down
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]"}]
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"]
32 changes: 0 additions & 32 deletions setup.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/test_buffer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python

import sys
import pytest
from msgpack import packb, unpackb


Expand Down
2 changes: 0 additions & 2 deletions test/test_memoryview.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions test/test_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions test/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion test/test_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/test_subtype.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

from msgpack import packb, unpackb
from msgpack import packb
from collections import namedtuple


Expand Down
1 change: 0 additions & 1 deletion test/test_timestamp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import sys
import datetime
import msgpack
from msgpack.ext import Timestamp
Expand Down

0 comments on commit 423c6df

Please sign in to comment.