From 3d9ce64bd89ea023b2654cbdd7e5740fa804a98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 24 Sep 2024 13:01:12 +0000 Subject: [PATCH 1/4] drop python<=3.7 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023. Filter all code over `pyupgracde --py38-plus`. Signed-off-by: Tomasz Kłoczko --- docs/conf.py | 15 +++++++-------- tests/test_bitstruct.py | 17 +++++++---------- tests/test_c.py | 27 ++++++++++----------------- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index bd06f9c..2d8f528 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # bitstruct documentation build configuration file, created by # sphinx-quickstart on Sat Apr 25 11:54:09 2015. @@ -51,9 +50,9 @@ master_doc = 'index' # General information about the project. -project = u'bitstruct' -copyright = u'2015-2019, Erik Moqvist' -author = u'Erik Moqvist' +project = 'bitstruct' +copyright = '2015-2019, Erik Moqvist' +author = 'Erik Moqvist' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -227,8 +226,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'bitstruct.tex', u'bitstruct Documentation', - u'Erik Moqvist', 'manual'), + (master_doc, 'bitstruct.tex', 'bitstruct Documentation', + 'Erik Moqvist', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -257,7 +256,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'bitstruct', u'bitstruct Documentation', + (master_doc, 'bitstruct', 'bitstruct Documentation', [author], 1) ] @@ -271,7 +270,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'bitstruct', u'bitstruct Documentation', + (master_doc, 'bitstruct', 'bitstruct Documentation', author, 'bitstruct', 'One line description of project.', 'Miscellaneous'), ] diff --git a/tests/test_bitstruct.py b/tests/test_bitstruct.py index 9504488..b77f5e6 100644 --- a/tests/test_bitstruct.py +++ b/tests/test_bitstruct.py @@ -1,4 +1,3 @@ -from __future__ import print_function import sys import timeit import unittest @@ -57,7 +56,7 @@ def test_pack(self): packed = pack('u5b2u1', 31, False, 1) self.assertEqual(packed, b'\xf9') - packed = pack('b1t24', False, u'Hi!') + packed = pack('b1t24', False, 'Hi!') self.assertEqual(packed, b'$4\x90\x80') packed = pack('b1t24', False, 'Hi!') @@ -66,9 +65,8 @@ def test_pack(self): packed = pack('t8000', 1000 * '7') self.assertEqual(packed, 1000 * b'\x37') - if sys.version_info >= (3, 6): - packed = pack('f16', 1.0) - self.assertEqual(packed, b'\x3c\x00') + packed = pack('f16', 1.0) + self.assertEqual(packed, b'\x3c\x00') packed = pack('f32', 1.0) self.assertEqual(packed, b'\x3f\x80\x00\x00') @@ -179,7 +177,7 @@ def test_unpack(self): packed = b'$4\x90\x80' unpacked = unpack('b1t24', packed) - self.assertEqual(unpacked, (False, u'Hi!')) + self.assertEqual(unpacked, (False, 'Hi!')) packed = 1000 * b'7' unpacked = unpack('t8000', packed) @@ -236,10 +234,9 @@ def test_pack_unpack(self): unpacked = unpack('f64', packed) self.assertEqual(unpacked, (1.0, )) - if sys.version_info >= (3, 6): - packed = pack('f16', 1.0) - unpacked = unpack('f16', packed) - self.assertEqual(unpacked, (1.0, )) + packed = pack('f16', 1.0) + unpacked = unpack('f16', packed) + self.assertEqual(unpacked, (1.0, )) def test_calcsize(self): """Calculate size. diff --git a/tests/test_c.py b/tests/test_c.py index e72bf3b..ac6d0a1 100644 --- a/tests/test_c.py +++ b/tests/test_c.py @@ -1,4 +1,3 @@ -from __future__ import print_function import sys import timeit import pickle @@ -83,7 +82,7 @@ def test_pack(self): packed = pack('u5b2u1', 31, False, 1) self.assertEqual(packed, b'\xf9') - packed = pack('b1t24', False, u'Hi!') + packed = pack('b1t24', False, 'Hi!') self.assertEqual(packed, b'$4\x90\x80') packed = pack('b1t24', False, 'Hi!') @@ -92,9 +91,8 @@ def test_pack(self): packed = pack('t8000', 1000 * '7') self.assertEqual(packed, 1000 * b'\x37') - if sys.version_info >= (3, 6): - packed = pack('f16', 1.0) - self.assertEqual(packed, b'\x3c\x00') + packed = pack('f16', 1.0) + self.assertEqual(packed, b'\x3c\x00') packed = pack('f32', 1.0) self.assertEqual(packed, b'\x3f\x80\x00\x00') @@ -176,15 +174,14 @@ def test_unpack(self): packed = b'$4\x90\x80' unpacked = unpack('b1t24', packed) - self.assertEqual(unpacked, (False, u'Hi!')) + self.assertEqual(unpacked, (False, 'Hi!')) packed = 1000 * b'7' unpacked = unpack('t8000', packed) self.assertEqual(packed, 1000 * b'\x37') - if sys.version_info >= (3, 6): - unpacked = unpack('f16', b'\x3c\x00') - self.assertEqual(unpacked, (1.0, )) + unpacked = unpack('f16', b'\x3c\x00') + self.assertEqual(unpacked, (1.0, )) unpacked = unpack('f32', b'\x3f\x80\x00\x00') self.assertEqual(unpacked, (1.0, )) @@ -225,10 +222,9 @@ def test_pack_unpack(self): unpacked = unpack('f64', packed) self.assertEqual(unpacked, (1.0, )) - if sys.version_info >= (3, 6): - packed = pack('f16', 1.0) - unpacked = unpack('f16', packed) - self.assertEqual(unpacked, (1.0, )) + packed = pack('f16', 1.0) + unpacked = unpack('f16', packed) + self.assertEqual(unpacked, (1.0, )) def test_calcsize(self): """Calculate size. @@ -618,10 +614,7 @@ def test_various(self): with self.assertRaises(NotImplementedError) as cm: pack('f1', 1.0) - if sys.version_info >= (3, 6): - self.assertEqual(str(cm.exception), 'Float not 16, 32 or 64 bits.') - else: - self.assertEqual(str(cm.exception), 'Float not 32 or 64 bits.') + self.assertEqual(str(cm.exception), 'Float not 16, 32 or 64 bits.') # Long bool. with self.assertRaises(NotImplementedError) as cm: From 1e242573ac4442b8c5204cacec734d9d7761aebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 24 Sep 2024 13:02:33 +0000 Subject: [PATCH 2/4] update requires-python to ">=3.8" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 964835c..8d3ed67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ description = """This module performs conversions between Python values \ and C bit field structs represented as Python \ byte strings.""" readme = "README.rst" -requires-python = ">=3.7" +requires-python = ">=3.8" license = { text = "MIT" } keywords = [ "bit field", From 89f1df0d8e0c7a8a667ca9ab0c24a3f24c8eb32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 24 Sep 2024 13:03:13 +0000 Subject: [PATCH 3/4] filter all code over ruff to drop unused impots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- tests/test_bitstruct.py | 1 - tests/test_c.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/test_bitstruct.py b/tests/test_bitstruct.py index b77f5e6..6dbf9c8 100644 --- a/tests/test_bitstruct.py +++ b/tests/test_bitstruct.py @@ -1,5 +1,4 @@ import sys -import timeit import unittest from bitstruct import * import bitstruct diff --git a/tests/test_c.py b/tests/test_c.py index ac6d0a1..c8ee5c9 100644 --- a/tests/test_c.py +++ b/tests/test_c.py @@ -1,5 +1,4 @@ import sys -import timeit import pickle import unittest import platform From fc770dbc067cc72d667a1c8c6a331c288486c5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 24 Sep 2024 13:04:05 +0000 Subject: [PATCH 4/4] update module path in source tree to `../src` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 2d8f528..822245d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ # 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. -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath("../src")) import bitstruct