Commit c69815a9 authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald
Browse files

pylint: fix inconsistent return statetements

parent dc88167b
......@@ -91,6 +91,7 @@ class Animation(QPropertyAnimation, StrMixin):
return '%d' % value
if pName == 'scale':
return '%.2f' % value
return 'formatValue: unexpected {}={}'.format(pName, value)
def __str__(self):
"""for debug messages"""
......@@ -262,7 +263,6 @@ class ParallelAnimationGroup(QParallelAnimationGroup, StrMixin):
graphicsObject.clearActiveAnimation(animation)
if Internal.scene:
Internal.scene.focusRect.refresh()
return
def stateName(self, state=None):
"""for debug output"""
......@@ -276,6 +276,7 @@ class ParallelAnimationGroup(QParallelAnimationGroup, StrMixin):
return 'running'
else:
assert False
return None
def __str__(self):
"""for debugging"""
......@@ -325,6 +326,7 @@ class AnimatedMixin:
for item in reversed(self.queuedAnimations):
if item.pName() == propertyName:
return item
return None
def shortcutAnimation(self, animation):
"""directly set the end value of the animation"""
......
......@@ -389,6 +389,7 @@ class Board(QGraphicsRectItem, StrMixin):
for uiTile in self.uiTiles:
if (uiTile.xoffset, uiTile.yoffset, uiTile.level) == (xoffset, yoffset, level):
return uiTile
return None
def tilesByElement(self, element):
"""return all child items holding a uiTile for element"""
......@@ -856,7 +857,7 @@ class FittingView(QGraphicsView):
self.dragObject = self.drag(tilePressed)
self.dragObject.exec_(Qt.MoveAction)
self.dragObject = None
return
return None
return QGraphicsView.mouseMoveEvent(self, event)
def drag(self, uiTile):
......
......@@ -36,7 +36,7 @@ class ChatModel(QAbstractTableModel):
if orientation != Qt.Horizontal:
return int(section + 1)
if role != Qt.DisplayRole:
return
return None
result = ''
if section < self.columnCount():
result = [i18n('Time'), i18n('Player'), i18n('Message')][section]
......
......@@ -137,6 +137,7 @@ class Client(pb.Referenceable):
"""hide weakref"""
if self._table:
return self._table()
return None
@table.setter
def table(self, value):
......@@ -162,6 +163,7 @@ class Client(pb.Referenceable):
for table in self.tables:
if table.tableid == tableid:
return table
return None
def logout(self, unusedResult=None): # pylint: disable=no-self-use
"""virtual"""
......@@ -230,6 +232,7 @@ class Client(pb.Referenceable):
for key, value in module.__dict__.items():
if key == 'AI' + aiName:
return value
return None
def __assignIntelligence(self):
"""assign intelligence to myself. All players already have default intelligence."""
......@@ -452,6 +455,7 @@ class Client(pb.Referenceable):
# even here we ask: if our discard is claimed we need time
# to notice - think 3 robots or network timing differences
return self.ask(move, [Message.OK])
return None
def myAction(self, move):
"""ask myself what I want to do after picking or claiming a tile"""
......
......@@ -200,7 +200,7 @@ Options {stropt} take a string argument like {example}.
"""args comes from the command line. Put this in the Debug class.
If something goes wrong, return an error message."""
if not args:
return
return None
Debug.argString = args
for arg in args.split(','):
parts = arg.split(':')
......@@ -220,6 +220,7 @@ Options {stropt} take a string argument like {example}.
type.__setattr__(Debug, option, value)
if Debug.time:
Debug.time = datetime.datetime.now()
return None
@staticmethod
def str():
......
......@@ -39,26 +39,22 @@ class Request(StrMixin):
@property
def block(self):
"""hide weakref"""
if self._block:
return self._block()
return self._block() if self._block else None
@property
def user(self):
"""hide weakref"""
if self._user:
return self._user()
return self._user() if self._user else None
@property
def about(self):
"""hide weakref"""
if self._about:
return self._about()
return self._about() if self._about else None
@property
def player(self):
"""hide weakref"""
if self._player:
return self._player()
return self._player() if self._player else None
def gotAnswer(self, rawAnswer):
"""convert the wired answer into something more useful"""
......@@ -352,6 +348,7 @@ class DeferredBlock(StrMixin):
for player in self.table.game.players:
if user.name == player.name:
return player
return None
@staticmethod
def __enrichMessage(game, about, command, kwargs):
......
......@@ -128,7 +128,7 @@ class DeferredDialog(Deferred):
def __execute(self):
"""now do the actual action"""
if self.dlg is None:
return
return None
scene = Internal.scene
if not Options.gui or not isAlive(self.dlg):
return self.clicked()
......@@ -142,6 +142,7 @@ class DeferredDialog(Deferred):
Internal.reactor.callLater(
Internal.Preferences.animationDuration() / 500.0,
self.clicked)
return None
def clicked(self, button=None):
"""we got a reaction"""
......
......@@ -42,15 +42,16 @@ class DifferModel(QAbstractTableModel):
def data(self, index, role=Qt.DisplayRole):
"""get from model"""
if not index.isValid():
return
return None
if not 0 <= index.row() < len(self.diffs):
return
return None
diff = self.diffs[index.row()]
column = index.column()
if role == Qt.DisplayRole:
return diff[column]
elif role == Qt.TextAlignmentRole:
return int(Qt.AlignLeft | Qt.AlignVCenter)
return None
def headerData(self, section, orientation, role):
"""tell the view about the wanted headers"""
......@@ -58,7 +59,7 @@ class DifferModel(QAbstractTableModel):
if orientation == Qt.Horizontal:
return int(Qt.AlignLeft | Qt.AlignVCenter)
if role != Qt.DisplayRole:
return
return None
if orientation == Qt.Horizontal:
if section == 0:
return i18nc('Kajongg', 'Rule')
......@@ -66,6 +67,7 @@ class DifferModel(QAbstractTableModel):
return i18n(self.view.cbRuleset1.current.name)
if section == 2:
return i18n(self.view.cbRuleset2.current.name)
return None
class RulesetDiffer(QDialog):
......
......@@ -113,6 +113,7 @@ class HandId(StrMixin):
logWarning('you want %s, changed to z' % char)
char = 'z'
self.notRotated = self.notRotated * 26 + ord(char) - ord('a') + 1
return
def prompt(self, withSeed=True, withAI=True, withMoveCount=False):
"""
......@@ -268,8 +269,7 @@ class Game:
@property
def client(self):
"""hide weakref"""
if self._client:
return self._client()
return self._client() if self._client else None
@client.setter
def client(self, value):
......@@ -358,6 +358,7 @@ class Game:
if myPlayer.name == playerName:
return myPlayer
logException('Move references unknown player %s' % playerName)
return None
def losers(self):
"""the 3 or 4 losers: All players without the winner"""
......@@ -708,6 +709,7 @@ class Game:
elif self.ruleset:
# while initialising Game, ruleset might be None
return self.roundsFinished >= self.ruleset.minRounds
return None
def __payHand(self):
"""pay the scores"""
......
......@@ -66,7 +66,7 @@ class GamesModel(QAbstractTableModel):
if role is None:
role = Qt.DisplayRole
if not (index.isValid() and role == Qt.DisplayRole):
return
return None
if role == Qt.DisplayRole:
unformatted = str(
self._resultRows[index.row()][index.column()]) # TODO: brauche ich str?
......@@ -88,6 +88,7 @@ class GamesModel(QAbstractTableModel):
# pylint: disable=no-self-use
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return i18n('Players') if section == 2 else i18n('Started')
return None
class Games(QDialog):
......
......@@ -556,6 +556,7 @@ class Hand(StrMixin):
self.debug(fmt('{callers} Found {matchingMJRules}',
callers=callers()))
return result
return None
def __arrangements(self):
"""find all legal arrangements.
......
......@@ -105,8 +105,7 @@ class HandBoard(Board):
@property
def player(self):
"""player is readonly and never None"""
if self._player:
return self._player()
return self._player() if self._player else None
# this is ordered such that pylint does not complain about
# identical code in board.py
......@@ -158,6 +157,7 @@ class HandBoard(Board):
def newLowerMelds(self):
"""a list of melds for the hand as it should look after sync"""
return []
def newTilePositions(self):
"""return list(TileAttr) for all tiles except bonus tiles.
......
......@@ -564,6 +564,7 @@ class HumanClient(Client):
if game:
self.game = None
return game.close()
return None
if self.beginQuestion:
self.beginQuestion.cancel()
Sorry(i18n('Player %1 has left the table', name)).addCallback(
......@@ -639,11 +640,10 @@ class HumanClient(Client):
"""playerNames are in wind order ESWN. Never called for first hand."""
def answered(unused=None):
"""called after the client player said yes, I am ready"""
if self.connection:
return Client.readyForHandStart(self, playerNames, rotateWinds)
return Client.readyForHandStart(self, playerNames, rotateWinds) if self.connection else None
if not self.connection:
# disconnected meanwhile
return
return None
if Options.gui:
# update the balances in the status bar:
Internal.mainWindow.updateGUI()
......@@ -901,8 +901,7 @@ class HumanClient(Client):
def callServerError(result):
"""if serverDisconnected has been called meanwhile, just ignore msg about
connection lost in a non-clean fashion"""
if self.connection:
return result
return result if self.connection else None
return self.connection.perspective.callRemote(*args).addErrback(callServerError)
except pb.DeadReferenceError:
logWarning(
......
......@@ -30,8 +30,7 @@ class AIDefaultAI:
@property
def player(self):
"""hide weakref"""
if self._player:
return self._player()
return self._player() if self._player else None
def name(self):
"""return our name"""
......@@ -275,12 +274,14 @@ class AIDefaultAI:
break
if not belongsToPair:
return chow
return None
def selectKong(self, kongs):
"""selects a kong to be declared. Having more than one undeclared kong is quite improbable"""
for kong in kongs:
if not self.player.mustPlayDangerous(kong):
return kong
return None
def handValue(self, hand):
"""compute the value of a hand.
......@@ -388,14 +389,12 @@ class DiscardCandidates(list):
@property
def player(self):
"""hide weakref"""
if self._player:
return self._player()
return self._player() if self._player else None
@property
def hand(self):
"""hide weakref"""
if self._hand:
return self._hand()
return self._hand() if self._hand else None
def link(self):
"""define values for candidate.prev and candidate.next"""
......
......@@ -184,6 +184,7 @@ class CsvRow(StrMixin):
_ = '{} {}'.format(cause.name, self.data(cause))
same.append(_)
return ', '.join(differing), ', '.join(same)
return None
def neutralize(self):
"""for comparisons"""
......
......@@ -301,6 +301,7 @@ class Job(StrMixin):
for prefix in range(100):
if sum(x.startswith(self.ruleset[:prefix]) for x in names) == 1:
return self.ruleset[prefix - 1:]
return None
def __str__(self):
pid = 'pid={}'.format(
......
......@@ -559,6 +559,7 @@ class KConfigGroup:
return default
if self.groupName == 'Locale' and name == 'Language':
return QLocale().name()
return None
def readEntry(self, name, default=None):
"""get an entry from this group."""
......@@ -957,6 +958,7 @@ class KLanguageButton(QWidget):
for action in self.popup.actions():
if action.data() == data:
return action
return None
class AboutKajonggDialog(KDialog):
......@@ -1077,6 +1079,7 @@ class AboutKajonggDialog(KDialog):
path = os.path.abspath(path)
if os.path.exists(path):
return path
return None
@classmethod
def showLicense(cls):
......@@ -1167,6 +1170,7 @@ class KConfigDialog(KDialog):
cls.dialog.updateButtons()
cls.dialog.show()
return cls.dialog
return None
def showEvent(self, unusedEvent):
"""if the settings dialog shows, remember current values
......
......@@ -111,6 +111,7 @@ class Url(str, StrMixin):
except socket.error:
return port
logException('cannot find a free port')
return None
def startServer(self, result, waiting=0):
"""make sure we have a running local server or network connectivity"""
......
......@@ -360,6 +360,7 @@ class MainWindow(KXmlGuiWindow):
if Options.gui:
ParallelAnimationGroup.cancelAll()
return KXmlGuiWindow.close(self)
return True # is closed
def closeEvent(self, event):
KXmlGuiWindow.closeEvent(self, event)
......
......@@ -145,6 +145,7 @@ class ClientMessage(Message):
errMsg = '%s said %s but is not the active player' % (
msg.player, msg.answer.i18nName)
table.abort(errMsg)
return False
class MessageAbort(ClientMessage):
......@@ -485,6 +486,7 @@ class MessageNoGameStart(NotifyAtOnceMessage):
client.beginQuestion.cancel()
elif client.game:
return client.game.close()
return None
@classmethod
def receivers(cls, request):
......@@ -571,6 +573,7 @@ class MessagePickedTile(ServerMessage):
(move.player.lastTile, move.tile)
if client.thatWasMe(move.player):
return (Message.Bonus, move.tile) if move.tile.isBonus else client.myAction(move)
return None
class MessageActivePlayer(ServerMessage):
......@@ -612,6 +615,7 @@ class MessageVoiceId(ServerMessage):
move.player.voice = Voice.locate(move.source)
if not move.player.voice:
return Message.ClientWantsVoiceData, move.source
return None
class MessageVoiceData(ServerMessage):
......@@ -684,8 +688,7 @@ class MessageDeclaredKong(ServerMessage):
move.player.showConcealedTiles(move.meld[3])
prompts = [Message.NoClaim, Message.MahJongg]
move.exposedMeld = move.player.exposeMeld(move.meld)
if prompts:
return client.ask(move, prompts)
return client.ask(move, prompts) if prompts else None
class MessageRobbedTheKong(NotifyAtOnceMessage, ServerMessage):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment