From 4dae9dd11f72bb5a5b5852524ec04b3240afe2a9 Mon Sep 17 00:00:00 2001 From: Pierre Raybaut Date: Wed, 6 Nov 2024 14:29:02 +0100 Subject: [PATCH] Revert "Dropped Python 3.8: remove unnecessary `from __future__ import annotations` statements" This reverts commit ae359f6214b1c7a5a827a5d1e1707d8db4ba89be. --- guidata/configtools.py | 2 ++ guidata/dataset/autodoc.py | 2 ++ guidata/dataset/conv.py | 2 ++ guidata/dataset/note_directive.py | 2 ++ guidata/dataset/qtitemwidgets.py | 2 ++ guidata/env.py | 2 ++ guidata/io/base.py | 11 +++++------ guidata/io/h5fmt.py | 2 ++ guidata/io/inifmt.py | 2 ++ guidata/io/jsonfmt.py | 2 ++ guidata/qthelpers.py | 2 ++ guidata/tests/unit/test_dataset_from_func.py | 2 ++ guidata/tests/unit/test_h5fmt.py | 2 ++ guidata/tests/unit/test_jsonfmt.py | 2 ++ guidata/tests/widgets/test_arrayeditor_unit.py | 2 ++ guidata/tests/widgets/test_theme.py | 2 ++ guidata/utils/encoding.py | 2 ++ guidata/utils/genreqs.py | 2 ++ guidata/utils/misc.py | 2 ++ guidata/widgets/about.py | 2 ++ guidata/widgets/arrayeditor/arrayeditor.py | 2 ++ guidata/widgets/arrayeditor/arrayhandler.py | 2 ++ guidata/widgets/arrayeditor/datamodel.py | 2 ++ guidata/widgets/arrayeditor/editorwidget.py | 2 ++ guidata/widgets/dockable.py | 2 ++ guidata/widgets/objecteditor.py | 2 ++ 26 files changed, 55 insertions(+), 6 deletions(-) diff --git a/guidata/configtools.py b/guidata/configtools.py index 8dec9ab..0107938 100644 --- a/guidata/configtools.py +++ b/guidata/configtools.py @@ -34,6 +34,8 @@ .. autofunction:: add_image_module_path """ +from __future__ import annotations + import gettext import os import os.path as osp diff --git a/guidata/dataset/autodoc.py b/guidata/dataset/autodoc.py index ae320d2..d2e2f93 100644 --- a/guidata/dataset/autodoc.py +++ b/guidata/dataset/autodoc.py @@ -3,6 +3,8 @@ classes. """ +from __future__ import annotations + import logging import re from inspect import Parameter, Signature diff --git a/guidata/dataset/conv.py b/guidata/dataset/conv.py index e7ddb9c..13399a2 100644 --- a/guidata/dataset/conv.py +++ b/guidata/dataset/conv.py @@ -22,6 +22,8 @@ .. autofunction:: guidata.dataset.create_dataset_from_dict """ +from __future__ import annotations + import inspect from typing import TYPE_CHECKING, Any diff --git a/guidata/dataset/note_directive.py b/guidata/dataset/note_directive.py index 18e030f..b6527ac 100644 --- a/guidata/dataset/note_directive.py +++ b/guidata/dataset/note_directive.py @@ -4,6 +4,8 @@ """Sphinx directive to display a note about how to instanciate a dataset class""" +from __future__ import annotations + from typing import TYPE_CHECKING, Type from docutils import nodes diff --git a/guidata/dataset/qtitemwidgets.py b/guidata/dataset/qtitemwidgets.py index f54cf7b..7fa1597 100644 --- a/guidata/dataset/qtitemwidgets.py +++ b/guidata/dataset/qtitemwidgets.py @@ -15,6 +15,8 @@ Example: ChoiceWidget <--> ChoiceItem, ImageChoiceItem """ +from __future__ import annotations + import datetime import os import os.path as osp diff --git a/guidata/env.py b/guidata/env.py index cc67433..1c49dce 100644 --- a/guidata/env.py +++ b/guidata/env.py @@ -7,6 +7,8 @@ Execution environmnent utilities """ +from __future__ import annotations + import argparse import enum import os diff --git a/guidata/io/base.py b/guidata/io/base.py index 883f174..186bca6 100644 --- a/guidata/io/base.py +++ b/guidata/io/base.py @@ -120,12 +120,11 @@ def end(self, section: str) -> None: section (str): The name of the section to end. """ sect = self.option.pop(-1) - assert sect == section, ( - "Ending section does not match the current section: %s != %s" - % ( - sect, - section, - ) + assert ( + sect == section + ), "Ending section does not match the current section: %s != %s" % ( + sect, + section, ) diff --git a/guidata/io/h5fmt.py b/guidata/io/h5fmt.py index 89e51fc..c687be2 100644 --- a/guidata/io/h5fmt.py +++ b/guidata/io/h5fmt.py @@ -7,6 +7,8 @@ HDF5 files (.h5) """ +from __future__ import annotations + import datetime import sys from collections.abc import Callable, Sequence diff --git a/guidata/io/inifmt.py b/guidata/io/inifmt.py index b88f7b4..ae54cfd 100644 --- a/guidata/io/inifmt.py +++ b/guidata/io/inifmt.py @@ -7,6 +7,8 @@ Configuration files (.ini) """ +from __future__ import annotations + from typing import Any from guidata.io.base import BaseIOHandler, GroupContext, WriterMixin diff --git a/guidata/io/jsonfmt.py b/guidata/io/jsonfmt.py index f82f18c..d95ab28 100644 --- a/guidata/io/jsonfmt.py +++ b/guidata/io/jsonfmt.py @@ -12,6 +12,8 @@ # pylint: disable=invalid-name # Allows short reference names like x, y, ... +from __future__ import annotations + import json import os from collections.abc import Callable, Sequence diff --git a/guidata/qthelpers.py b/guidata/qthelpers.py index 049c7d0..d6ccbd0 100644 --- a/guidata/qthelpers.py +++ b/guidata/qthelpers.py @@ -53,6 +53,8 @@ .. autofunction:: save_restore_stds """ +from __future__ import annotations + import os import os.path as osp import sys diff --git a/guidata/tests/unit/test_dataset_from_func.py b/guidata/tests/unit/test_dataset_from_func.py index 21d5fd2..a32561b 100644 --- a/guidata/tests/unit/test_dataset_from_func.py +++ b/guidata/tests/unit/test_dataset_from_func.py @@ -12,6 +12,8 @@ # guitest: show +from __future__ import annotations + import numpy as np from guidata.dataset import create_dataset_from_func diff --git a/guidata/tests/unit/test_h5fmt.py b/guidata/tests/unit/test_h5fmt.py index ca55151..ba1138e 100644 --- a/guidata/tests/unit/test_h5fmt.py +++ b/guidata/tests/unit/test_h5fmt.py @@ -12,6 +12,8 @@ * Serialize and deserialize a data model, handling versioning and compatibility breaks. """ +from __future__ import annotations + import atexit import os import os.path as osp diff --git a/guidata/tests/unit/test_jsonfmt.py b/guidata/tests/unit/test_jsonfmt.py index d2f4a3e..19368fb 100644 --- a/guidata/tests/unit/test_jsonfmt.py +++ b/guidata/tests/unit/test_jsonfmt.py @@ -12,6 +12,8 @@ * Serialize and deserialize a data model, handling versioning and compatibility breaks. """ +from __future__ import annotations + import atexit import os import os.path as osp diff --git a/guidata/tests/widgets/test_arrayeditor_unit.py b/guidata/tests/widgets/test_arrayeditor_unit.py index 83c86fe..00dd3d0 100644 --- a/guidata/tests/widgets/test_arrayeditor_unit.py +++ b/guidata/tests/widgets/test_arrayeditor_unit.py @@ -10,6 +10,8 @@ # guitest: show +from __future__ import annotations + from typing import Any import numpy as np diff --git a/guidata/tests/widgets/test_theme.py b/guidata/tests/widgets/test_theme.py index a5262e3..611764b 100644 --- a/guidata/tests/widgets/test_theme.py +++ b/guidata/tests/widgets/test_theme.py @@ -7,6 +7,8 @@ Test dark/light theme switching """ +from __future__ import annotations + import os import sys from typing import Literal diff --git a/guidata/utils/encoding.py b/guidata/utils/encoding.py index 59640a7..6f97f07 100644 --- a/guidata/utils/encoding.py +++ b/guidata/utils/encoding.py @@ -11,6 +11,8 @@ source code (Utilities/__init___.py) Copyright © 2003-2009 Detlev Offenbach """ +from __future__ import annotations + import os import re from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF32 diff --git a/guidata/utils/genreqs.py b/guidata/utils/genreqs.py index a418403..a5a28b1 100644 --- a/guidata/utils/genreqs.py +++ b/guidata/utils/genreqs.py @@ -12,6 +12,8 @@ This module is derived from the `genreqs.py` module of the `DataLab` project. """ +from __future__ import annotations + import configparser as cp import os import os.path as osp diff --git a/guidata/utils/misc.py b/guidata/utils/misc.py index 46cad42..2196b00 100644 --- a/guidata/utils/misc.py +++ b/guidata/utils/misc.py @@ -26,6 +26,8 @@ .. autofunction:: decode_fs_string """ +from __future__ import annotations + import collections.abc import ctypes import locale diff --git a/guidata/widgets/about.py b/guidata/widgets/about.py index d6eaf95..7ddad02 100644 --- a/guidata/widgets/about.py +++ b/guidata/widgets/about.py @@ -6,6 +6,8 @@ """ +from __future__ import annotations + import platform import sys diff --git a/guidata/widgets/arrayeditor/arrayeditor.py b/guidata/widgets/arrayeditor/arrayeditor.py index dbca10b..352fb2a 100644 --- a/guidata/widgets/arrayeditor/arrayeditor.py +++ b/guidata/widgets/arrayeditor/arrayeditor.py @@ -16,6 +16,8 @@ Module that provides array editor dialog boxes to edit various types of NumPy arrays """ +from __future__ import annotations + from typing import Generic import numpy as np diff --git a/guidata/widgets/arrayeditor/arrayhandler.py b/guidata/widgets/arrayeditor/arrayhandler.py index 97f1190..70af1ba 100644 --- a/guidata/widgets/arrayeditor/arrayhandler.py +++ b/guidata/widgets/arrayeditor/arrayhandler.py @@ -18,6 +18,8 @@ models/widgets and views. They handle data access and changes. """ +from __future__ import annotations + import copy from typing import Any, Generic, TypeVar, Union, cast diff --git a/guidata/widgets/arrayeditor/datamodel.py b/guidata/widgets/arrayeditor/datamodel.py index b883861..176a638 100644 --- a/guidata/widgets/arrayeditor/datamodel.py +++ b/guidata/widgets/arrayeditor/datamodel.py @@ -16,6 +16,8 @@ Data models for the array editor widget. """ +from __future__ import annotations + from abc import abstractmethod from collections.abc import Callable from functools import reduce diff --git a/guidata/widgets/arrayeditor/editorwidget.py b/guidata/widgets/arrayeditor/editorwidget.py index f7c37bf..0f16172 100644 --- a/guidata/widgets/arrayeditor/editorwidget.py +++ b/guidata/widgets/arrayeditor/editorwidget.py @@ -14,6 +14,8 @@ """Array editor widget""" +from __future__ import annotations + import io from typing import Any, Generic, Sequence, cast diff --git a/guidata/widgets/dockable.py b/guidata/widgets/dockable.py index bd7ad7b..77db40e 100644 --- a/guidata/widgets/dockable.py +++ b/guidata/widgets/dockable.py @@ -11,6 +11,8 @@ into a QMainWindow. """ +from __future__ import annotations + from qtpy.QtCore import Qt from qtpy.QtWidgets import QDockWidget, QWidget diff --git a/guidata/widgets/objecteditor.py b/guidata/widgets/objecteditor.py index 16e4d02..7acee8a 100644 --- a/guidata/widgets/objecteditor.py +++ b/guidata/widgets/objecteditor.py @@ -14,6 +14,8 @@ """ +from __future__ import annotations + from typing import TYPE_CHECKING import numpy as np