aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2025-03-01 18:09:53 +0100
committerDaniel Schadt <kingdread@gmx.de>2025-03-01 18:09:53 +0100
commit4dc73b2e0cf5defaee3f89522d900362e8d44fbf (patch)
treefb25a1d5e280408949af74a0e9c0905a8dc61d9a
parent42b4a8ec723e0e28967a76685868370d39442d5c (diff)
downloadfietsboek-4dc73b2e0cf5defaee3f89522d900362e8d44fbf.tar.gz
fietsboek-4dc73b2e0cf5defaee3f89522d900362e8d44fbf.tar.bz2
fietsboek-4dc73b2e0cf5defaee3f89522d900362e8d44fbf.zip
replace typing.List/Set/Dict
The built-in types set/list/dict support type arguments since 3.9, so we should just use them.
-rw-r--r--fietsboek/actions.py8
-rw-r--r--fietsboek/config.py2
-rw-r--r--fietsboek/data.py4
-rw-r--r--fietsboek/models/track.py16
-rw-r--r--fietsboek/pages.py12
-rw-r--r--fietsboek/summaries.py16
-rw-r--r--fietsboek/util.py4
-rw-r--r--fietsboek/views/tileproxy.py6
8 files changed, 34 insertions, 34 deletions
diff --git a/fietsboek/actions.py b/fietsboek/actions.py
index 33b96b3..f5cd8e8 100644
--- a/fietsboek/actions.py
+++ b/fietsboek/actions.py
@@ -9,7 +9,7 @@ the test functions.
import datetime
import logging
import re
-from typing import List, Optional
+from typing import Optional
import brotli
import gpxpy
@@ -37,9 +37,9 @@ def add_track(
visibility: Visibility,
track_type: TrackType,
description: str,
- badges: List[models.Badge],
- tagged_people: List[models.User],
- tags: List[str],
+ badges: list[models.Badge],
+ tagged_people: list[models.User],
+ tags: list[str],
transformers: list[mod_transformers.Transformer],
gpx_data: bytes,
) -> models.Track:
diff --git a/fietsboek/config.py b/fietsboek/config.py
index 5e52005..b12bf9b 100644
--- a/fietsboek/config.py
+++ b/fietsboek/config.py
@@ -199,7 +199,7 @@ class Config(BaseModel):
disable_tile_proxy: bool = Field(False, alias="fietsboek.tile_proxy.disable")
"""Disable the tile proxy."""
- tile_layers: typing.List[TileLayerConfig] = []
+ tile_layers: list[TileLayerConfig] = []
"""Tile layers."""
hittekaart_bin: str = Field("", alias="hittekaart.bin")
diff --git a/fietsboek/data.py b/fietsboek/data.py
index 1e04c86..294df30 100644
--- a/fietsboek/data.py
+++ b/fietsboek/data.py
@@ -15,7 +15,7 @@ import shutil
import string
import uuid
from pathlib import Path
-from typing import BinaryIO, List, Literal, Optional
+from typing import BinaryIO, Literal, Optional
import brotli
import gpxpy
@@ -345,7 +345,7 @@ class TrackDataDir:
"""
return self.path / "track.bck.gpx.br"
- def images(self) -> List[str]:
+ def images(self) -> list[str]:
"""Returns a list of images that belong to the track.
:param track_id: Numerical ID of the track.
diff --git a/fietsboek/models/track.py b/fietsboek/models/track.py
index 7606529..afa7772 100644
--- a/fietsboek/models/track.py
+++ b/fietsboek/models/track.py
@@ -17,7 +17,7 @@ import enum
import gzip
import logging
from itertools import chain
-from typing import TYPE_CHECKING, List, Optional, Set, Union
+from typing import TYPE_CHECKING, Optional, Union
import gpxpy
from babel.numbers import format_decimal
@@ -673,36 +673,36 @@ class TrackWithMetadata:
return self.track.owner
@property
- def tagged_people(self) -> List["models.User"]:
+ def tagged_people(self) -> list["models.User"]:
"""Tagged people of the underlying track."""
return self.track.tagged_people[:]
@property
- def badges(self) -> List["models.Badge"]:
+ def badges(self) -> list["models.Badge"]:
"""Badges of the underlying track."""
return self.track.badges[:]
@property
- def tags(self) -> List["models.Tag"]:
+ def tags(self) -> list["models.Tag"]:
"""Tags of the underlying track."""
return self.track.tags[:]
@property
- def comments(self) -> List["models.Comment"]:
+ def comments(self) -> list["models.Comment"]:
"""Comments of the underlying track."""
return self.track.comments[:]
@property
- def images(self) -> List["models.ImageMetadata"]:
+ def images(self) -> list["models.ImageMetadata"]:
"""Images of the underlying track."""
return self.track.images[:]
@property
- def favourees(self) -> List["models.User"]:
+ def favourees(self) -> list["models.User"]:
"""People who have favoured this track."""
return self.track.favourees[:]
- def text_tags(self) -> Set[str]:
+ def text_tags(self) -> set[str]:
"""Returns a set of textual tags.
:return: The tags of the track, as a set of strings.
diff --git a/fietsboek/pages.py b/fietsboek/pages.py
index cb546b2..73d08cc 100644
--- a/fietsboek/pages.py
+++ b/fietsboek/pages.py
@@ -3,7 +3,7 @@
import enum
import re
from pathlib import Path
-from typing import List, Optional
+from typing import Optional
import markdown
from pyramid.request import Request
@@ -37,7 +37,7 @@ class Page:
:vartype link_name: str
:ivar locale_filter: An (optional) pattern that determines whether the page
should be shown to certain locales only.
- :vartype locale_filter: Optional[List[re.Pattern]]
+ :vartype locale_filter: Optional[list[re.Pattern]]
:ivar user_filter: A filter that determines if the page should be shown to
certain users only.
:vartype user_filter: UserFilter
@@ -51,7 +51,7 @@ class Page:
title: str,
content: str,
link_name: str,
- locale_filter: Optional[List[re.Pattern]] = None,
+ locale_filter: Optional[list[re.Pattern]] = None,
user_filter: UserFilter = UserFilter.EVERYONE,
menu_index: int = 0,
):
@@ -110,7 +110,7 @@ class Page:
if not slug:
raise PageException("Missing `slug`")
- locale_filter: Optional[List[re.Pattern]]
+ locale_filter: Optional[list[re.Pattern]]
try:
locale_filter = list(map(re.compile, parser.Meta.get("locale", []))) # type: ignore
except re.error as exc:
@@ -192,7 +192,7 @@ class Pages:
return page
return None
- def pre_menu_items(self, request: Request) -> List[Page]:
+ def pre_menu_items(self, request: Request) -> list[Page]:
"""Return all items that should appear before Fietsboek's main menu.
:param request: The request to filter against.
@@ -200,7 +200,7 @@ class Pages:
"""
return [page for page in self.collection if page.menu_index < 0 and page.matches(request)]
- def post_menu_items(self, request: Request) -> List[Page]:
+ def post_menu_items(self, request: Request) -> list[Page]:
"""Return all items that should appear after Fietsboek's main menu.
:param request: The request to filter against.
diff --git a/fietsboek/summaries.py b/fietsboek/summaries.py
index a0bd7d0..e0544ce 100644
--- a/fietsboek/summaries.py
+++ b/fietsboek/summaries.py
@@ -2,7 +2,7 @@
import datetime
from dataclasses import dataclass
-from typing import Dict, List, Optional
+from typing import Optional
from . import util
from .models.track import TrackWithMetadata
@@ -19,7 +19,7 @@ class Summary:
"""
def __init__(self, ascending: bool = True):
- self.years: Dict[int, YearSummary] = {}
+ self.years: dict[int, YearSummary] = {}
self.ascending = ascending
def __iter__(self):
@@ -30,7 +30,7 @@ class Summary:
def __len__(self) -> int:
return len(self.all_tracks())
- def all_tracks(self) -> List[TrackWithMetadata]:
+ def all_tracks(self) -> list[TrackWithMetadata]:
"""Returns all tracks of the summary.
:return: All tracks.
@@ -79,7 +79,7 @@ class YearSummary:
def __init__(self, year: int, ascending: bool = True):
self.year: int = year
- self.months: Dict[int, MonthSummary] = {}
+ self.months: dict[int, MonthSummary] = {}
self.ascending = ascending
def __iter__(self):
@@ -90,7 +90,7 @@ class YearSummary:
def __len__(self) -> int:
return len(self.all_tracks())
- def all_tracks(self) -> List[TrackWithMetadata]:
+ def all_tracks(self) -> list[TrackWithMetadata]:
"""Returns all tracks of the summary.
:return: All tracks.
@@ -135,7 +135,7 @@ class MonthSummary:
def __init__(self, month):
self.month: int = month
- self.tracks: List[TrackWithMetadata] = []
+ self.tracks: list[TrackWithMetadata] = []
def __iter__(self):
items = self.tracks[:]
@@ -147,7 +147,7 @@ class MonthSummary:
def __len__(self) -> int:
return len(self.all_tracks())
- def all_tracks(self) -> List[TrackWithMetadata]:
+ def all_tracks(self) -> list[TrackWithMetadata]:
"""Returns all tracks of the summary.
:return: All tracks.
@@ -224,7 +224,7 @@ class CumulativeStats:
"""The track with the shortest time."""
@classmethod
- def from_tracks(cls, tracks: List[TrackWithMetadata]) -> "CumulativeStats":
+ def from_tracks(cls, tracks: list[TrackWithMetadata]) -> "CumulativeStats":
"""Create a new stats collection from this list of tracks.
:param tracks: List of tracks.
diff --git a/fietsboek/util.py b/fietsboek/util.py
index 47e7b7f..bcf1fb7 100644
--- a/fietsboek/util.py
+++ b/fietsboek/util.py
@@ -7,7 +7,7 @@ import os
import re
import secrets
import unicodedata
-from typing import List, Optional, TypeVar, Union
+from typing import Optional, TypeVar, Union
import babel
import gpxpy
@@ -347,7 +347,7 @@ def _locale_packages(locale_packages: Optional[list[str]] = None) -> list[str]:
def read_localized_resource(
locale_name: str,
path: str,
- locale_packages: Optional[List[str]] = None,
+ locale_packages: Optional[list[str]] = None,
raise_on_error: bool = False,
) -> str:
"""Reads a localized resource.
diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py
index e129ae1..7478095 100644
--- a/fietsboek/views/tileproxy.py
+++ b/fietsboek/views/tileproxy.py
@@ -11,7 +11,7 @@ import datetime
import logging
import threading
from itertools import chain
-from typing import List, Optional
+from typing import Optional
from urllib.parse import quote
import requests
@@ -369,7 +369,7 @@ def tile_proxy(request):
return Response(resp.content, content_type=resp.headers.get("Content-type", content_type))
-def sources_for(request: Request) -> List[TileLayerConfig]:
+def sources_for(request: Request) -> list[TileLayerConfig]:
"""Returns all eligible tile sources for the given request.
:param request: The Pyramid request.
@@ -389,7 +389,7 @@ def sources_for(request: Request) -> List[TileLayerConfig]:
]
-def extract_tile_layers(config: Config) -> List[TileLayerConfig]:
+def extract_tile_layers(config: Config) -> list[TileLayerConfig]:
"""Extract all defined tile layers from the settings.
:param config: The fietsboek config.