Update Mypy so I can use PEP 695 type param syntax

This commit is contained in:
Danielle McLean 2024-07-30 10:09:33 +10:00
parent 3ef3112014
commit 452867699e
Signed by: 00dani
GPG key ID: 6854781A0488421C
10 changed files with 53 additions and 52 deletions

View file

@ -1,6 +1,5 @@
from collections.abc import Mapping
from os import environ
from typing import TypeVar
from boltons.iterutils import remap
from pytomlpp import load
@ -9,8 +8,6 @@ from xdg_base_dirs import xdg_config_home
from .model import Config
__all__ = ("loadConfig",)
K = TypeVar("K")
V = TypeVar("V")
# Sadly this is the kind of function that's incredibly easy to type statically
@ -24,7 +21,7 @@ V = TypeVar("V")
# type like NonNullable<T>. Python's type system also doesn't infer a
# dictionary literal as having a structural type by default in the way
# TypeScript does, of course, so that part wouldn't work anyway.
def withoutNones(data: Mapping[K, V | None]) -> Mapping[K, V]:
def withoutNones[K, V](data: Mapping[K, V | None]) -> Mapping[K, V]:
return remap(data, lambda p, k, v: v is not None)