Re: Unneeded object inheritance
Claude Paroz <[email protected]> Fri, 4 Feb 2022 21:45:41 +0100
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <[email protected]> |
Le 04.02.22 à 14:42, Claude Paroz a écrit : > Hi, > > Here's a new cleaning patch that remove (object) inheritances, which was > needed on Python 2, but no more useful in Python 3. I found one more. New patch. Claude -- www.2xlibre.net
0001-Removed-unneeded-object-inheritance.patch
(text/x-patch, 6.4 KB)
From 2c4e1a571678463d99f468edc7c09742b225aa70 Mon Sep 17 00:00:00 2001 From: Claude Paroz <[email protected]> Date: Mon, 27 Dec 2021 18:32:42 +0100 Subject: [PATCH] Removed unneeded object inheritance --- src/reportlab/graphics/barcode/common.py | 2 +- src/reportlab/graphics/barcode/dmtx.py | 2 +- src/reportlab/graphics/barcode/qrencoder.py | 2 +- src/reportlab/graphics/charts/utils.py | 2 +- src/reportlab/lib/rl_safe_eval.py | 8 ++++---- src/reportlab/lib/utils.py | 6 +++--- src/reportlab/pdfbase/pdfdoc.py | 2 +- src/reportlab/pdfbase/pdfpattern.py | 2 +- tests/test_lib_rl_safe_eval.py | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/reportlab/graphics/barcode/common.py b/src/reportlab/graphics/barcode/common.py index 596b88dc..91bdfc52 100644 --- a/src/reportlab/graphics/barcode/common.py +++ b/src/reportlab/graphics/barcode/common.py @@ -35,7 +35,7 @@ from reportlab.lib.units import inch from reportlab.lib.utils import ascii_uppercase, ascii_lowercase from string import digits as string_digits -class Barcode(Flowable,object): +class Barcode(Flowable): """Abstract Base for barcodes. Includes implementations of some methods suitable for the more primitive barcode types""" diff --git a/src/reportlab/graphics/barcode/dmtx.py b/src/reportlab/graphics/barcode/dmtx.py index 6bda8627..bc155d25 100644 --- a/src/reportlab/graphics/barcode/dmtx.py +++ b/src/reportlab/graphics/barcode/dmtx.py @@ -18,7 +18,7 @@ from reportlab.graphics.shapes import Group, Rect def _numConv(x): return x if isinstance(x,(int,float)) else paraparser_num(x) -class _DMTXCheck(object): +class _DMTXCheck: @classmethod def pylibdmtx_check(cls): if not pylibdmtx: diff --git a/src/reportlab/graphics/barcode/qrencoder.py b/src/reportlab/graphics/barcode/qrencoder.py index 3417dfbc..a9cfeb8c 100644 --- a/src/reportlab/graphics/barcode/qrencoder.py +++ b/src/reportlab/graphics/barcode/qrencoder.py @@ -587,7 +587,7 @@ class QRMaskPattern: PATTERN110 = 6 PATTERN111 = 7 -class QRUtil(object): +class QRUtil: PATTERN_POSITION_TABLE = [ [], [6, 18], diff --git a/src/reportlab/graphics/charts/utils.py b/src/reportlab/graphics/charts/utils.py index fe87dea9..8492ba9a 100644 --- a/src/reportlab/graphics/charts/utils.py +++ b/src/reportlab/graphics/charts/utils.py @@ -212,7 +212,7 @@ def maverage(data,n=6): def pairMaverage(data,n=6): return [(x[0],s) for x,s in zip(data, maverage([x[1] for x in data],n))] -class DrawTimeCollector(object): +class DrawTimeCollector: ''' generic mechanism for collecting information about nodes at the time they are about to be drawn ''' diff --git a/src/reportlab/lib/rl_safe_eval.py b/src/reportlab/lib/rl_safe_eval.py index af8928e1..08880ac1 100644 --- a/src/reportlab/lib/rl_safe_eval.py +++ b/src/reportlab/lib/rl_safe_eval.py @@ -839,7 +839,7 @@ class UntrustedAstTransformer(ast.NodeTransformer): def astFormat(node): return ast.dump(copy.deepcopy(node),annotate_fields=True, include_attributes=True,indent=4) -class __rl_SafeIter__(object): +class __rl_SafeIter__: def __init__(self, it, owner): self.__rl_iter__ = owner().__rl_real_iter__(it) self.__rl_owner__ = owner @@ -865,7 +865,7 @@ def safer_globals(g=None): math_log10 = math.log10 __rl_undef__ = object() -class __RL_SAFE_ENV__(object): +class __RL_SAFE_ENV__: __time_time__ = time.time __weakref_ref__ = weakref.ref __slicetype__ = type(slice(0)) @@ -889,7 +889,7 @@ class __RL_SAFE_ENV__(object): args = (self.__rl_getiter__(it),) return dict.__new__(cls,*args,**kwds) - class __rl_missing_func__(object): + class __rl_missing_func__: def __init__(self,name): self.__name__ = name def __call__(self,*args,**kwds): @@ -1205,7 +1205,7 @@ class __RL_SAFE_ENV__(object): if obi: G['__builtins__'] = obi[0] -class __rl_safe_eval__(object): +class __rl_safe_eval__: '''creates one environment and re-uses it''' mode = 'eval' def __init__(self): diff --git a/src/reportlab/lib/utils.py b/src/reportlab/lib/utils.py index 96be9ca4..27555349 100644 --- a/src/reportlab/lib/utils.py +++ b/src/reportlab/lib/utils.py @@ -15,7 +15,7 @@ from reportlab.lib.logger import warnOnce from reportlab.lib.rltempfile import get_rl_tempfile, get_rl_tempdir, _rl_getuid from . rl_safe_eval import rl_safe_exec, rl_safe_eval, safer_globals -class __UNSET__(object): +class __UNSET__: @staticmethod def __bool__(): return False @@ -668,7 +668,7 @@ def _isPILImage(im): except AttributeError: return 0 -class ImageReader(object): +class ImageReader: "Wraps up either PIL or Java to get data from bitmaps" _cache={} _max_image_size = None @@ -1368,7 +1368,7 @@ class FixedOffsetTZ(datetime.tzinfo): def dst(self, dt): return datetime.timedelta(0) -class TimeStamp(object): +class TimeStamp: def __init__(self,invariant=None): if invariant is None: from reportlab.rl_config import invariant diff --git a/src/reportlab/pdfbase/pdfdoc.py b/src/reportlab/pdfbase/pdfdoc.py index 91827d55..82bb3a17 100755 --- a/src/reportlab/pdfbase/pdfdoc.py +++ b/src/reportlab/pdfbase/pdfdoc.py @@ -109,7 +109,7 @@ class NoEncryption: # the representation of self in file if any (should be None or PDFDict) return None -class PDFObject(object): +class PDFObject: pass class DummyDoc(PDFObject): diff --git a/src/reportlab/pdfbase/pdfpattern.py b/src/reportlab/pdfbase/pdfpattern.py index 774ff334..4cc0898f 100644 --- a/src/reportlab/pdfbase/pdfpattern.py +++ b/src/reportlab/pdfbase/pdfpattern.py @@ -78,7 +78,7 @@ class PDFPattern(PDFObject): c.arguments = self.arguments return c -class PDFPatternIf(object): +class PDFPatternIf: '''cond will be evaluated as [cond] in PDFpattern eval. It should evaluate to a list with value 0/1 etc etc. thenPart is a list to be evaluated if the cond evaulates true, diff --git a/tests/test_lib_rl_safe_eval.py b/tests/test_lib_rl_safe_eval.py index a2ca89d9..84bd86f5 100644 --- a/tests/test_lib_rl_safe_eval.py +++ b/tests/test_lib_rl_safe_eval.py @@ -14,7 +14,7 @@ from reportlab.lib.utils import rl_safe_eval, rl_safe_exec, annotateException from reportlab.lib.rl_safe_eval import BadCode testObj = [1,('a','b',2),{'A':1,'B':2.0},"32"] -class TestClass(object): +class TestClass: a = 1 format = 3 testInst = TestClass() -- 2.30.2