From fd39935d19c662e7e6bf761c0741dc7faa7c95e9 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 27 Apr 2024 22:26:18 +0200 Subject: [PATCH] Ran black on sources --- evennia/commands/default/account.py | 4 ++-- evennia/commands/default/building.py | 24 ++++++++++++++------- evennia/commands/default/comms.py | 1 + evennia/commands/default/help.py | 2 +- evennia/server/portal/telnet.py | 11 ++++++---- evennia/server/portal/telnet_oob.py | 4 +++- evennia/utils/funcparser.py | 22 +++++++++++-------- evennia/utils/tests/test_funcparser.py | 13 +++++++++-- evennia/utils/verb_conjugation/conjugate.py | 4 ++-- 9 files changed, 56 insertions(+), 29 deletions(-) diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index 1185648d01..4fdb88f4ff 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -638,8 +638,8 @@ class CmdOption(COMMAND_DEFAULT_CLASS): flags[new_name] = new_val # If we're manually assign a display size, turn off auto-resizing - if new_name in ['SCREENWIDTH', 'SCREENHEIGHT']: - flags['AUTORESIZE'] = False + if new_name in ["SCREENWIDTH", "SCREENHEIGHT"]: + flags["AUTORESIZE"] = False self.msg( f"Option |w{new_name}|n was changed from '|w{old_val}|n' to" diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 7e72ad23e9..53b3c6ba94 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -5,13 +5,13 @@ Building and world design commands import re import typing -import evennia from django.conf import settings from django.core.paginator import Paginator from django.db.models import Max, Min, Q + +import evennia from evennia import InterruptCommand -from evennia.commands.cmdhandler import (generate_cmdset_providers, - get_and_merge_cmdsets) +from evennia.commands.cmdhandler import generate_cmdset_providers, get_and_merge_cmdsets from evennia.locks.lockhandler import LockException from evennia.objects.models import ObjectDB from evennia.prototypes import menus as olc_menus @@ -24,10 +24,18 @@ from evennia.utils.dbserialize import deserialize from evennia.utils.eveditor import EvEditor from evennia.utils.evmore import EvMore from evennia.utils.evtable import EvTable -from evennia.utils.utils import (class_from_module, crop, dbref, display_len, - format_grid, get_all_typeclasses, - inherits_from, interactive, list_to_string, - variable_from_module) +from evennia.utils.utils import ( + class_from_module, + crop, + dbref, + display_len, + format_grid, + get_all_typeclasses, + inherits_from, + interactive, + list_to_string, + variable_from_module, +) COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS) @@ -170,7 +178,7 @@ class ObjManipCommand(COMMAND_DEFAULT_CLASS): def get_object_typeclass( self, obj_type: str = "object", typeclass: str = None, method: str = "cmd_create", **kwargs - ) -> tuple[typing.Optional['Typeclass'], list[str]]: + ) -> tuple[typing.Optional["Typeclass"], list[str]]: """ This hook is called by build commands to determine which typeclass to use for a specific purpose. diff --git a/evennia/commands/default/comms.py b/evennia/commands/default/comms.py index 521eef7291..cac9905a5a 100644 --- a/evennia/commands/default/comms.py +++ b/evennia/commands/default/comms.py @@ -9,6 +9,7 @@ Communication commands: from django.conf import settings from django.db.models import Q + from evennia.accounts import bots from evennia.accounts.models import AccountDB from evennia.comms.comms import DefaultChannel diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index 4a7a1f9adf..2a8ef389cc 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -1039,7 +1039,7 @@ class CmdSetHelp(CmdHelp): old_entry.locks.add(lockstring) except LockException as e: old_entry.locks.add(existing_locks) - self.msg(str(e) + " Locks not changed.") + self.msg(str(e) + " Locks not changed.") else: self.msg(f"Locks for entry '{topicstr}'{aliastxt} changed to: {lockstring}") return diff --git a/evennia/server/portal/telnet.py b/evennia/server/portal/telnet.py index b545e67f7e..e961152b16 100644 --- a/evennia/server/portal/telnet.py +++ b/evennia/server/portal/telnet.py @@ -94,10 +94,13 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS): """ try: # Do we have a NAWS update? - if (NAWS in data and - len([data[i:i+1] for i in range(0, len(data))]) == 9 and - # Is auto resizing on? - self.protocol_flags.get('AUTORESIZE')): + if ( + NAWS in data + and len([data[i : i + 1] for i in range(0, len(data))]) == 9 + and + # Is auto resizing on? + self.protocol_flags.get("AUTORESIZE") + ): self.sessionhandler.sync(self.sessionhandler.get(self.sessid)) super().dataReceived(data) diff --git a/evennia/server/portal/telnet_oob.py b/evennia/server/portal/telnet_oob.py index 37c1f8067c..ffc2283067 100644 --- a/evennia/server/portal/telnet_oob.py +++ b/evennia/server/portal/telnet_oob.py @@ -258,7 +258,9 @@ class TelnetOOB: gmcp_cmdname = EVENNIA_TO_GMCP[cmdname] elif "_" in cmdname: # enforce initial capitalization of each command part, leaving fully-capitalized sections intact - gmcp_cmdname = ".".join(word.capitalize() if not word.isupper() else word for word in cmdname.split("_")) + gmcp_cmdname = ".".join( + word.capitalize() if not word.isupper() else word for word in cmdname.split("_") + ) else: gmcp_cmdname = "Core.%s" % (cmdname if cmdname.istitle() else cmdname.capitalize()) diff --git a/evennia/utils/funcparser.py b/evennia/utils/funcparser.py index bca394530f..c0de83838a 100644 --- a/evennia/utils/funcparser.py +++ b/evennia/utils/funcparser.py @@ -1330,7 +1330,7 @@ def funcparser_callable_conjugate(*args, caller=None, receiver=None, mapping=Non caller (Object): The object who represents 'you' in the string. receiver (Object): The recipient of the string. mapping (dict, optional): This is a mapping `{key:Object, ...}` and is - used to find which object the optional `key` argument refers to. If not given, + used to find which object the optional `key` argument refers to. If not given, the `caller` kwarg is used. Returns: @@ -1341,7 +1341,7 @@ def funcparser_callable_conjugate(*args, caller=None, receiver=None, mapping=Non Notes: Note that the verb will not be capitalized. - + Examples: This is often used in combination with the $you/You callables. @@ -1366,7 +1366,9 @@ def funcparser_callable_conjugate(*args, caller=None, receiver=None, mapping=Non return second_person_str if obj == receiver else third_person_str -def funcparser_callable_conjugate_for_pronouns(*args, caller=None, receiver=None, mapping=None, **kwargs): +def funcparser_callable_conjugate_for_pronouns( + *args, caller=None, receiver=None, mapping=None, **kwargs +): """ Usage: $pconj(word, [key]) @@ -1377,7 +1379,7 @@ def funcparser_callable_conjugate_for_pronouns(*args, caller=None, receiver=None caller (Object): The object who represents 'you' in the string. receiver (Object): The recipient of the string. mapping (dict, optional): This is a mapping `{key:Object, ...}` and is - used to find which object the optional `key` argument refers to. If not given, + used to find which object the optional `key` argument refers to. If not given, the `caller` kwarg is used. Returns: @@ -1388,7 +1390,7 @@ def funcparser_callable_conjugate_for_pronouns(*args, caller=None, receiver=None Notes: Note that the verb will not be capitalized. - + Examples: This is often used in combination with the $pron/Pron callables. @@ -1414,15 +1416,17 @@ def funcparser_callable_conjugate_for_pronouns(*args, caller=None, receiver=None plural = False if hasattr(obj, "gender"): if callable(obj.gender): - plural = (obj.gender() == "plural") + plural = obj.gender() == "plural" else: - plural = (obj.gender == "plural") + plural = obj.gender == "plural" second_person_str, third_person_str = verb_actor_stance_components(verb, plural=plural) return second_person_str if obj == receiver else third_person_str -def funcparser_callable_pronoun(*args, caller=None, receiver=None, mapping=None, capitalize=False, **kwargs): +def funcparser_callable_pronoun( + *args, caller=None, receiver=None, mapping=None, capitalize=False, **kwargs +): """ Usage: $pron(word, [options], [key]) @@ -1501,7 +1505,7 @@ def funcparser_callable_pronoun(*args, caller=None, receiver=None, mapping=None, `caller` or not helps determine 2nd vs 3rd-person forms. This is provided automatically by the funcparser. mapping (dict, optional): This is a mapping `{key:Object, ...}` and is - used to find which object the optional `key` argument refers to. If not given, + used to find which object the optional `key` argument refers to. If not given, the `caller` kwarg is used. capitalize (bool): The input retains its capitalization. If this is set the output is always capitalized. diff --git a/evennia/utils/tests/test_funcparser.py b/evennia/utils/tests/test_funcparser.py index 1b2fd41da1..5ca8824186 100644 --- a/evennia/utils/tests/test_funcparser.py +++ b/evennia/utils/tests/test_funcparser.py @@ -435,7 +435,11 @@ class TestDefaultCallables(TestCase): ("$You() $conj(smile) at him.", "You smile at him.", "Char1 smiles at him."), ("$You() $conj(smile) at $You(char1).", "You smile at You.", "Char1 smiles at Char1."), ("$You() $conj(smile) at $You(char2).", "You smile at Char2.", "Char1 smiles at You."), - ("$You() $conj(smile) while $You(char2) $conj(waves, char2).", "You smile while Char2 waves.", "Char1 smiles while You wave."), + ( + "$You() $conj(smile) while $You(char2) $conj(waves, char2).", + "You smile while Char2 waves.", + "Char1 smiles while You wave.", + ), ( "$You(char2) $conj(smile) at $you(char1).", "Char2 smile at you.", @@ -519,7 +523,12 @@ class TestDefaultCallables(TestCase): string = "Char1 raises $pron(your, char1) fist as Char2 raises $pron(yours, char2)" expected = "Char1 raises her fist as Char2 raises his" - ret = self.parser.parse(string, caller=self.obj1, mapping={'char1': self.obj1, 'char2': self.obj2}, raise_errors=True) + ret = self.parser.parse( + string, + caller=self.obj1, + mapping={"char1": self.obj1, "char2": self.obj2}, + raise_errors=True, + ) self.assertEqual(expected, ret) def test_pronoun_viewpoint(self): diff --git a/evennia/utils/verb_conjugation/conjugate.py b/evennia/utils/verb_conjugation/conjugate.py index 21ec134ced..e29530b9b9 100644 --- a/evennia/utils/verb_conjugation/conjugate.py +++ b/evennia/utils/verb_conjugation/conjugate.py @@ -371,7 +371,7 @@ def verb_actor_stance_components(verb, plural=False): Args: verb (str): The verb to analyze - plural (bool): Whether to force 3rd person to plural form + plural (bool): Whether to force 3rd person to plural form Returns: tuple: The 2nd person (you) and 3rd person forms of the verb, @@ -380,7 +380,7 @@ def verb_actor_stance_components(verb, plural=False): tense = verb_tense(verb) them = "*" if plural else "3" them_suff = "" if plural else "s" - + if "participle" in tense or "plural" in tense: return (verb, verb) if tense == "infinitive" or "present" in tense: