Skip to content

Commit

Permalink
Use classmethod as a decorator (#481)
Browse files Browse the repository at this point in the history
Because it solves warning coming from linters and type checkers.
  • Loading branch information
ticosax authored Sep 27, 2021
1 parent c3be1f0 commit 449e4b2
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pulp/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ def add_expression(self, e):
self.expression = e
self.addVariableToConstraints(e)

@classmethod
def matrix(
self,
cls,
name,
indexs,
lowBound=None,
Expand Down Expand Up @@ -340,10 +341,9 @@ def matrix(
for i in index
]

matrix = classmethod(matrix)

@classmethod
def dicts(
self,
cls,
name,
indexs,
lowBound=None,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 449e4b2

Please sign in to comment.