From a82a5ee193629b32c5c7c0c05e21af20efd892eb Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Fri, 24 May 2024 00:23:20 +0200 Subject: [PATCH] Use explicit typevars to have 3.11 compatibility --- src/parliamentarch/_util.py | 5 +++-- src/parliamentarch/svg.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/parliamentarch/_util.py b/src/parliamentarch/_util.py index 33144d7..90b25db 100644 --- a/src/parliamentarch/_util.py +++ b/src/parliamentarch/_util.py @@ -1,7 +1,7 @@ from collections.abc import Callable, Container, Sequence from inspect import Parameter, signature from io import TextIOBase -from typing import NamedTuple +from typing import NamedTuple, TypeVar class FactoryDict(dict): def __init__(self, default_factory, *args, **kwargs): @@ -59,7 +59,8 @@ def write_func(file, /, *args, **kwargs): write_func.__name__ = get_func.__name__.replace("get_", "write_") return write_func -def filter_kwargs[V]( +V = TypeVar("V") # PY3.11 compat +def filter_kwargs( *sets: Container[str], **kwargs: V, ) -> list[dict[str, V]]: diff --git a/src/parliamentarch/svg.py b/src/parliamentarch/svg.py index 83eae38..311d34a 100644 --- a/src/parliamentarch/svg.py +++ b/src/parliamentarch/svg.py @@ -1,6 +1,7 @@ from collections.abc import Iterable from functools import cached_property import re +from typing import TypeVar import warnings from ._util import Color, UnPicklable, write_from_get @@ -38,7 +39,8 @@ def accepted_color(c): self.border_size = border_size self.border_color = accepted_color(border_color) -def dispatch_seats[S]( +S = TypeVar("S") # PY3.11 compat +def dispatch_seats( group_seats: dict[SeatData, int], seats: Iterable[S], ) -> dict[SeatData, list[S]]: