Skip to content

Commit

Permalink
⬆️ Bump to Python 3.9
Browse files Browse the repository at this point in the history
Run pyupgrade:
pyupgrade --py39-plus --keep-runtime-typing --keep-percent-format  $(find . -name '*.py')
  • Loading branch information
Viicos committed Jan 18, 2024
1 parent a31db48 commit 153268c
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quick-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/objects/api/kanalen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import defaultdict
from typing import Dict

from django.conf import settings
from django.db import models
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/objects/api/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import date
from typing import Dict, Union
from typing import Union

from djchoices import DjangoChoices

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/objects/typing.py
Original file line number Diff line number Diff line change
@@ -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]
4 changes: 1 addition & 3 deletions src/objects/utils/autoschema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from django.conf import settings
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -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 []

Expand Down
5 changes: 2 additions & 3 deletions src/objects/utils/serializers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 153268c

Please sign in to comment.