From e572b27fc3b41440adf2767cd9098bc5c05fc290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Morosi?= Date: Tue, 13 Aug 2024 15:11:59 +0200 Subject: [PATCH] Fix Git_Cmd typing Git_Cmd is defined as List[Optional[str]] as to allow for lists of str with potentially None values. However as lists are invariant, mypy complains when a variable of type List[str] is passed with the message `has incompatible type "list[str]"; expected "list[Optional[str]]"`. So Git_Cmd should also be defined as List[str] --- src/e3/vcs/git.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/e3/vcs/git.py b/src/e3/vcs/git.py index 5e8d6255..1c6e59ce 100644 --- a/src/e3/vcs/git.py +++ b/src/e3/vcs/git.py @@ -32,19 +32,11 @@ from e3.vcs import VCSError if TYPE_CHECKING: - from typing import ( - Any, - Final, - IO, - Literal, - List, - Optional, - TextIO, - ) + from typing import Any, Final, IO, Literal, Optional, TextIO, Union from collections.abc import Iterator from e3.os.process import Run, DEVNULL_VALUE, PIPE_VALUE - Git_Cmd = List[Optional[str]] + Git_Cmd = Union[list[str], list[Optional[str]]] GIT_LOG_STREAM_VALUE = Literal[-4] # Special value to direct outputs to the git log stream