From f5b02f794d3b1ee3b015712f430b98cbfefee686 Mon Sep 17 00:00:00 2001 From: Cory Francis Myers Date: Wed, 27 Sep 2023 16:32:25 -0700 Subject: [PATCH] fix(CatalogVerifier): relax typing < Python 3.9 When typing[1] exc_type as Optional[type[BaseException]], there seems to be no way around "TypeError: 'type' object is not subscriptable" in our current Python 3.8, even using __future__.annotations. [1]: https://adamj.eu/tech/2021/07/04/python-type-hints-how-to-type-a-context-manager/ --- devops/scripts/verify-mo.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/devops/scripts/verify-mo.py b/devops/scripts/verify-mo.py index 945d2b7c89c..cc1d7d595e9 100755 --- a/devops/scripts/verify-mo.py +++ b/devops/scripts/verify-mo.py @@ -20,10 +20,8 @@ import os import shlex import subprocess -from collections.abc import Iterator from pathlib import Path -from types import TracebackType -from typing import Optional, Set +from typing import Any, Iterator, Optional, Set import polib from translate.tools.pocompile import convertmo @@ -61,9 +59,9 @@ def __enter__(self) -> "CatalogVerifier": def __exit__( self, - exc_type: Optional[type[BaseException]], - exc_value: Optional[BaseException], - traceback: Optional[TracebackType], + exc_type: Optional[Any], + exc_value: Optional[Any], + traceback: Optional[Any], ) -> None: """Clean up."""