From 153268c61b48e0591822ceb1db2520b10403936a Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:41:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Bump=20to=20Python=203.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run pyupgrade: pyupgrade --py39-plus --keep-runtime-typing --keep-percent-format $(find . -name '*.py') --- .github/workflows/ci.yml | 2 +- .github/workflows/code-quality.yml | 4 ++-- .github/workflows/quick-start.yml | 2 +- Dockerfile | 4 ++-- src/objects/api/kanalen.py | 3 +-- src/objects/api/utils.py | 4 ++-- src/objects/typing.py | 6 +++--- src/objects/utils/autoschema.py | 4 +--- src/objects/utils/serializers.py | 5 ++--- 9 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b9ba024..df59bb08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - uses: actions/setup-node@v4 with: node-version: '12' diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index d6968e25..c7da6b2c 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - uses: isort/isort-action@v1 with: requirementsFiles: requirements/dev.txt @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - name: Install dependencies run: | pip install -r requirements/dev.txt diff --git a/.github/workflows/quick-start.yml b/.github/workflows/quick-start.yml index b7230775..e3cf9353 100644 --- a/.github/workflows/quick-start.yml +++ b/.github/workflows/quick-start.yml @@ -4,7 +4,7 @@ on: [push] jobs: run: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Download docker-compose file diff --git a/Dockerfile b/Dockerfile index 522e17b2..c3b17bc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1 - Compile needed python dependencies -FROM python:3.8-buster AS build +FROM python:3.9-buster AS build RUN apt-get update && apt-get install -y --no-install-recommends \ libpq-dev \ @@ -29,7 +29,7 @@ RUN npm run build # Stage 3 - Build docker image suitable for execution and deployment -FROM python:3.8-buster AS production +FROM python:3.9-buster AS production # Stage 3.1 - Set up the needed production dependencies # install all the dependencies for GeoDjango diff --git a/src/objects/api/kanalen.py b/src/objects/api/kanalen.py index fbb2462d..2ac56ccf 100644 --- a/src/objects/api/kanalen.py +++ b/src/objects/api/kanalen.py @@ -1,5 +1,4 @@ from collections import defaultdict -from typing import Dict from django.conf import settings from django.db import models @@ -21,7 +20,7 @@ def __init__( # check that we're refering to existing fields self.kenmerken = kenmerken or () - def get_kenmerken(self, obj: models.Model, data: Dict = None) -> Dict: + def get_kenmerken(self, obj: models.Model, data: dict = None) -> dict: data = data or {} return { kenmerk: data.get("type") or obj.object.object_type.url diff --git a/src/objects/api/utils.py b/src/objects/api/utils.py index b3c94da0..3b5330e4 100644 --- a/src/objects/api/utils.py +++ b/src/objects/api/utils.py @@ -1,5 +1,5 @@ from datetime import date -from typing import Dict, Union +from typing import Union from djchoices import DjangoChoices @@ -47,7 +47,7 @@ def display_choice_values_for_help_text(choices: DjangoChoices) -> str: return "\n".join(items) -def merge_patch(target: JSONValue, patch: JSONValue) -> Dict[str, JSONValue]: +def merge_patch(target: JSONValue, patch: JSONValue) -> dict[str, JSONValue]: """Merge two objects together recursively. This is inspired by https://datatracker.ietf.org/doc/html/rfc7396 - JSON Merge Patch, diff --git a/src/objects/typing.py b/src/objects/typing.py index 0264e153..1ffa8c1a 100644 --- a/src/objects/typing.py +++ b/src/objects/typing.py @@ -1,7 +1,7 @@ -from typing import Dict, List, Union +from typing import Union JSONPrimitive = Union[str, int, None, float, bool] -JSONValue = Union[JSONPrimitive, "JSONObject", List["JSONValue"]] +JSONValue = Union[JSONPrimitive, "JSONObject", list["JSONValue"]] -JSONObject = Dict[str, JSONValue] +JSONObject = dict[str, JSONValue] diff --git a/src/objects/utils/autoschema.py b/src/objects/utils/autoschema.py index 061dce39..bd12b493 100644 --- a/src/objects/utils/autoschema.py +++ b/src/objects/utils/autoschema.py @@ -1,5 +1,3 @@ -from typing import List - from django.conf import settings from django.utils.translation import gettext_lazy as _ @@ -119,7 +117,7 @@ def get_content_type_headers(self) -> list: ) ] - def get_fields_params(self) -> List[OpenApiParameter]: + def get_fields_params(self) -> list[OpenApiParameter]: if self.method != "GET": return [] diff --git a/src/objects/utils/serializers.py b/src/objects/utils/serializers.py index 7cf75a48..c7c2aaa1 100644 --- a/src/objects/utils/serializers.py +++ b/src/objects/utils/serializers.py @@ -1,6 +1,5 @@ import logging from collections import defaultdict -from typing import Dict, List, Tuple from glom import SKIP, GlomError, glom from rest_framework import fields, serializers @@ -35,13 +34,13 @@ def build_spec_field(spec, name, value, ui): spec[name] = value if ui else spec_val -def get_field_names(data: Dict[str, fields.Field]) -> List[str]: +def get_field_names(data: dict[str, fields.Field]) -> list[str]: """return list of names for all serializer fields. Supports nesting""" names_and_sources = get_field_names_and_sources(data) return [name for name, source in names_and_sources] -def get_field_names_and_sources(data: Dict[str, fields.Field]) -> List[Tuple[str, str]]: +def get_field_names_and_sources(data: dict[str, fields.Field]) -> list[tuple[str, str]]: """return list of (name, source) for all serializer fields. Supports nesting""" names_and_sources = [] for key, value in data.items():