Fix many py3.12 SyntaxWarnings as per #3561

This commit is contained in:
Griatch 2024-06-15 11:50:03 +02:00
parent 7b299f2cad
commit 381d34522b
8 changed files with 28 additions and 25 deletions

View file

@ -0,0 +1,10 @@
```{eval-rst}
evennia.utils.hex\_colors
================================
.. automodule:: evennia.utils.hex_colors
:members:
:undoc-members:
:show-inheritance:
```

View file

@ -44,7 +44,7 @@ class Migration(migrations.Migration):
verbose_name="username",
validators=[
django.core.validators.RegexValidator(
"^[\\w.@+-]+$", "Enter a valid username.", "invalid"
r"^[\w.@+-]+$", "Enter a valid username.", "invalid"
)
],
),

View file

@ -2,9 +2,8 @@
import django.core.validators
from django.db import migrations, models
import evennia.accounts.manager
from django.db import migrations, models
class Migration(migrations.Migration):
@ -47,7 +46,7 @@ class Migration(migrations.Migration):
max_length=30,
validators=[
django.core.validators.RegexValidator(
"^[\\w.@+-]+$",
r"^[\w.@+-]+$",
"Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.",
"invalid",
)

View file

@ -21,7 +21,7 @@ class Migration(migrations.Migration):
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[\\w.@+-]+$",
r"^[\w.@+-]+$",
"Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.",
)
],

View file

@ -3,18 +3,14 @@
from random import randint
from unittest import TestCase
from django.test import override_settings
from mock import MagicMock, Mock, patch
import evennia
from evennia.accounts.accounts import (
AccountSessionHandler,
DefaultAccount,
DefaultGuest,
)
from django.test import override_settings
from evennia.accounts.accounts import (AccountSessionHandler, DefaultAccount,
DefaultGuest)
from evennia.utils import create
from evennia.utils.test_resources import BaseEvenniaTest
from evennia.utils.utils import uses_database
from mock import MagicMock, Mock, patch
class TestAccountSessionHandler(TestCase):
@ -172,7 +168,7 @@ class TestDefaultAccountAuth(BaseEvenniaTest):
if not uses_database("mysql"):
# TODO As of Mar 2019, mysql does not pass this test due to collation problems
# that has not been possible to resolve
result, error = DefaultAccount.validate_username("¯\_(ツ)_/¯")
result, error = DefaultAccount.validate_username(r"¯\_(ツ)_/¯")
self.assertFalse(result, "Validator allowed kanji in username.")
# Should not allow duplicate username

View file

@ -5,11 +5,10 @@ Base typeclass for in-game Channels.
import re
import evennia
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from django.utils.text import slugify
import evennia
from evennia.comms.managers import ChannelManager
from evennia.comms.models import ChannelDB
from evennia.typeclasses.models import TypeclassBase
@ -18,7 +17,7 @@ from evennia.utils.utils import inherits_from, make_iter
class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
r"""
This is the base class for all Channel Comms. Inherit from this to
create different types of communication channels.
@ -35,7 +34,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
in front of every channel message; use `{channelmessage}` token to insert the
name of the current channel. Set to `None` if you want no prefix (or want to
handle it in a hook during message generation instead.
- `channel_msg_nick_pattern`(str, default `"{alias}\\s*?|{alias}\\s+?(?P<arg1>.+?)") -
- `channel_msg_nick_pattern`(str, default `"{alias}\s*?|{alias}\s+?(?P<arg1>.+?)") -
this is what used when a channel subscriber gets a channel nick assigned to this
channel. The nickhandler uses the pattern to pick out this channel's name from user
input. The `{alias}` token will get both the channel's key and any set/custom aliases

View file

@ -65,7 +65,7 @@ class S3Boto3StorageTests(S3Boto3TestCase):
"""
Test the _clean_name when the path has a trailing slash
"""
path = self.storage._clean_name("path\\to\\somewhere")
path = self.storage._clean_name(r"path\to\somewhere")
self.assertEqual(path, "path/to/somewhere")
def test_pickle_with_bucket(self):

View file

@ -10,11 +10,10 @@ from ast import literal_eval
from unittest.mock import MagicMock, patch
from django.test import TestCase, override_settings
from evennia.utils import funcparser, test_resources
from parameterized import parameterized
from simpleeval import simple_eval
from evennia.utils import funcparser, test_resources
def _test_callable(*args, **kwargs):
kwargs.pop("funcparser", None)
@ -144,12 +143,12 @@ class TestFuncParser(TestCase):
(r'Test args3 $bar(foo, bar, " too")', "Test args3 _test(foo, bar, too)"),
("Test args4 $foo('')", "Test args4 _test('')"), # ' treated as literal
('Test args4 $foo("")', "Test args4 _test()"),
("Test args5 $foo(\(\))", "Test args5 _test(())"),
("Test args6 $foo(\()", "Test args6 _test(()"),
(r"Test args5 $foo(\(\))", "Test args5 _test(())"),
(r"Test args6 $foo(\()", "Test args6 _test(()"),
("Test args7 $foo(())", "Test args7 _test(())"),
("Test args8 $foo())", "Test args8 _test())"),
("Test args9 $foo(=)", "Test args9 _test(=)"),
("Test args10 $foo(\,)", "Test args10 _test(,)"),
(r"Test args10 $foo(\,)", "Test args10 _test(,)"),
(r'Test args10 $foo(",")', "Test args10 _test(,)"),
("Test args11 $foo(()", "Test args11 $foo(()"), # invalid syntax
(
@ -327,7 +326,7 @@ class TestFuncParser(TestCase):
"""
string = "Test $foo(a) and $bar() and $rep(c) things"
ret = self.parser.parse(string, escape=True)
self.assertEqual("Test \$foo(a) and \$bar() and \$rep(c) things", ret)
self.assertEqual(r"Test \$foo(a) and \$bar() and \$rep(c) things", ret)
def test_parse_lit(self):
"""