Add pre-commit
This commit is contained in:
parent
4c16d14e61
commit
927e20c9bb
5 changed files with 90 additions and 20 deletions
|
|
@ -149,7 +149,7 @@ def struct_time_to_datetime(struct_time: struct_time | None) -> datetime.datetim
|
|||
if struct_time == "Mon, 01 Jan 0001 00:00:00 +0000":
|
||||
return None
|
||||
|
||||
dt: datetime.datetime = datetime.datetime.fromtimestamp(mktime(struct_time), tz=datetime.timezone.utc)
|
||||
dt: datetime.datetime = datetime.datetime.fromtimestamp(mktime(struct_time), tz=datetime.UTC)
|
||||
if not dt:
|
||||
logger.error("Error converting struct_time to datetime: %s", struct_time)
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ class StaticViewSitemap(Sitemap):
|
|||
changefreq: str = "daily"
|
||||
priority: float = 0.5
|
||||
|
||||
def items(self: StaticViewSitemap) -> list[str]: # noqa: PLR6301
|
||||
def items(self: StaticViewSitemap) -> list[str]:
|
||||
"""Return all the items in the sitemap."""
|
||||
return ["feeds:index", "feeds:feeds", "feeds:domains"]
|
||||
|
||||
def location(self: StaticViewSitemap, item: str) -> str: # noqa: PLR6301
|
||||
def location(self: StaticViewSitemap, item: str) -> str:
|
||||
"""Return the location of the item."""
|
||||
return reverse(item)
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ class APIFeedView(View):
|
|||
class APIEntriesView(View):
|
||||
"""API Entries view."""
|
||||
|
||||
def get(self, request: HttpRequest) -> HttpResponse:
|
||||
def get(self: APIEntriesView, request: HttpRequest) -> HttpResponse:
|
||||
"""Get all entries with pagination."""
|
||||
# Retrieve all entries
|
||||
entries_list = Entry.objects.all()
|
||||
|
|
@ -390,7 +390,7 @@ class APIEntriesView(View):
|
|||
class APIEntryView(View):
|
||||
"""API Entry view."""
|
||||
|
||||
def get(self, request: HttpRequest, entry_id: int) -> HttpResponse: # noqa: ARG002
|
||||
def get(self: APIEntryView, request: HttpRequest, entry_id: int) -> HttpResponse: # noqa: ARG002
|
||||
"""Get a single entry."""
|
||||
entry = get_object_or_404(Entry, id=entry_id)
|
||||
return JsonResponse(model_to_dict(entry), safe=False)
|
||||
|
|
@ -399,7 +399,7 @@ class APIEntryView(View):
|
|||
class APIFeedEntriesView(View):
|
||||
"""API Feed Entries view."""
|
||||
|
||||
def get(self, request: HttpRequest, feed_id: int) -> HttpResponse:
|
||||
def get(self: APIFeedEntriesView, request: HttpRequest, feed_id: int) -> HttpResponse:
|
||||
"""Get all entries for a single feed with pagination."""
|
||||
# Retrieve all entries for a single feed
|
||||
entries_list = Entry.objects.filter(feed_id=feed_id)
|
||||
|
|
@ -451,7 +451,7 @@ class APIFeedEntriesView(View):
|
|||
class DomainsView(View):
|
||||
"""All domains."""
|
||||
|
||||
def get(self, request: HttpRequest) -> HttpResponse:
|
||||
def get(self: DomainsView, request: HttpRequest) -> HttpResponse:
|
||||
"""Load the domains page."""
|
||||
domains = Domain.objects.all()
|
||||
template = loader.get_template(template_name="domains.html")
|
||||
|
|
@ -469,7 +469,7 @@ class DomainsView(View):
|
|||
class DomainView(View):
|
||||
"""A single domain."""
|
||||
|
||||
def get(self, request: HttpRequest, domain_id: int) -> HttpResponse:
|
||||
def get(self: DomainView, request: HttpRequest, domain_id: int) -> HttpResponse:
|
||||
"""Load the domain page."""
|
||||
domain = get_object_or_404(Domain, id=domain_id)
|
||||
feeds = Feed.objects.filter(domain=domain).order_by("-created_at")[:100]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue