diff --git a/django/thunderstore/api/cyberstorm/tests/test_community_detail.py b/django/thunderstore/api/cyberstorm/tests/test_community_detail.py index c9fb2d9f6..e36e44541 100644 --- a/django/thunderstore/api/cyberstorm/tests/test_community_detail.py +++ b/django/thunderstore/api/cyberstorm/tests/test_community_detail.py @@ -7,16 +7,20 @@ @pytest.mark.django_db def test_api_cyberstorm_community_detail_success( - client: APIClient, community_site: CommunitySite + client: APIClient, + community_site: CommunitySite, ): PackageListingFactory( - community_=community_site.community, package_version_kwargs={"downloads": 0} + community_=community_site.community, + package_version_kwargs={"downloads": 0}, ) PackageListingFactory( - community_=community_site.community, package_version_kwargs={"downloads": 23} + community_=community_site.community, + package_version_kwargs={"downloads": 23}, ) PackageListingFactory( - community_=community_site.community, package_version_kwargs={"downloads": 42} + community_=community_site.community, + package_version_kwargs={"downloads": 42}, ) CommunityAggregatedFields.create_missing() community_site.community.refresh_from_db() @@ -42,10 +46,11 @@ def test_api_cyberstorm_community_detail_success( @pytest.mark.django_db def test_api_cyberstorm_community_detail_failure( - client: APIClient, community_site: CommunitySite + client: APIClient, + community_site: CommunitySite, ): response = client.get( - f"/api/cyberstorm/community/bad/", + "/api/cyberstorm/community/bad/", HTTP_HOST=community_site.site.domain, ) assert response.status_code == 404 diff --git a/django/thunderstore/api/cyberstorm/tests/test_community_list.py b/django/thunderstore/api/cyberstorm/tests/test_community_list.py index 9c9d31d90..6f035250d 100644 --- a/django/thunderstore/api/cyberstorm/tests/test_community_list.py +++ b/django/thunderstore/api/cyberstorm/tests/test_community_list.py @@ -14,7 +14,9 @@ @pytest.mark.django_db def test_api_cyberstorm_community_list_get_success( - client: APIClient, community_site: CommunitySite, dummy_image + client: APIClient, + community_site: CommunitySite, + dummy_image, ): community1 = CommunityFactory( aggregated_fields=CommunityAggregatedFields.objects.create(), @@ -24,15 +26,17 @@ def test_api_cyberstorm_community_list_get_success( background_image=dummy_image, ) - for x in range(10): + for _ in range(10): PackageListingFactory( - community_=community1, package_version_kwargs={"downloads": 10} + community_=community1, + package_version_kwargs={"downloads": 10}, ) PackageListingFactory( - community_=community2, package_version_kwargs={"downloads": 5} + community_=community2, + package_version_kwargs={"downloads": 5}, ) - for x in range(10): + for _ in range(10): PackageListingFactory( community_=community1, package_version_kwargs={"downloads": 3}, @@ -82,12 +86,13 @@ def test_api_cyberstorm_community_list_only_listed_communities_are_returned( assert ( len(data["results"]) == 2 ) # There is the test community, that is created in api_client - assert not (non_listed.identifier in [c["identifier"] for c in data["results"]]) + assert not (non_listed.identifier in (c["identifier"] for c in data["results"])) @pytest.mark.django_db def test_api_cyberstorm_community_list_are_ordered_by_identifier_by_default( - api_client: APIClient, community + api_client: APIClient, + community, ) -> None: a = CommunityFactory(identifier="a") b = CommunityFactory(identifier="b") @@ -104,7 +109,7 @@ def test_api_cyberstorm_community_list_pagination( api_client: APIClient, ) -> None: - for i in range(25): + for _ in range(25): CommunityFactory() total_count = Community.objects.count() @@ -131,7 +136,8 @@ def test_api_cyberstorm_community_list_pagination( def __assert_communities( - data: Dict, communities: Union[Community, List[Community]] + data: Dict, + communities: Union[Community, List[Community]], ) -> None: """ Check that expected communities are found in results diff --git a/django/thunderstore/community/context_processors.py b/django/thunderstore/community/context_processors.py index 322b8ed38..1b63f9a0d 100644 --- a/django/thunderstore/community/context_processors.py +++ b/django/thunderstore/community/context_processors.py @@ -1,7 +1,6 @@ from typing import Optional from django.conf import settings -from django.db.models import Count from django.templatetags.static import static from thunderstore.community.models.community import Community @@ -28,7 +27,7 @@ def get_community_context(community: Optional[Community]): "site_icon": url, "site_icon_width": community.icon_width, "site_icon_height": community.icon_height, - } + }, ) else: result.update( @@ -36,7 +35,7 @@ def get_community_context(community: Optional[Community]): "site_icon": f"{settings.PROTOCOL}{settings.PRIMARY_HOST}{static('icon.png')}", "site_icon_width": "1000", "site_icon_height": "1000", - } + }, ) return result else: @@ -62,6 +61,7 @@ def community_site(request): def selectable_communities(request): return { "selectable_communities": Community.objects.listed().order_by( - "-aggregated_fields__package_count", "datetime_created" - ) + "-aggregated_fields__package_count", + "datetime_created", + ), } diff --git a/django/thunderstore/community/models/community.py b/django/thunderstore/community/models/community.py index 188aa2dd7..adc8d9520 100644 --- a/django/thunderstore/community/models/community.py +++ b/django/thunderstore/community/models/community.py @@ -103,7 +103,7 @@ def save(self, *args, **kwargs): + ( "icon_width", "icon_height", - ) + ), ) if not self.background_image: self.background_image_width = 0 @@ -114,7 +114,7 @@ def save(self, *args, **kwargs): + ( "background_image_width", "background_image_height", - ) + ), ) return super().save(*args, **kwargs) diff --git a/django/thunderstore/community/tests/test_community.py b/django/thunderstore/community/tests/test_community.py index eeadd9ac4..cc34c4f24 100644 --- a/django/thunderstore/community/tests/test_community.py +++ b/django/thunderstore/community/tests/test_community.py @@ -111,9 +111,10 @@ def test_community_get_community_filepath(community: Community) -> None: @pytest.mark.django_db -@pytest.mark.parametrize("require_approval", (False, True)) +@pytest.mark.parametrize("require_approval", [False, True]) def test_community_valid_review_statuses( - community: Community, require_approval: bool + community: Community, + require_approval: bool, ) -> None: community.require_package_listing_approval = require_approval community.save() @@ -127,7 +128,7 @@ def test_community_valid_review_statuses( @pytest.mark.django_db -@pytest.mark.parametrize("has_site", (False, True)) +@pytest.mark.parametrize("has_site", [False, True]) def test_community_full_url( community: Community, has_site: bool, @@ -141,7 +142,7 @@ def test_community_full_url( @pytest.mark.django_db -@pytest.mark.parametrize("has_site", (False, True)) +@pytest.mark.parametrize("has_site", [False, True]) def test_community_should_use_old_urls( community: Community, has_site: bool, diff --git a/django/thunderstore/core/tests/test_celery.py b/django/thunderstore/core/tests/test_celery.py index d93aa96d7..27df3d102 100644 --- a/django/thunderstore/core/tests/test_celery.py +++ b/django/thunderstore/core/tests/test_celery.py @@ -102,7 +102,8 @@ def test_celery_task_removal_handled_correctly(celery_app): @pytest.mark.django_db @override_settings(CELERY_ALWAYS_EAGER=True) def test_celery_post( - celery_app: celery.Celery, http_server: Generator[str, None, None] + celery_app: celery.Celery, + http_server: Generator[str, None, None], ): celery_response = celery_post.delay("http://localhost:8888") assert celery_response.state == "SUCCESS" diff --git a/django/thunderstore/frontend/api/experimental/views/frontpage.py b/django/thunderstore/frontend/api/experimental/views/frontpage.py index d0da2391c..d8dc46e15 100644 --- a/django/thunderstore/frontend/api/experimental/views/frontpage.py +++ b/django/thunderstore/frontend/api/experimental/views/frontpage.py @@ -37,7 +37,8 @@ def get_queryset(self) -> QuerySet[Community]: ) def serialize_results( - self, queryset: QuerySet[Community] + self, + queryset: QuerySet[Community], ) -> FrontPageContentSerializer: communities = [ {