Skip to content

Commit

Permalink
chore: update project config
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed Dec 11, 2024
1 parent cb5cf49 commit 8ccdb27
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ jobs:
test:
name: Test Python ${{ matrix.python-version }} [${{ matrix.qt-api }}]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DISPLAY: ':99.0'
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
qt-api: ["pyqt6", "pyside6"]

steps:
- uses: actions/checkout@v4
with:
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,18 @@ docstring-code-line-length = "dynamic"
profile = "black"

[tool.pytest.ini_options]
addopts = ["--import-mode=importlib"]
addopts = [
"-ra",
"--strict-config",
"--strict-markers",
"--import-mode=importlib",
]
pythonpath = "src"
testpaths = "tests"
minversion = "8.3"
log_cli_level = "DEBUG"
xfail_strict = true
filterwarnings = ["always"]

[tool.coverage.run]
source = ["src"]
Expand Down Expand Up @@ -260,5 +269,6 @@ exclude = [
'_deprecated/',
'^src/erlab/interactive/curvefittingtool.py',
]
disable_error_code = ['import-untyped']
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
disable_error_code = ["import-untyped"]
pretty = true
4 changes: 1 addition & 3 deletions src/erlab/accessors/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ def __call__(
if parallel_kw is None:
parallel_kw = {}

is_dask: bool = not (
self._obj.chunksizes is None or len(self._obj.chunksizes) == 0
)
is_dask: bool = not (not self._obj.chunksizes or len(self._obj.chunksizes) == 0)

if not isinstance(params, xr.Dataset) and isinstance(params, Mapping):
# Given as a mapping from str to ...
Expand Down
4 changes: 3 additions & 1 deletion src/erlab/interactive/bzplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def __init__(
param_type: Literal["lattice", "avec", "bvec"] | None = None,
execute: bool = True,
) -> None:
self.qapp = cast(QtWidgets.QApplication, QtWidgets.QApplication.instance())
self.qapp = cast(
QtWidgets.QApplication | None, QtWidgets.QApplication.instance()
)
if not self.qapp:
self.qapp = QtWidgets.QApplication(sys.argv)

Expand Down
2 changes: 1 addition & 1 deletion src/erlab/interactive/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def dtool(
if execute is None:
execute = True
try:
shell = get_ipython().__class__.__name__ # type: ignore
shell = get_ipython().__class__.__name__ # type: ignore[name-defined]
if shell in ["ZMQInteractiveShell", "TerminalInteractiveShell"]:
execute = False
from IPython.lib.guisupport import start_event_loop_qt4
Expand Down
5 changes: 3 additions & 2 deletions src/erlab/interactive/imagetool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def itool(
if execute is None:
execute = True
try:
shell = get_ipython().__class__.__name__ # type: ignore
shell = get_ipython().__class__.__name__ # type: ignore[name-defined]
if shell in ["ZMQInteractiveShell", "TerminalInteractiveShell"]:
execute = False
from IPython.lib.guisupport import start_event_loop_qt4
Expand Down Expand Up @@ -283,7 +283,8 @@ def array_slicer(self) -> ArraySlicer:

def to_dataset(self) -> xr.Dataset:
name = self.slicer_area._data.name
name = name if name else ""
if name is None:
name = ""
return self.slicer_area._data.to_dataset(
name=_ITOOL_DATA_NAME, promote_attrs=False
).assign_attrs(
Expand Down
4 changes: 2 additions & 2 deletions src/erlab/interactive/imagetool/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ def cursor_index(self, value: int) -> None:
def sliced_data(self) -> xr.DataArray:
with xr.set_options(keep_attrs=True):
sliced = self.array_slicer.xslice(self.cursor_index, self.display_axis)
if sliced.name:
if sliced.name is not None and sliced.name != "":
sliced = sliced.rename(f"{sliced.name} Sliced")
return sliced

Expand Down Expand Up @@ -2217,7 +2217,7 @@ def save_current_data(self) -> None:
data_to_save = self.current_data

default_name = data_to_save.name
if not default_name:
if default_name is not None and default_name != "":
default_name = "data"

dialog = QtWidgets.QFileDialog()
Expand Down
2 changes: 1 addition & 1 deletion src/erlab/interactive/imagetool/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def make_code(self) -> str:
out += f".sel({kwargs})"

if isel_kwargs:
if all(isinstance(k, str) and str(k).isidentifier() for k in isel_kwargs):
if all(k.isidentifier() for k in isel_kwargs):
out = generate_code(xr.DataArray.isel, [], isel_kwargs, module=out)
else:
out += f".isel({isel_kwargs})"
Expand Down
2 changes: 1 addition & 1 deletion src/erlab/interactive/kspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def ktool(
if execute is None:
execute = True
try:
shell = get_ipython().__class__.__name__ # type: ignore
shell = get_ipython().__class__.__name__ # type: ignore[name-defined]
if shell in ["ZMQInteractiveShell", "TerminalInteractiveShell"]:
execute = False
from IPython.lib.guisupport import start_event_loop_qt4
Expand Down
4 changes: 3 additions & 1 deletion src/erlab/interactive/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,9 @@ def __init__(
*args,
**kwargs,
) -> None:
self.qapp = cast(QtWidgets.QApplication, QtWidgets.QApplication.instance())
self.qapp = cast(
QtWidgets.QApplication | None, QtWidgets.QApplication.instance()
)
if not self.qapp:
self.qapp = QtWidgets.QApplication(sys.argv)
self.qapp.setStyle("Fusion")
Expand Down
4 changes: 1 addition & 3 deletions src/erlab/io/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,7 @@ def summarize(

try:
shell = get_ipython().__class__.__name__ # type: ignore[name-defined]
if display and (
shell in ["ZMQInteractiveShell", "TerminalInteractiveShell"]
):
if shell in ["ZMQInteractiveShell", "TerminalInteractiveShell"]:
import IPython.display

with pandas.option_context(
Expand Down

0 comments on commit 8ccdb27

Please sign in to comment.