From 449e4b2950367f1d21d38a6afb07baf0dbc18f17 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby Date: Mon, 27 Sep 2021 14:43:05 +0200 Subject: [PATCH] Use classmethod as a decorator (#481) Because it solves warning coming from linters and type checkers. --- pulp/pulp.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pulp/pulp.py b/pulp/pulp.py index 76d8d327..6cf0dd79 100644 --- a/pulp/pulp.py +++ b/pulp/pulp.py @@ -311,8 +311,9 @@ def add_expression(self, e): self.expression = e self.addVariableToConstraints(e) + @classmethod def matrix( - self, + cls, name, indexs, lowBound=None, @@ -340,10 +341,9 @@ def matrix( for i in index ] - matrix = classmethod(matrix) - + @classmethod def dicts( - self, + cls, name, indexs, lowBound=None, @@ -386,9 +386,8 @@ def dicts( ) return d - dicts = classmethod(dicts) - - def dict(self, name, indexs, lowBound=None, upBound=None, cat=const.LpContinuous): + @classmethod + def dict(cls, name, indexs, lowBound=None, upBound=None, cat=const.LpContinuous): if not isinstance(indexs, tuple): indexs = (indexs,) if "%" not in name: @@ -420,11 +419,9 @@ def dict(self, name, indexs, lowBound=None, upBound=None, cat=const.LpContinuous d = {} for i in index: - d[i] = self(name % i, lowBound, upBound, cat) + d[i] = cls(name % i, lowBound, upBound, cat) return d - dict = classmethod(dict) - def getLb(self): return self.lowBound