Skip to content

Commit

Permalink
Use explicit typevars to have 3.11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Gouvernathor committed May 23, 2024
1 parent 9973b2c commit a82a5ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/parliamentarch/_util.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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]]:
Expand Down
4 changes: 3 additions & 1 deletion src/parliamentarch/svg.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]]:
Expand Down

0 comments on commit a82a5ee

Please sign in to comment.