mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 04:20:17 +02:00
typehints
This commit is contained in:
parent
876f1e48e7
commit
75d67aa1b1
@ -25,7 +25,7 @@ exclude: |
|
|||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.9.9
|
rev: v0.11.0
|
||||||
hooks:
|
hooks:
|
||||||
# Run the linter, and only the linter
|
# Run the linter, and only the linter
|
||||||
- id: ruff
|
- id: ruff
|
||||||
@ -59,7 +59,7 @@ repos:
|
|||||||
- id: detect-private-key
|
- id: detect-private-key
|
||||||
- id: check-case-conflict
|
- id: check-case-conflict
|
||||||
# Python checks
|
# Python checks
|
||||||
# - id: check-docstring-first
|
#
|
||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
# - id: requirements-txt-fixer
|
# - id: requirements-txt-fixer
|
||||||
- id: fix-encoding-pragma
|
- id: fix-encoding-pragma
|
||||||
@ -97,6 +97,6 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: tox-ini-fmt
|
- id: tox-ini-fmt
|
||||||
- repo: https://github.com/abravalheri/validate-pyproject
|
- repo: https://github.com/abravalheri/validate-pyproject
|
||||||
rev: v0.23
|
rev: v0.24
|
||||||
hooks:
|
hooks:
|
||||||
- id: validate-pyproject
|
- id: validate-pyproject
|
||||||
|
@ -32,7 +32,7 @@ class State(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-priority']
|
ordering = ['-priority']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def available_to_character(self, character):
|
def available_to_character(self, character):
|
||||||
@ -153,7 +153,7 @@ class CharacterOwnership(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
default_permissions = ('change', 'delete')
|
default_permissions = ('change', 'delete')
|
||||||
ordering = ['user', 'character__character_name']
|
ordering = ['user', 'character__character_name']
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"{self.user}: {self.character}"
|
return f"{self.user}: {self.character}"
|
||||||
|
|
||||||
|
|
||||||
@ -166,5 +166,5 @@ class OwnershipRecord(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-created']
|
ordering = ['-created']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"{self.user}: {self.character} on {self.created}"
|
return f"{self.user}: {self.character} on {self.created}"
|
||||||
|
@ -45,7 +45,7 @@ class CorpStats(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"{self.__class__.__name__} for {self.corp}"
|
return f"{self.__class__.__name__} for {self.corp}"
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
@ -154,7 +154,7 @@ class CorpMember(models.Model):
|
|||||||
unique_together = ('corpstats', 'character_id')
|
unique_together = ('corpstats', 'character_id')
|
||||||
ordering = ['character_name']
|
ordering = ['character_name']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.character_name
|
return self.character_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -81,7 +81,7 @@ class AutogroupsConfig(models.Model):
|
|||||||
|
|
||||||
objects = AutogroupsConfigManager()
|
objects = AutogroupsConfigManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return 'States: ' + (' '.join(list(self.states.all().values_list('name', flat=True))) if self.pk else str(None))
|
return 'States: ' + (' '.join(list(self.states.all().values_list('name', flat=True))) if self.pk else str(None))
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -235,7 +235,7 @@ class ManagedGroup(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"Managed Group: {self.group.name}"
|
return f"Managed Group: {self.group.name}"
|
||||||
|
|
||||||
class ManagedCorpGroup(ManagedGroup):
|
class ManagedCorpGroup(ManagedGroup):
|
||||||
|
@ -32,7 +32,7 @@ class EveFactionInfo(models.Model):
|
|||||||
|
|
||||||
provider = providers.provider
|
provider = providers.provider
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.faction_name
|
return self.faction_name
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -80,7 +80,7 @@ class EveAllianceInfo(models.Model):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
indexes = [models.Index(fields=['executor_corp_id',])]
|
indexes = [models.Index(fields=['executor_corp_id',])]
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.alliance_name
|
return self.alliance_name
|
||||||
def populate_alliance(self):
|
def populate_alliance(self):
|
||||||
alliance = self.provider.get_alliance(self.alliance_id)
|
alliance = self.provider.get_alliance(self.alliance_id)
|
||||||
@ -152,7 +152,7 @@ class EveCorporationInfo(models.Model):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
indexes = [models.Index(fields=['ceo_id',]),]
|
indexes = [models.Index(fields=['ceo_id',]),]
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.corporation_name
|
return self.corporation_name
|
||||||
def update_corporation(self, corp: providers.Corporation = None):
|
def update_corporation(self, corp: providers.Corporation = None):
|
||||||
if corp is None:
|
if corp is None:
|
||||||
@ -226,7 +226,7 @@ class EveCharacter(models.Model):
|
|||||||
models.Index(fields=['faction_id',]),
|
models.Index(fields=['faction_id',]),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.character_name
|
return self.character_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -36,7 +36,7 @@ class ObjectNotFound(Exception):
|
|||||||
self.id = obj_id
|
self.id = obj_id
|
||||||
self.type = type_name
|
self.type = type_name
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f'{self.type} with ID {self.id} not found.'
|
return f'{self.type} with ID {self.id} not found.'
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class Entity:
|
|||||||
self.id = id
|
self.id = id
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -206,7 +206,7 @@ class EveSwaggerProvider(EveProvider):
|
|||||||
)
|
)
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return 'esi'
|
return 'esi'
|
||||||
|
|
||||||
def get_alliance(self, alliance_id: int) -> Alliance:
|
def get_alliance(self, alliance_id: int) -> Alliance:
|
||||||
|
@ -13,7 +13,7 @@ class BravadoResponseStub:
|
|||||||
self.headers = headers if headers else {}
|
self.headers = headers if headers else {}
|
||||||
self.raw_bytes = raw_bytes
|
self.raw_bytes = raw_bytes
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"{self.status_code} {self.reason}"
|
return f"{self.status_code} {self.reason}"
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class Fatlink(models.Model):
|
|||||||
hash = models.CharField(max_length=254, unique=True)
|
hash = models.CharField(max_length=254, unique=True)
|
||||||
creator = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user))
|
creator = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.fleet
|
return self.fleet
|
||||||
|
|
||||||
|
|
||||||
@ -28,5 +28,5 @@ class Fat(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
unique_together = (('character', 'fatlink'),)
|
unique_together = (('character', 'fatlink'),)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"Fat-link for {self.character.character_name}"
|
return f"Fat-link for {self.character.character_name}"
|
||||||
|
@ -15,7 +15,7 @@ class GroupRequest(models.Model):
|
|||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
group = models.ForeignKey(Group, on_delete=models.CASCADE)
|
group = models.ForeignKey(Group, on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.user.username + ":" + self.group.name
|
return self.user.username + ":" + self.group.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -50,7 +50,7 @@ class RequestLog(models.Model):
|
|||||||
request_actor = models.ForeignKey(User, on_delete=models.CASCADE)
|
request_actor = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
date = models.DateTimeField(auto_now_add=True)
|
date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
def requestor(self):
|
def requestor(self):
|
||||||
@ -179,7 +179,7 @@ class AuthGroup(models.Model):
|
|||||||
)
|
)
|
||||||
default_permissions = ()
|
default_permissions = ()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.group.name
|
return self.group.name
|
||||||
|
|
||||||
def group_request_approvers(self) -> set[User]:
|
def group_request_approvers(self) -> set[User]:
|
||||||
|
@ -13,7 +13,7 @@ class ApplicationQuestion(models.Model):
|
|||||||
help_text = models.CharField(max_length=254, blank=True)
|
help_text = models.CharField(max_length=254, blank=True)
|
||||||
multi_select = models.BooleanField(default=False)
|
multi_select = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return "Question: " + self.title
|
return "Question: " + self.title
|
||||||
|
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ class ApplicationChoice(models.Model):
|
|||||||
question = models.ForeignKey(ApplicationQuestion,on_delete=models.CASCADE,related_name="choices")
|
question = models.ForeignKey(ApplicationQuestion,on_delete=models.CASCADE,related_name="choices")
|
||||||
choice_text = models.CharField(max_length=200, verbose_name='Choice')
|
choice_text = models.CharField(max_length=200, verbose_name='Choice')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.choice_text
|
return self.choice_text
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class ApplicationForm(models.Model):
|
|||||||
questions = SortedManyToManyField(ApplicationQuestion)
|
questions = SortedManyToManyField(ApplicationQuestion)
|
||||||
corp = models.OneToOneField(EveCorporationInfo, on_delete=models.CASCADE)
|
corp = models.OneToOneField(EveCorporationInfo, on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return str(self.corp)
|
return str(self.corp)
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class Application(models.Model):
|
|||||||
('view_apis', 'Can view applicant APIs'),)
|
('view_apis', 'Can view applicant APIs'),)
|
||||||
unique_together = ('form', 'user')
|
unique_together = ('form', 'user')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return str(self.user) + " Application To " + str(self.form)
|
return str(self.user) + " Application To " + str(self.form)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -77,7 +77,7 @@ class ApplicationResponse(models.Model):
|
|||||||
answer = models.TextField()
|
answer = models.TextField()
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('question', 'application')
|
unique_together = ('question', 'application')
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return str(self.application) + " Answer To " + str(self.question)
|
return str(self.application) + " Answer To " + str(self.question)
|
||||||
|
|
||||||
|
|
||||||
@ -89,5 +89,5 @@ class ApplicationComment(models.Model):
|
|||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return str(self.user) + " comment on " + str(self.application)
|
return str(self.user) + " comment on " + str(self.application)
|
||||||
|
@ -19,7 +19,7 @@ class OpTimerType(models.Model):
|
|||||||
ordering = ['type']
|
ordering = ['type']
|
||||||
default_permissions = ()
|
default_permissions = ()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
class OpTimer(models.Model):
|
class OpTimer(models.Model):
|
||||||
@ -39,5 +39,5 @@ class OpTimer(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['start']
|
ordering = ['start']
|
||||||
default_permissions = ()
|
default_permissions = ()
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.operation_name
|
return self.operation_name
|
||||||
|
@ -16,5 +16,5 @@ class DiscourseUser(models.Model):
|
|||||||
("access_discourse", "Can access the Discourse service"),
|
("access_discourse", "Can access the Discourse service"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
@ -18,7 +18,7 @@ class SrpFleetMain(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
permissions = (('access_srp', 'Can access SRP module'),)
|
permissions = (('access_srp', 'Can access SRP module'),)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.fleet_name
|
return self.fleet_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -46,5 +46,5 @@ class SrpUserRequest(models.Model):
|
|||||||
srp_ship_name = models.CharField(max_length=254, default="")
|
srp_ship_name = models.CharField(max_length=254, default="")
|
||||||
post_time = models.DateTimeField(default=timezone.now)
|
post_time = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return self.character.character_name + ' SRP request for ' + self.srp_ship_name
|
return self.character.character_name + ' SRP request for ' + self.srp_ship_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user