]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Use 'Any' instead of type unions in GLConfig.
authorCollin Funk <collin.funk1@gmail.com>
Fri, 5 Apr 2024 04:41:08 +0000 (21:41 -0700)
committerBruno Haible <bruno@clisp.org>
Fri, 5 Apr 2024 12:55:16 +0000 (14:55 +0200)
* pygnulib/GLConfig.py (GLConfig.__getitem__, GLConfig.dictionary)
(GLConfig.default, GLConfig.isdefault, GLConfig.values): Use 'Any' from
the typing module instead of large type unions. This silences unhelpful
warnings from type checkers.

ChangeLog
pygnulib/GLConfig.py

index 1d6466d9dac54b0ed029d30f536802d25b84de0c..2bb5443e317dda4bc0a35228899dd435de06b3b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-05  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Use 'Any' instead of type unions in GLConfig.
+       * pygnulib/GLConfig.py (GLConfig.__getitem__, GLConfig.dictionary)
+       (GLConfig.default, GLConfig.isdefault, GLConfig.values): Use 'Any' from
+       the typing module instead of large type unions. This silences unhelpful
+       warnings from type checkers.
+
 2024-04-05  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Fix 'consider-using-set-comprehension' warnings.
index 121edf541e920d82538c406d273aea8a42307387..1c9caa218bcb5526b93aebcd3d5b67a33f0179d6 100644 (file)
@@ -21,6 +21,7 @@ from __future__ import annotations
 import os
 import copy
 import tempfile
+from typing import Any
 from . import constants
 from .GLError import GLError
 from pygnulib.enums import CopyAction
@@ -248,14 +249,14 @@ class GLConfig:
         '''x.__repr__() <==> repr(x)'''
         return '<pygnulib.GLConfig>'
 
-    def __getitem__(self, y: str) -> str | float | int | bool | CopyAction | list[str] | None:
+    def __getitem__(self, y: str) -> Any:
         '''x.__getitem__(y) <==> x[y]'''
         if y in self.table:
             return self.table[y]
         else:  # if y not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(y))
 
-    def dictionary(self) -> dict[str, str | float | int | bool | CopyAction | list[str] | None]:
+    def dictionary(self) -> dict[str, Any]:
         '''Return the configuration as a dict object.'''
         return dict(self.table)
 
@@ -296,7 +297,7 @@ class GLConfig:
         else:  # if key not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(key))
 
-    def default(self, key: str) -> str | float | int | bool | CopyAction | list[str] | None:
+    def default(self, key: str) -> Any:
         '''Return default value for the given key.'''
         if key in self.table:
             if key == 'libname':
@@ -327,7 +328,7 @@ class GLConfig:
         else:  # if key not in self.table
             raise KeyError('GLConfig does not contain key: %s' % repr(key))
 
-    def isdefault(self, key: str, value: str | float | int | bool | CopyAction | list[str] | None) -> bool:
+    def isdefault(self, key: str, value: Any) -> bool:
         '''Check whether the value for the given key is a default value.'''
         if key in self.table:
             default = self.default(key)
@@ -339,7 +340,7 @@ class GLConfig:
         '''Return list of keys.'''
         return list(self.table.keys())
 
-    def values(self) -> list[str | float | int | bool | CopyAction | list[str] | None]:
+    def values(self) -> list[Any]:
         '''Return list of values.'''
         return list(self.table.values())