From 53c3606422651bf22371a7e089c7b4c917977ab7 Mon Sep 17 00:00:00 2001 From: JaffarA Date: Tue, 8 Oct 2024 11:18:43 +0100 Subject: [PATCH] types: fix mypy type errors --- demos/dashboard/demo/kitchensink/charts.py | 10 +++++----- demos/dashboard/demo/kitchensink/dashboards.py | 2 +- demos/dashboard/demo/kitchensink/views.py | 2 +- demos/dashboard/demo/settings.py | 2 +- demos/dashboard/demo/vehicle/data.py | 4 ++-- .../vehicle/management/commands/sample_vehicle_data.py | 2 +- demos/dashboard/demo/vehicle/models.py | 2 +- docs/docs_dj_settings.py | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/demos/dashboard/demo/kitchensink/charts.py b/demos/dashboard/demo/kitchensink/charts.py index c5557004..82c4acb5 100644 --- a/demos/dashboard/demo/kitchensink/charts.py +++ b/demos/dashboard/demo/kitchensink/charts.py @@ -14,13 +14,13 @@ class ScatterChartSerializer(ChartSerializer): color: Optional[str] = None mode: Optional[str] = "markers" - def get_x(self, df) -> str: + def get_x(self, df) -> str | None: return self.x - def get_y(self, df) -> str: + def get_y(self, df) -> str | None: return self.y - def get_size(self, df) -> str: + def get_size(self, df) -> str | None: return self.size def to_fig(self, df) -> go.Figure: @@ -42,10 +42,10 @@ class BarChartSerializer(ChartSerializer): color: Optional[str] = None barmode: Optional[str] = "group" - def get_x(self, df) -> str: + def get_x(self, df) -> str | None: return self.x - def get_y(self, df) -> str: + def get_y(self, df) -> str | None: return self.y def to_fig(self, df) -> go.Figure: diff --git a/demos/dashboard/demo/kitchensink/dashboards.py b/demos/dashboard/demo/kitchensink/dashboards.py index ec2ba18c..c691dafd 100644 --- a/demos/dashboard/demo/kitchensink/dashboards.py +++ b/demos/dashboard/demo/kitchensink/dashboards.py @@ -104,7 +104,7 @@ class DemoDashboard(Dashboard): grid_css_classes=Grid.TWO.value, ) stat_two = Stat( - value=StatData(text="88%", sub_text="decrease", change_by="12%"), + value=StatData(text="88%", sub_text="decrease", change_by_text="12%"), icon="", grid_css_classes=Grid.TWO.value, ) diff --git a/demos/dashboard/demo/kitchensink/views.py b/demos/dashboard/demo/kitchensink/views.py index 0606b4bf..b484ad09 100644 --- a/demos/dashboard/demo/kitchensink/views.py +++ b/demos/dashboard/demo/kitchensink/views.py @@ -66,7 +66,7 @@ def as_view(cls, **initkwargs): Needed prior to 4.1 for CBV """ view = super().as_view(**initkwargs) - view._is_coroutine = asyncio.coroutines._is_coroutine + view._is_coroutine = asyncio.coroutines._is_coroutine # type: ignore return view async def get(self, request: HttpRequest, *args, **kwargs): diff --git a/demos/dashboard/demo/settings.py b/demos/dashboard/demo/settings.py index 8b1d0fce..3c52e2d2 100644 --- a/demos/dashboard/demo/settings.py +++ b/demos/dashboard/demo/settings.py @@ -267,7 +267,7 @@ def CACHES(self): "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": f"redis://{self.REDIS_HOST}:{self.REDIS_PORT}/1", - "KEY_PREFIX": f"{self.PROJECT_ENVIRONMENT_SLUG}_", + "KEY_PREFIX": f"{self.PROJECT_ENVIRONMENT_SLUG}_", # type: ignore "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "PARSER_CLASS": "redis.connection.HiredisParser", diff --git a/demos/dashboard/demo/vehicle/data.py b/demos/dashboard/demo/vehicle/data.py index c32768e9..d7115577 100644 --- a/demos/dashboard/demo/vehicle/data.py +++ b/demos/dashboard/demo/vehicle/data.py @@ -74,7 +74,7 @@ def fetch_service_count(request, **kwargs): @staticmethod def fetch_vehicle_details(*args, **kwargs): - vehicle = kwargs.get("object") + vehicle: Vehicle = kwargs.get("object") # type: ignore return StatData( text=dict_to_table( { @@ -92,7 +92,7 @@ def fetch_vehicle_details(*args, **kwargs): @staticmethod def fetch_last_route(*args, **kwargs): - vehicle = kwargs.get("object") + vehicle: Vehicle = kwargs.get("object") # type: ignore locations = vehicle.get_locations_for_last_job() lat_coords = [location.lat for location in locations] lon_coords = [location.lon for location in locations] diff --git a/demos/dashboard/demo/vehicle/management/commands/sample_vehicle_data.py b/demos/dashboard/demo/vehicle/management/commands/sample_vehicle_data.py index 5dae7efe..2f5a79bf 100644 --- a/demos/dashboard/demo/vehicle/management/commands/sample_vehicle_data.py +++ b/demos/dashboard/demo/vehicle/management/commands/sample_vehicle_data.py @@ -10,7 +10,7 @@ class Command(BaseCommand): def handle(self, *args, **options): if Data.objects.count() == 0: - vehicles = baker.make("Vehicle", _quantity=5, _bulk_create=True) + vehicles = baker.make("Vehicle", _quantity=5, _bulk_create=True) # type: ignore location_param, _ = Parameter.objects.get_or_create( name="Current Location", cast_type=Parameter.CastType.COORDINATE ) diff --git a/demos/dashboard/demo/vehicle/models.py b/demos/dashboard/demo/vehicle/models.py index d505a11c..cb240095 100644 --- a/demos/dashboard/demo/vehicle/models.py +++ b/demos/dashboard/demo/vehicle/models.py @@ -115,4 +115,4 @@ def convert(self): Coord = namedtuple("Coord", ["lon", "lat"]) return Coord(lon=lon, lat=lat) elif self.parameter.cast_type == "datetime": - return datetime.strptime(self.value, self.DT_FORMAT) + return datetime.strptime(self.value, self.DT_FORMAT) # type: ignore diff --git a/docs/docs_dj_settings.py b/docs/docs_dj_settings.py index 490207b0..78ad1d38 100644 --- a/docs/docs_dj_settings.py +++ b/docs/docs_dj_settings.py @@ -6,7 +6,7 @@ PROJECT_NAME = "docs" -ADMINS = [] +ADMINS = [] # type: ignore SECRET_KEY = "somesecretvalue"