From fb7b00f0e83d84a21088eb9b54f2f8b5d72c3d41 Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Mon, 18 Mar 2024 18:13:49 +0900 Subject: [PATCH 1/4] =?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 --- pyproject.toml | 2 +- src/arpes/utilities/jupyter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e707d81e..cee87c78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ lint.ignore = [ "NPY201", # Numpy 2.0, ] lint.select = ["ALL"] -target-version = "py310" +target-version = "py312" line-length = 100 indent-width = 4 diff --git a/src/arpes/utilities/jupyter.py b/src/arpes/utilities/jupyter.py index 52684ae5..cccf956b 100644 --- a/src/arpes/utilities/jupyter.py +++ b/src/arpes/utilities/jupyter.py @@ -118,7 +118,7 @@ def get_full_notebook_information() -> NoteBookInfomation | None: if not url.startswith(("http:", "https:")): msg = "URL must start with 'http:' or 'https:'" raise ValueError(msg) - sessions = json.load(urllib.request.urlopen(url)) + sessions = json.load(urllib.request.urlopen(url)) # noqa: S310 for sess in sessions: if sess["kernel"]["id"] == kernel_id: return { From 5973903c0dd40d40ba6fe6d34dbdb24bdf272a60 Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Tue, 19 Mar 2024 11:09:44 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=92=AC=20=20Change=20target=20python?= =?UTF-8?q?=20version.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cee87c78..ddb04c60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,9 +96,10 @@ lint.ignore = [ "G004", # logging-f-string # "NPY201", # Numpy 2.0, + "ISC001", # single-line-implicit-string-concatenation ] lint.select = ["ALL"] -target-version = "py312" +target-version = "py311" line-length = 100 indent-width = 4 From b62366c07f86f19e3055cd2da4e8d0bdb8c4fcfe Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Tue, 19 Mar 2024 11:10:05 +0900 Subject: [PATCH 3/4] =?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 --- src/arpes/deep_learning/interpret.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arpes/deep_learning/interpret.py b/src/arpes/deep_learning/interpret.py index 8e8e3e3e..92db5d62 100644 --- a/src/arpes/deep_learning/interpret.py +++ b/src/arpes/deep_learning/interpret.py @@ -137,7 +137,7 @@ def items(self) -> list[InterpretationItem]: def top_losses(self, *, ascending: bool = False) -> list[InterpretationItem]: """Orders the items by loss.""" - def key(item: Incomplete): + def key(item: Incomplete) -> Incomplete: return item.loss if ascending else -item.loss return sorted(self.items, key=key) From e8159fc9ba06c9af266b5494f1caea9a8424cff3 Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Tue, 19 Mar 2024 11:19:17 +0900 Subject: [PATCH 4/4] =?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 --- src/arpes/analysis/band_analysis.py | 13 +++++++++++++ src/arpes/plotting/fit_tool/__init__.py | 2 +- src/arpes/plotting/qt_tool/__init__.py | 2 +- src/arpes/plotting/stack_plot.py | 4 ++-- src/arpes/utilities/widgets.py | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/arpes/analysis/band_analysis.py b/src/arpes/analysis/band_analysis.py index cbc6113a..e2b979b8 100644 --- a/src/arpes/analysis/band_analysis.py +++ b/src/arpes/analysis/band_analysis.py @@ -7,6 +7,7 @@ import functools import itertools from itertools import pairwise +from logging import DEBUG, INFO, Formatter, StreamHandler, getLogger from typing import TYPE_CHECKING, Any, Literal import numpy as np @@ -36,6 +37,18 @@ "fit_for_effective_mass", ) +LOGLEVELS = (DEBUG, INFO) +LOGLEVEL = LOGLEVELS[1] +logger = getLogger(__name__) +fmt = "%(asctime)s %(levelname)s %(name)s :%(message)s" +formatter = Formatter(fmt) +handler = StreamHandler() +handler.setLevel(LOGLEVEL) +logger.setLevel(LOGLEVEL) +handler.setFormatter(formatter) +logger.addHandler(handler) +logger.propagate = False + def fit_for_effective_mass( data: xr.DataArray, diff --git a/src/arpes/plotting/fit_tool/__init__.py b/src/arpes/plotting/fit_tool/__init__.py index 6d805cc3..f9c7c22c 100644 --- a/src/arpes/plotting/fit_tool/__init__.py +++ b/src/arpes/plotting/fit_tool/__init__.py @@ -266,7 +266,7 @@ def configure_image_widgets(self) -> None: layout=self.content_layout, ) - def generate_fit_marginal_for( + def generate_fit_marginal_for( # noqa: PLR0913 self, dimensions: tuple[int, ...], column_row: tuple[int, int], diff --git a/src/arpes/plotting/qt_tool/__init__.py b/src/arpes/plotting/qt_tool/__init__.py index f27c32f5..8f210789 100644 --- a/src/arpes/plotting/qt_tool/__init__.py +++ b/src/arpes/plotting/qt_tool/__init__.py @@ -552,7 +552,7 @@ def set_data(self, data: xr.DataArray) -> None: def _qt_tool(data: XrTypes, **kwargs: Incomplete) -> None: """Starts the qt_tool using an input spectrum.""" with contextlib.suppress(TypeError): - data = dill.loads(data) + data = dill.loads(data) # noqa: S301 tool = QtTool() tool.set_data(data) diff --git a/src/arpes/plotting/stack_plot.py b/src/arpes/plotting/stack_plot.py index 8d611012..e6606137 100644 --- a/src/arpes/plotting/stack_plot.py +++ b/src/arpes/plotting/stack_plot.py @@ -65,7 +65,7 @@ @save_plot_provenance -def offset_scatter_plot( +def offset_scatter_plot( # noqa: PLR0913 data: xr.Dataset, name_to_plot: str = "", stack_axis: str = "", @@ -133,7 +133,7 @@ def offset_scatter_plot( skip_colorbar = True if cbarmap is None: skip_colorbar = False - cbar: colorbar.Colorbar | Callable[..., colorbar.Colorbar] + cbar: Callable[..., colorbar.Colorbar] cmap: Callable[..., ColorType] | Callable[..., Callable[..., ColorType]] try: cbar, cmap = colorbarmaps_for_axis[stack_axis] diff --git a/src/arpes/utilities/widgets.py b/src/arpes/utilities/widgets.py index 04b0c2cc..ec432501 100644 --- a/src/arpes/utilities/widgets.py +++ b/src/arpes/utilities/widgets.py @@ -138,7 +138,7 @@ def __init__(self, *args: QWidget | None) -> None: self.toggled.connect(lambda: self.subject.on_next(self.isChecked())) self.subject.subscribe(self.update_ui) - def update_ui(self, value: bool) -> None: + def update_ui(self, *, value: bool) -> None: """Forwards value change to the UI.""" self.setChecked(value)