Change to use super() instead of the old py2 style everywhere

This commit is contained in:
Griatch 2022-01-26 21:45:28 +01:00
parent 55237f20a7
commit 5859de7054
33 changed files with 69 additions and 70 deletions

View file

@ -26,7 +26,7 @@ that will edit any default object, offering to change its key and description.
key = "DefaultCharacter"
def at_cmdset_creation(self):
super(CharacterCmdSet, self).at_cmdset_creation()
super().at_cmdset_creation()
# ... add the line below
self.add(GenericBuildingCmd())
```

View file

@ -26,7 +26,7 @@ that will edit any default object offering to change its key and description.
key = "DefaultCharacter"
def at_cmdset_creation(self):
super(CharacterCmdSet, self).at_cmdset_creation()
super().at_cmdset_creation()
# ... add the line below
self.add(GenericBuildingCmd())
```
@ -338,7 +338,7 @@ class CmdNoInput(Command):
def __init__(self, **kwargs):
self.menu = kwargs.pop("building_menu", None)
super(Command, self).__init__(**kwargs)
super().__init__(**kwargs)
def func(self):
"""Display the menu or choice text."""
@ -359,7 +359,7 @@ class CmdNoMatch(Command):
def __init__(self, **kwargs):
self.menu = kwargs.pop("building_menu", None)
super(Command, self).__init__(**kwargs)
super().__init__(**kwargs)
def func(self):
"""Call the proper menu or redirect to nomatch."""

View file

@ -14,7 +14,7 @@ class Submenu(BuildingMenu):
class TestBuildingMenu(BaseEvenniaCommandTest):
def setUp(self):
super(TestBuildingMenu, self).setUp()
super().setUp()
self.menu = BuildingMenu(caller=self.char1, obj=self.room1, title="test")
self.menu.add_choice("title", key="t", attr="key")

View file

@ -208,7 +208,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
"""
Populates the cmdset
"""
super(CharacterCmdSet, self).at_cmdset_creation()
super().at_cmdset_creation()
self.add(CmdCallback())
```

View file

@ -808,7 +808,7 @@ class PuzzleSystemCmdSet(CmdSet):
"""
def at_cmdset_creation(self):
super(PuzzleSystemCmdSet, self).at_cmdset_creation()
super().at_cmdset_creation()
self.add(CmdCreatePuzzleRecipe())
self.add(CmdEditPuzzle())

View file

@ -16,7 +16,7 @@ from . import puzzles
class TestPuzzles(BaseEvenniaCommandTest):
def setUp(self):
super(TestPuzzles, self).setUp()
super().setUp()
self.steel = create_object(self.object_typeclass, key="steel", location=self.char1.location)
self.flint = create_object(self.object_typeclass, key="flint", location=self.char1.location)
self.fire = create_object(self.object_typeclass, key="fire", location=self.char1.location)

View file

@ -1046,7 +1046,7 @@ class CmdCombatHelp(CmdHelp):
+ "|wUse:|n Use an item you're carrying."
)
else:
super(CmdCombatHelp, self).func() # Call the default help command
super().func() # Call the default help command
class CmdUse(MuxCommand):

View file

@ -1080,7 +1080,7 @@ class CmdCombatHelp(CmdHelp):
+ "|wDisengage:|n End your turn and attempt to end combat.|/"
)
else:
super(CmdCombatHelp, self).func() # Call the default help command
super().func() # Call the default help command
class BattleCmdSet(default_cmds.CharacterCmdSet):

View file

@ -1409,7 +1409,7 @@ class CmdCombatHelp(CmdHelp):
+ "|wDisengage:|n End your turn and attempt to end combat.|/"
)
else:
super(CmdCombatHelp, self).func() # Call the default help command
super().func() # Call the default help command
class BattleCmdSet(default_cmds.CharacterCmdSet):

View file

@ -24,7 +24,7 @@ class TestTurnBattleBasicCmd(BaseEvenniaCommandTest):
class TestTurnBattleEquipCmd(BaseEvenniaCommandTest):
def setUp(self):
super(TestTurnBattleEquipCmd, self).setUp()
super().setUp()
self.testweapon = create_object(tb_equip.TBEWeapon, key="test weapon")
self.testarmor = create_object(tb_equip.TBEArmor, key="test armor")
self.testweapon.move_to(self.char1)
@ -63,7 +63,7 @@ class TestTurnBattleRangeCmd(BaseEvenniaCommandTest):
class TestTurnBattleItemsCmd(BaseEvenniaCommandTest):
def setUp(self):
super(TestTurnBattleItemsCmd, self).setUp()
super().setUp()
self.testitem = create_object(key="test item")
self.testitem.move_to(self.char1)
@ -95,7 +95,7 @@ class TestTurnBattleMagicCmd(BaseEvenniaCommandTest):
class TestTurnBattleBasicFunc(BaseEvenniaTest):
def setUp(self):
super(TestTurnBattleBasicFunc, self).setUp()
super().setUp()
self.testroom = create_object(DefaultRoom, key="Test Room")
self.attacker = create_object(
tb_basic.TBBasicCharacter, key="Attacker", location=self.testroom
@ -106,12 +106,12 @@ class TestTurnBattleBasicFunc(BaseEvenniaTest):
self.joiner = create_object(tb_basic.TBBasicCharacter, key="Joiner", location=None)
def tearDown(self):
super(TestTurnBattleBasicFunc, self).tearDown()
super().tearDown()
self.turnhandler.stop()
self.testroom.delete()
self.attacker.delete()
self.defender.delete()
self.joiner.delete()
self.testroom.delete()
# Test combat functions
def test_tbbasicfunc(self):
@ -188,7 +188,7 @@ class TestTurnBattleBasicFunc(BaseEvenniaTest):
class TestTurnBattleEquipFunc(BaseEvenniaTest):
def setUp(self):
super(TestTurnBattleEquipFunc, self).setUp()
super().setUp()
self.testroom = create_object(DefaultRoom, key="Test Room")
self.attacker = create_object(
tb_equip.TBEquipCharacter, key="Attacker", location=self.testroom
@ -199,12 +199,12 @@ class TestTurnBattleEquipFunc(BaseEvenniaTest):
self.joiner = create_object(tb_equip.TBEquipCharacter, key="Joiner", location=None)
def tearDown(self):
super(TestTurnBattleEquipFunc, self).tearDown()
super().tearDown()
self.turnhandler.stop()
self.testroom.delete()
self.attacker.delete()
self.defender.delete()
self.joiner.delete()
self.testroom.delete()
# Test the combat functions in tb_equip too. They work mostly the same.
def test_tbequipfunc(self):
@ -280,7 +280,7 @@ class TestTurnBattleEquipFunc(BaseEvenniaTest):
class TestTurnBattleRangeFunc(BaseEvenniaTest):
def setUp(self):
super(TestTurnBattleRangeFunc, self).setUp()
super().setUp()
self.testroom = create_object(DefaultRoom, key="Test Room")
self.attacker = create_object(
tb_range.TBRangeCharacter, key="Attacker", location=self.testroom
@ -291,12 +291,12 @@ class TestTurnBattleRangeFunc(BaseEvenniaTest):
self.joiner = create_object(tb_range.TBRangeCharacter, key="Joiner", location=self.testroom)
def tearDown(self):
super(TestTurnBattleRangeFunc, self).tearDown()
super().tearDown()
self.turnhandler.stop()
self.testroom.delete()
self.attacker.delete()
self.defender.delete()
self.joiner.delete()
self.testroom.delete()
# Test combat functions in tb_range too.
def test_tbrangefunc(self):
@ -390,7 +390,7 @@ class TestTurnBattleRangeFunc(BaseEvenniaTest):
class TestTurnBattleItemsFunc(BaseEvenniaTest):
@patch("evennia.contrib.game_systems.turnbattle.tb_items.tickerhandler", new=MagicMock())
def setUp(self):
super(TestTurnBattleItemsFunc, self).setUp()
super().setUp()
self.testroom = create_object(DefaultRoom, key="Test Room")
self.attacker = create_object(
tb_items.TBItemsCharacter, key="Attacker", location=self.testroom
@ -405,13 +405,13 @@ class TestTurnBattleItemsFunc(BaseEvenniaTest):
self.test_healpotion.db.item_uses = 3
def tearDown(self):
super(TestTurnBattleItemsFunc, self).tearDown()
super().tearDown()
self.turnhandler.stop()
self.testroom.delete()
self.attacker.delete()
self.defender.delete()
self.joiner.delete()
self.user.delete()
self.testroom.delete()
# Test functions in tb_items.
def test_tbitemsfunc(self):
@ -513,7 +513,7 @@ class TestTurnBattleItemsFunc(BaseEvenniaTest):
class TestTurnBattleMagicFunc(BaseEvenniaTest):
def setUp(self):
super(TestTurnBattleMagicFunc, self).setUp()
super().setUp()
self.testroom = create_object(DefaultRoom, key="Test Room")
self.attacker = create_object(
tb_magic.TBMagicCharacter, key="Attacker", location=self.testroom
@ -524,12 +524,12 @@ class TestTurnBattleMagicFunc(BaseEvenniaTest):
self.joiner = create_object(tb_magic.TBMagicCharacter, key="Joiner", location=self.testroom)
def tearDown(self):
super(TestTurnBattleMagicFunc, self).tearDown()
super().tearDown()
self.turnhandler.stop()
self.testroom.delete()
self.attacker.delete()
self.defender.delete()
self.joiner.delete()
self.testroom.delete()
# Test combat functions in tb_magic.
def test_tbbasicfunc(self):

View file

@ -285,7 +285,7 @@ class ExtendedRoom(DefaultRoom):
# ensures that our description is current based on time/season
self.update_current_description()
# run the normal return_appearance method, now that desc is updated.
return super(ExtendedRoom, self).return_appearance(looker, **kwargs)
return super().return_appearance(looker, **kwargs)
def update_current_description(self):
"""

View file

@ -12,11 +12,11 @@ class TestBodyFunctions(BaseEvenniaTest):
script_typeclass = BodyFunctions
def setUp(self):
super(TestBodyFunctions, self).setUp()
super().setUp()
self.script.obj = self.char1
def tearDown(self):
super(TestBodyFunctions, self).tearDown()
super().tearDown()
# if we forget to stop the script, DirtyReactorAggregateError will be raised
self.script.stop()

View file

@ -228,7 +228,7 @@ class AuditedServerSession(ServerSession):
except Exception as e:
logger.log_err(e)
super(AuditedServerSession, self).data_out(**kwargs)
super().data_out(**kwargs)
def data_in(self, **kwargs):
"""
@ -246,4 +246,4 @@ class AuditedServerSession(ServerSession):
except Exception as e:
logger.log_err(e)
super(AuditedServerSession, self).data_in(**kwargs)
super().data_in(**kwargs)