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