From 1b016bef735d02b76970b802a1a58e6de6508d05 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 15 Nov 2022 21:32:50 -0800 Subject: [PATCH] ruff: Enable naming errors. Signed-off-by: Anders Kaseorg --- pyproject.toml | 4 ++++ zerver/lib/test_classes.py | 2 +- zerver/lib/test_helpers.py | 6 +++--- zerver/models.py | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3257bc04e7..2a9be168b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,6 +106,7 @@ select = [ "E", # style errors "F", # flakes "M", # meta + "N", # naming "U", # upgrade "W", # style warnings ] @@ -120,6 +121,9 @@ ignore = [ "E402", # Module level import not at top of file "E501", # Line too long "E731", # Do not assign a lambda expression, use a def + "N802", # Function name should be lowercase + "N806", # Variable in function should be lowercase + "N818", # Exception name should be named with an Error suffix ] line-length = 100 target-version = "py38" diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index b4c66c041b..35da3d69f2 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -140,7 +140,7 @@ class UploadSerializeMixin(SerializeMixin): class ZulipTestCase(TestCase): # Ensure that the test system just shows us diffs - maxDiff: Optional[int] = None + maxDiff: Optional[int] = None # noqa: N815 def setUp(self) -> None: super().setUp() diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index 5613bde21c..b79deea473 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -73,13 +73,13 @@ class MockLDAP(fakeldap.MockLDAP): class LDAPError(ldap.LDAPError): pass - class INVALID_CREDENTIALS(ldap.INVALID_CREDENTIALS): + class INVALID_CREDENTIALS(ldap.INVALID_CREDENTIALS): # noqa: N801 pass - class NO_SUCH_OBJECT(ldap.NO_SUCH_OBJECT): + class NO_SUCH_OBJECT(ldap.NO_SUCH_OBJECT): # noqa: N801 pass - class ALREADY_EXISTS(ldap.ALREADY_EXISTS): + class ALREADY_EXISTS(ldap.ALREADY_EXISTS): # noqa: N801 pass diff --git a/zerver/models.py b/zerver/models.py index 07feb0123f..84bedce234 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -792,11 +792,11 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub # `realm` instead of `self` here to make sure the parameters of the cache key # function matches the original method. @cache_with_key(get_realm_emoji_cache_key, timeout=3600 * 24 * 7) - def get_emoji(realm) -> Dict[str, EmojiInfo]: + def get_emoji(realm) -> Dict[str, EmojiInfo]: # noqa: N805 return get_realm_emoji_uncached(realm) @cache_with_key(get_active_realm_emoji_cache_key, timeout=3600 * 24 * 7) - def get_active_emoji(realm) -> Dict[str, EmojiInfo]: + def get_active_emoji(realm) -> Dict[str, EmojiInfo]: # noqa: N805 return get_active_realm_emoji_uncached(realm) def get_admin_users_and_bots( @@ -897,7 +897,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub # `realm` instead of `self` here to make sure the parameters of the cache key # function matches the original method. @cache_with_key(get_realm_used_upload_space_cache_key, timeout=3600 * 24 * 7) - def currently_used_upload_space_bytes(realm) -> int: + def currently_used_upload_space_bytes(realm) -> int: # noqa: N805 used_space = Attachment.objects.filter(realm=realm).aggregate(Sum("size"))["size__sum"] if used_space is None: return 0