From 41b2902f12eebd708af0c3665adf7b18d2f7f406 Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Mon, 5 Feb 2024 19:44:49 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AC=20=20Update=20type=20hints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arpes/plotting/bz_tool/__init__.py | 1 - arpes/plotting/dynamic_tool.py | 5 +++-- arpes/plotting/qt_ktool/__init__.py | 2 +- arpes/plotting/qt_tool/__init__.py | 8 ++++---- arpes/utilities/qt/__init__.py | 4 +--- arpes/utilities/qt/windows.py | 2 +- arpes/utilities/ui.py | 12 ++++++------ 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/arpes/plotting/bz_tool/__init__.py b/arpes/plotting/bz_tool/__init__.py index 59c213a2..a78df126 100644 --- a/arpes/plotting/bz_tool/__init__.py +++ b/arpes/plotting/bz_tool/__init__.py @@ -22,7 +22,6 @@ from arpes.utilities.ui import combo_box, horizontal, tabs from .CoordinateOffsetWidget import CoordinateOffsetWidget -from .RangeOrSingleValueWidget import RangeOrSingleValueWidget if TYPE_CHECKING: from _typeshed import Incomplete diff --git a/arpes/plotting/dynamic_tool.py b/arpes/plotting/dynamic_tool.py index 119b99a9..bd898f1b 100644 --- a/arpes/plotting/dynamic_tool.py +++ b/arpes/plotting/dynamic_tool.py @@ -1,4 +1,5 @@ """Allows for making any function of a spectrum into a dynamic tool.""" + from __future__ import annotations import inspect @@ -170,11 +171,11 @@ def build_control_for( parameter_default, parameter_type, validator_settings=config, - id=f"{parameter_name}-control", + id_=f"{parameter_name}-control", ) if parameter_type == str: - return line_edit(parameter_default, id=f"{parameter_name}-control") + return line_edit(parameter_default, id_=f"{parameter_name}-control") return None def before_show(self) -> None: diff --git a/arpes/plotting/qt_ktool/__init__.py b/arpes/plotting/qt_ktool/__init__.py index 7d5908d4..237128ea 100644 --- a/arpes/plotting/qt_ktool/__init__.py +++ b/arpes/plotting/qt_ktool/__init__.py @@ -99,7 +99,7 @@ def add_contextual_widgets(self) -> None: numeric_input( self.data.attrs.get(f"{p}_offset", 0.0), input_type=float, - id=f"control-{p}", + id_=f"control-{p}", ), ) for p in pair diff --git a/arpes/plotting/qt_tool/__init__.py b/arpes/plotting/qt_tool/__init__.py index 8cf8a639..7e18fb96 100644 --- a/arpes/plotting/qt_tool/__init__.py +++ b/arpes/plotting/qt_tool/__init__.py @@ -192,10 +192,10 @@ class QtTool(SimpleApp): def __init__(self) -> None: """Initialize attributes to safe empty values.""" super().__init__() - self.data: xr.Dataset | xr.DataArray + self.data: xr.DataArray - self.content_layout = None - self.main_layout: QtWidgets.QGridLayout | None = None + self.content_layout: QGridLayout + self.main_layout: QGridLayout self.axis_info_widgets: list = [] self.binning_info_widgets: list = [] @@ -527,7 +527,7 @@ def reset_intensity(self) -> None: """Autoscales intensity in each marginal plot.""" self.update_cursor_position(self.context["cursor"], force=True, keep_levels=False) - def set_data(self, data: DataType) -> None: + def set_data(self, data: xr.DataArray | xr.Dataset) -> None: """Sets the current data to a new value and resets binning.""" data_arr = normalize_to_spectrum(data) diff --git a/arpes/utilities/qt/__init__.py b/arpes/utilities/qt/__init__.py index 2243c655..0b1579f1 100644 --- a/arpes/utilities/qt/__init__.py +++ b/arpes/utilities/qt/__init__.py @@ -10,8 +10,6 @@ import dill import pyqtgraph as pg from pyqtgraph import ViewBox -from PySide6.QtCore import QCoreApplication -from PySide6.QtWidgets import QWidget from arpes._typing import xr_types @@ -21,7 +19,7 @@ from .windows import SimpleWindow if TYPE_CHECKING: - from collections.abc import Callable, Generator, Iterable + from collections.abc import Callable from typing import Literal, Self from _typeshed import Incomplete diff --git a/arpes/utilities/qt/windows.py b/arpes/utilities/qt/windows.py index e17a9d61..88aee956 100644 --- a/arpes/utilities/qt/windows.py +++ b/arpes/utilities/qt/windows.py @@ -23,7 +23,7 @@ LOGLEVELS = (DEBUG, INFO) -LOGLEVEL = LOGLEVELS[0] +LOGLEVEL = LOGLEVELS[1] logger = getLogger(__name__) fmt = "%(asctime)s %(levelname)s %(name)s :%(message)s" formatter = Formatter(fmt) diff --git a/arpes/utilities/ui.py b/arpes/utilities/ui.py index ad33d61f..80f80853 100644 --- a/arpes/utilities/ui.py +++ b/arpes/utilities/ui.py @@ -120,7 +120,7 @@ LOGLEVELS = (DEBUG, INFO) -LOGLEVEL = LOGLEVELS[0] +LOGLEVEL = LOGLEVELS[1] logger = getLogger(__name__) fmt = "%(asctime)s %(levelname)s %(name)s :%(message)s" formatter = Formatter(fmt) @@ -152,7 +152,7 @@ class CursorMode(NamedTuple): supported_dimensions: Incomplete -PRETTY_KEYS: str[int, str] = {} +PRETTY_KEYS: dict[Enum, str] = {} for key, value in vars(QtCore.Qt.Key).items(): if isinstance(value, QtCore.Qt.Key): PRETTY_KEYS[value] = key.partition("_")[2] @@ -522,14 +522,14 @@ def _layout_dataclass_field(dataclass_cls: Incomplete, field_name: str, prefix: int, float, ]: - field_input = numeric_input(value=0, input_type=field.type, id=id_for_field) + field_input = numeric_input(value=0, input_type=field.type, id_=id_for_field) elif field.type == str: - field_input = line_edit("", id=id_for_field) + field_input = line_edit("", id_=id_for_field) elif issubclass(field.type, enum.Enum): enum_options = enum_option_names(field.type) - field_input = combo_box(enum_options, id=id_for_field) + field_input = combo_box(enum_options, id_=id_for_field) elif field.type == bool: - field_input = check_box(field_name, id=id_for_field) + field_input = check_box(field_name, id_=id_for_field) else: msg = f"Could not render field: {field}" raise RuntimeError(msg)