Ran black on sources

This commit is contained in:
Griatch 2024-04-27 22:26:18 +02:00
parent 49330826f3
commit fd39935d19
9 changed files with 56 additions and 29 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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