mirror of
https://github.com/kjanat/livegraphs-django.git
synced 2026-02-13 17:55:44 +01:00
feat: add ty type checking support and fix type issues
- Add ty.toml configuration with Django project root - Add py.typed marker for type checking - Fix type issues across codebase: - Add type ignore comments for redis.exceptions imports - Fix django.db.models.functions imports in utils - Fix getattr usage in accounts/forms - Remove unnecessary type annotations in dashboard/forms - Configure ty to exclude migrations and respect ignore files - All ty checks now pass (29 diagnostics -> 0)
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
# dashboard/forms.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django import forms
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
from .models import Dashboard, DataSource
|
||||
|
||||
|
||||
@@ -37,7 +44,9 @@ class DashboardForm(forms.ModelForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if self.company:
|
||||
self.fields["data_sources"].queryset = DataSource.objects.filter(company=self.company)
|
||||
# Access queryset on ModelMultipleChoiceField
|
||||
data_sources_field = self.fields["data_sources"] # type: ignore[assignment]
|
||||
data_sources_field.queryset = DataSource.objects.filter(company=self.company) # type: ignore[attr-defined]
|
||||
|
||||
def save(self, commit=True):
|
||||
instance = super().save(commit=False)
|
||||
|
||||
Reference in New Issue
Block a user