diff --git a/allianceauth/authentication/models.py b/allianceauth/authentication/models.py index 714f1934..8871e7ee 100644 --- a/allianceauth/authentication/models.py +++ b/allianceauth/authentication/models.py @@ -1,4 +1,5 @@ import logging +from typing import ClassVar from django.contrib.auth.models import User, Permission from django.db import models, transaction @@ -27,7 +28,7 @@ class State(models.Model): help_text="Factions to whose members this state is available.") public = models.BooleanField(default=False, help_text="Make this state available to any character.") - objects = StateManager() + objects: ClassVar[StateManager] = StateManager() class Meta: ordering = ['-priority'] @@ -137,8 +138,10 @@ class UserProfile(models.Model): sender=self.__class__, user=self.user, state=self.state ) - def __str__(self): + def __str__(self) -> str: return str(self.user) + + class CharacterOwnership(models.Model): class Meta: default_permissions = ('change', 'delete') @@ -148,7 +151,7 @@ class CharacterOwnership(models.Model): owner_hash = models.CharField(max_length=28, unique=True) user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='character_ownerships') - objects = CharacterOwnershipManager() + objects: ClassVar[CharacterOwnershipManager] = CharacterOwnershipManager() def __str__(self): return f"{self.user}: {self.character}" diff --git a/allianceauth/corputils/models.py b/allianceauth/corputils/models.py index 7ac03b7e..0bed1ed0 100644 --- a/allianceauth/corputils/models.py +++ b/allianceauth/corputils/models.py @@ -1,5 +1,6 @@ import logging import os +from typing import ClassVar from allianceauth.authentication.models import CharacterOwnership, UserProfile from bravado.exception import HTTPForbidden @@ -40,9 +41,9 @@ class CorpStats(models.Model): verbose_name = "corp stats" verbose_name_plural = "corp stats" - objects = CorpStatsManager() + objects: ClassVar[CorpStatsManager] = CorpStatsManager() - def __str__(self): + def __str__(self) -> str: return f"{self.__class__.__name__} for {self.corp}" def update(self): diff --git a/allianceauth/eveonline/autogroups/models.py b/allianceauth/eveonline/autogroups/models.py index 88bc3ece..b7309354 100644 --- a/allianceauth/eveonline/autogroups/models.py +++ b/allianceauth/eveonline/autogroups/models.py @@ -1,4 +1,5 @@ import logging +from typing import ClassVar from django.db import models, transaction from django.contrib.auth.models import Group, User from django.core.exceptions import ObjectDoesNotExist @@ -78,7 +79,7 @@ class AutogroupsConfig(models.Model): max_length=10, default='', blank=True, help_text='Any spaces in the group name will be replaced with this.') - objects = AutogroupsConfigManager() + objects: ClassVar[AutogroupsConfigManager] = AutogroupsConfigManager() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/allianceauth/eveonline/managers.py b/allianceauth/eveonline/managers.py index 5e849edc..ceec8c0b 100644 --- a/allianceauth/eveonline/managers.py +++ b/allianceauth/eveonline/managers.py @@ -14,10 +14,10 @@ class EveCharacterProviderManager: class EveCharacterManager(models.Manager): provider = EveCharacterProviderManager() - def create_character(self, character_id): + def create_character(self, character_id) -> models.Model: return self.create_character_obj(self.provider.get_character(character_id)) - def create_character_obj(self, character: providers.Character): + def create_character_obj(self, character: providers.Character) -> models.Model: return self.create( character_id=character.id, character_name=character.name, diff --git a/allianceauth/eveonline/models.py b/allianceauth/eveonline/models.py index fb279c35..15f06419 100644 --- a/allianceauth/eveonline/models.py +++ b/allianceauth/eveonline/models.py @@ -1,5 +1,5 @@ import logging -from typing import Union +from typing import ClassVar, Union from django.core.exceptions import ObjectDoesNotExist from django.db import models @@ -75,8 +75,8 @@ class EveAllianceInfo(models.Model): alliance_ticker = models.CharField(max_length=254) executor_corp_id = models.PositiveIntegerField() - objects = EveAllianceManager() - provider = EveAllianceProviderManager() + objects: ClassVar[EveAllianceManager] = EveAllianceManager() + provider: ClassVar[EveAllianceProviderManager] = EveAllianceProviderManager() class Meta: indexes = [models.Index(fields=['executor_corp_id',])] @@ -147,7 +147,7 @@ class EveCorporationInfo(models.Model): EveAllianceInfo, blank=True, null=True, on_delete=models.SET_NULL ) - objects = EveCorporationManager() + objects: ClassVar[EveCorporationManager] = EveCorporationManager() provider = EveCorporationProviderManager() class Meta: @@ -214,7 +214,7 @@ class EveCharacter(models.Model): faction_id = models.PositiveIntegerField(blank=True, null=True, default=None) faction_name = models.CharField(max_length=254, blank=True, null=True, default='') - objects = EveCharacterManager() + objects: ClassVar[EveCharacterManager] = EveCharacterManager() provider = EveCharacterProviderManager() class Meta: diff --git a/allianceauth/hrapplications/models.py b/allianceauth/hrapplications/models.py index 4767ec7f..df63439a 100644 --- a/allianceauth/hrapplications/models.py +++ b/allianceauth/hrapplications/models.py @@ -1,3 +1,4 @@ +from typing import ClassVar from django.contrib.auth.models import User from django.db import models from sortedm2m.fields import SortedManyToManyField @@ -40,7 +41,7 @@ class Application(models.Model): reviewer_character = models.ForeignKey(EveCharacter, on_delete=models.SET_NULL, blank=True, null=True) created = models.DateTimeField(auto_now_add=True) - objects = ApplicationManager() + objects: ClassVar[ApplicationManager] = ApplicationManager() def __str__(self): return str(self.user) + " Application To " + str(self.form) diff --git a/allianceauth/menu/models.py b/allianceauth/menu/models.py index b2984842..a2b218e7 100644 --- a/allianceauth/menu/models.py +++ b/allianceauth/menu/models.py @@ -1,3 +1,4 @@ +from typing import ClassVar from django.db import models from django.utils.translation import gettext_lazy as _ @@ -68,7 +69,7 @@ class MenuItem(models.Model): help_text=_("External URL this menu items will link to"), ) - objects = MenuItemManager() + objects: ClassVar[MenuItemManager] = MenuItemManager() def __str__(self) -> str: return self.text diff --git a/allianceauth/notifications/models.py b/allianceauth/notifications/models.py index dd77d0ff..f4108b8a 100644 --- a/allianceauth/notifications/models.py +++ b/allianceauth/notifications/models.py @@ -1,4 +1,5 @@ import logging +from typing import ClassVar from django.db import models from django.contrib.auth.models import User @@ -56,7 +57,7 @@ class Notification(models.Model): timestamp = models.DateTimeField(auto_now_add=True, db_index=True) viewed = models.BooleanField(default=False, db_index=True) - objects = NotificationManager() + objects: ClassVar[NotificationManager] = NotificationManager() def __str__(self) -> str: return f"{self.user}: {self.title}" diff --git a/allianceauth/services/modules/discord/models.py b/allianceauth/services/modules/discord/models.py index 1f9c084f..ec2b7d26 100644 --- a/allianceauth/services/modules/discord/models.py +++ b/allianceauth/services/modules/discord/models.py @@ -1,5 +1,5 @@ import logging -from typing import Optional +from typing import ClassVar, Optional from requests.exceptions import HTTPError @@ -59,7 +59,7 @@ class DiscordUser(models.Model): help_text='Date & time this service account was activated' ) - objects = DiscordUserManager() + objects: ClassVar[DiscordUserManager] = DiscordUserManager() class Meta: permissions = ( diff --git a/allianceauth/services/modules/mumble/models.py b/allianceauth/services/modules/mumble/models.py index 8c7d0ead..94dfb876 100644 --- a/allianceauth/services/modules/mumble/models.py +++ b/allianceauth/services/modules/mumble/models.py @@ -1,5 +1,6 @@ import random import string +from typing import ClassVar from passlib.hash import bcrypt_sha256 from django.db import models @@ -116,7 +117,7 @@ class MumbleUser(AbstractServiceModel): help_text="Timestamp of the users Last Disconnection to Mumble" ) - objects = MumbleManager() + objects: ClassVar[MumbleManager] = MumbleManager() def __str__(self): return self.username