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 @@ jobs:
with:
ref: v0.9.5
- name: Checkout develop branch
- name: Checkout ${{ github.ref }} branch
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
@ -56,6 +56,5 @@ jobs:
git config --global user.email "docbuilder@evennia.com"
git config --global user.name "Evennia docbuilder action"
git branch
git checkout develop
cd docs
make release

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

@ -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

@ -664,7 +664,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
could get invalidated.
"""
super(DefaultAccount, self).set_password(password)
super().set_password(password)
logger.log_sec(f"Password successfully changed for {self}.")
self.at_password_change()

View file

@ -116,7 +116,7 @@ class TestDefaultGuest(BaseEvenniaTest):
class TestDefaultAccountAuth(BaseEvenniaTest):
def setUp(self):
super(TestDefaultAccountAuth, self).setUp()
super().setUp()
self.password = "testpassword"
self.account.delete()

View file

@ -141,7 +141,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
"""
Support escaping of = with \=
"""
super(CmdNick, self).parse()
super().parse()
args = (self.lhs or "") + (" = %s" % self.rhs if self.rhs else "")
parts = re.split(r"(?<!\\)=", args, 1)
self.rhs = None

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)

View file

@ -44,7 +44,7 @@ class TestLockCheck(BaseEvenniaTest):
class TestLockfuncs(BaseEvenniaTest):
def setUp(self):
super(TestLockfuncs, self).setUp()
super().setUp()
self.account2.permissions.add("Admin")
self.char2.permissions.add("Builder")

View file

@ -2661,7 +2661,7 @@ class OLCMenu(EvMenu):
Format the node text itself.
"""
return super(OLCMenu, self).nodetext_formatter(nodetext)
return super().nodetext_formatter(nodetext)
def options_formatter(self, optionlist):
"""
@ -2697,7 +2697,7 @@ class OLCMenu(EvMenu):
if olc_options
else ""
)
other_options = super(OLCMenu, self).options_formatter(other_options)
other_options = super().options_formatter(other_options)
sep = "\n\n" if olc_options and other_options else ""
return "{}{}{}".format(olc_options, sep, other_options)

View file

@ -47,7 +47,7 @@ _PROTPARENTS = {
class TestSpawner(BaseEvenniaTest):
def setUp(self):
super(TestSpawner, self).setUp()
super().setUp()
self.prot1 = {
"prototype_key": "testprototype",
"typeclass": "evennia.objects.objects.DefaultObject",
@ -309,7 +309,7 @@ class TestUtils(BaseEvenniaTest):
class TestProtLib(BaseEvenniaTest):
def setUp(self):
super(TestProtLib, self).setUp()
super().setUp()
self.obj1.attributes.add("testattr", "testval")
self.prot = spawner.prototype_from_object(self.obj1)
@ -357,7 +357,7 @@ class TestProtFuncs(BaseEvenniaTest):
class TestPrototypeStorage(BaseEvenniaTest):
def setUp(self):
super(TestPrototypeStorage, self).setUp()
super().setUp()
self.maxDiff = None
self.prot1 = spawner.prototype_from_object(self.obj1)
@ -442,7 +442,7 @@ class TestMenuModule(BaseEvenniaTest):
maxDiff = None
def setUp(self):
super(TestMenuModule, self).setUp()
super().setUp()
# set up fake store
self.caller = self.char1

View file

@ -108,7 +108,7 @@ class AMPServerClientProtocol(amp.AMPMultiConnectionProtocol):
"""
# print("AMPClient new connection {}".format(self))
info_dict = self.factory.server.get_info_dict()
super(AMPServerClientProtocol, self).connectionMade()
super().connectionMade()
# first thing we do is to request the Portal to sync all sessions
# back with the Server side. We also need the startup mode (reload, reset, shutdown)
self.send_AdminServer2Portal(

View file

@ -177,14 +177,14 @@ class Compressed(amp.String):
Note: In Py3 this is really a byte stream.
"""
return zlib.compress(super(Compressed, self).toString(inObject), 9)
return zlib.compress(super().toString(inObject), 9)
def fromString(self, inString):
"""
Convert (decompress) from the string-representation on the wire to Python.
"""
return super(Compressed, self).fromString(zlib.decompress(inString))
return super().fromString(zlib.decompress(inString))
class MsgLauncher2Portal(amp.Command):
@ -313,7 +313,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
self.send_task = None
self.multibatches = 0
# later twisted amp has its own __init__
super(AMPMultiConnectionProtocol, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
def _commandReceived(self, box):
"""
@ -368,7 +368,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
# an incomplete AMP box means more batches are forthcoming.
self.multibatches += 1
try:
super(AMPMultiConnectionProtocol, self).dataReceived(data)
super().dataReceived(data)
except KeyError:
_get_logger().log_trace(
"Discarded incoming partial (packed) data (len {})".format(len(data))
@ -379,7 +379,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
# end of existing multibatch
self.multibatches = max(0, self.multibatches - 1)
try:
super(AMPMultiConnectionProtocol, self).dataReceived(data)
super().dataReceived(data)
except KeyError:
_get_logger().log_trace(
"Discarded incoming multi-batch (packed) data (len {})".format(len(data))

View file

@ -95,7 +95,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
"""
# wipe broadcast and data memory
super(AMPServerProtocol, self).connectionLost(reason)
super().connectionLost(reason)
if self.factory.server_connection == self:
self.factory.server_connection = None
self.factory.portal.server_info_dict = {}

View file

@ -72,7 +72,7 @@ class SSLProtocol(TelnetProtocol):
"""
def __init__(self, *args, **kwargs):
super(SSLProtocol, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.protocol_key = "telnet/ssl"

View file

@ -46,7 +46,7 @@ class TestAMPServer(TwistedTestCase):
"""
def setUp(self):
super(TestAMPServer, self).setUp()
super().setUp()
portal = Mock()
factory = AMPServerFactory(portal)
self.proto = factory.buildProtocol(("localhost", 0))
@ -217,7 +217,7 @@ class TestIRC(TestCase):
class TestTelnet(TwistedTestCase):
def setUp(self):
super(TestTelnet, self).setUp()
super().setUp()
factory = TelnetServerFactory()
factory.protocol = TelnetProtocol
factory.sessionhandler = PORTAL_SESSIONS

View file

@ -76,7 +76,7 @@ class ServerSession(_BASE_SESSION_CLASS):
if not _ObjectDB:
from evennia.objects.models import ObjectDB as _ObjectDB
super(ServerSession, self).at_sync()
super().at_sync()
if not self.logged_in:
# assign the unloggedin-command set.
self.cmdset_storage = settings.CMDSET_UNLOGGEDIN

View file

@ -24,7 +24,7 @@ DelayedCall.debug = True
# MagicMock(return_value=create.account("TestAMPAccount", "test@test.com", "testpassword")))
class _TestAMP(TwistedTestCase):
def setUp(self):
super(_TestAMP, self).setUp()
super().setUp()
self.account = mommy.make("accounts.AccountDB", id=1)
self.server = server.Evennia(MagicMock())
self.server.sessions.data_in = MagicMock()
@ -47,7 +47,7 @@ class _TestAMP(TwistedTestCase):
def tearDown(self):
self.account.delete()
super(_TestAMP, self).tearDown()
super().tearDown()
def _connect_client(self, mocktransport):
"Setup client to send data for testing"

View file

@ -32,6 +32,6 @@ class EvenniaTestSuiteRunner(DiscoverRunner):
import evennia
evennia._init()
return super(EvenniaTestSuiteRunner, self).build_suite(
return super().build_suite(
test_labels, extra_tests=extra_tests, **kwargs
)

View file

@ -751,7 +751,7 @@ class TypeclassManager(TypedObjectManager):
Annotated queryset.
"""
return (
super(TypeclassManager, self)
super()
.filter(db_typeclass_path=self.model.path)
.annotate(*args, **kwargs)
)
@ -767,7 +767,7 @@ class TypeclassManager(TypedObjectManager):
Queryset of values dictionaries, just filtered by typeclass first.
"""
return (
super(TypeclassManager, self)
super()
.filter(db_typeclass_path=self.model.path)
.values(*args, **kwargs)
)
@ -783,7 +783,7 @@ class TypeclassManager(TypedObjectManager):
Queryset of value_list tuples, just filtered by typeclass first.
"""
return (
super(TypeclassManager, self)
super()
.filter(db_typeclass_path=self.model.path)
.values_list(*args, **kwargs)
)

View file

@ -31,7 +31,7 @@ class EvenniaWebTest(BaseEvenniaTest):
authenticated_response = 200
def setUp(self):
super(EvenniaWebTest, self).setUp()
super().setUp()
# Add chars to account rosters
self.account.db._playable_characters = [self.char1]
@ -110,13 +110,13 @@ class WebclientTest(EvenniaWebTest):
def test_get(self):
self.authenticated_response = 200
self.unauthenticated_response = 200
super(WebclientTest, self).test_get()
super().test_get()
@override_settings(WEBCLIENT_ENABLED=False)
def test_get_disabled(self):
self.authenticated_response = 404
self.unauthenticated_response = 404
super(WebclientTest, self).test_get()
super().test_get()
class ChannelListTest(EvenniaWebTest):
@ -127,7 +127,7 @@ class ChannelDetailTest(EvenniaWebTest):
url_name = "channel-detail"
def setUp(self):
super(ChannelDetailTest, self).setUp()
super().setUp()
klass = class_from_module(self.channel_typeclass,
fallback=settings.FALLBACK_CHANNEL_TYPECLASS)
@ -189,7 +189,7 @@ class HelpLockedDetailTest(EvenniaWebTest):
url_name = "help-entry-detail"
def setUp(self):
super(HelpLockedDetailTest, self).setUp()
super().setUp()
# create a db entry with a lock
self.db_help_entry = create_help_entry('unit test locked topic', 'unit test locked entrytext',

View file

@ -123,7 +123,7 @@ class ObjectDetailView(EvenniaDetailView):
raise PermissionDenied("You are not authorized to %s this object." % self.access_type)
# Get the object, if it is in the specified queryset
obj = super(ObjectDetailView, self).get_object(queryset)
obj = super().get_object(queryset)
return obj