Skip to content

Commit

Permalink
Add missing annotations to make Python 3.9 compatible (#487)
Browse files Browse the repository at this point in the history
* Add missing annotations to make Python 3.9 compatible

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix conda env

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
scottstanie and pre-commit-ci[bot] authored Nov 11, 2024
1 parent 2a372af commit e89276e
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion conda-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: dolphin-env
channels:
- conda-forge
dependencies:
- python>=3.8
- python>=3.9
- pip>=21.3 # https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#editable-installation
- git # for pip install, due to setuptools_scm
- gdal>=3.3
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "dolphin"
description = "Workflows for generating surface displacement maps using InSAR"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.8"
requires-python = ">=3.9"

classifiers = [
"Development Status :: 2 - Pre-Alpha",
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/_cli_unwrap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
from pathlib import Path
from typing import TYPE_CHECKING, Any
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/_log.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import logging
import logging.config
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/_overviews.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import logging
from enum import Enum
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/filtering.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import multiprocessing as mp
from concurrent.futures import ProcessPoolExecutor
from itertools import repeat
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/goldstein.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
from numpy.typing import NDArray

Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/interpolation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging

import numba
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/io/_process.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from concurrent.futures import FIRST_EXCEPTION, Future, ThreadPoolExecutor, wait
from typing import Protocol, Sequence

Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/phase_link/_compress.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import warnings

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/phase_link/metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Module for computing quality metrics of estimated solutions."""

from __future__ import annotations

import jax.numpy as jnp
from jax import Array, jit, vmap
from jax.typing import ArrayLike
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/phase_link/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
full CPU/GPU stack implementations.
"""

from __future__ import annotations

import numpy as np
import numpy.linalg as la
import scipy.ndimage as ndi
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Uses metric from [@Wang2022AccuratePersistentScatterer] for similarity.
"""

from __future__ import annotations

import logging
from pathlib import Path
from typing import Callable, Literal, Sequence
Expand Down
6 changes: 3 additions & 3 deletions src/dolphin/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ class CompressedSlcInfo(BaseModel):
..., description="Datetime of the last real SLC used in the compression."
)

real_slc_file_list: list[Filename] | None = Field(
real_slc_file_list: Optional[list[Filename]] = Field(
None,
description="List of real SLC filenames in the ministack.",
)
real_slc_dates: list[datetime] | None = Field(
real_slc_dates: Optional[list[datetime]] = Field(
None,
description=(
"List of date sequences, one for each SLC in the ministack. "
"Each item is a list/tuple of datetime.date or datetime.datetime objects."
),
)
compressed_slc_file_list: list[Filename] | None = Field(
compressed_slc_file_list: Optional[list[Filename]] = Field(
None,
description="List of compressed SLC filenames in the ministack.",
)
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/unwrap/_post_process.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging

import numpy as np
Expand Down
7 changes: 4 additions & 3 deletions src/dolphin/unwrap/_tophu.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ def _get_cb_and_nodata(unwrap_method, unwrap_callback, nodata):
# Fill in the nan pixels with the nearest ambiguities
from ._post_process import interpolate_masked_gaps

with rio.open(unw_filename, mode="r+") as u_src, rio.open(
igram_rb.filepath
) as i_src:
with (
rio.open(unw_filename, mode="r+") as u_src,
rio.open(igram_rb.filepath) as i_src,
):
unw = u_src.read(1)
ifg = i_src.read(1)
# nodata_mask = i_src.read_masks(1) != 0
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/unwrap/_unwrap_3d.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import shutil
import subprocess
Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/workflows/_cli_run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
from typing import TYPE_CHECKING, Any, Optional, Sequence

Expand Down
2 changes: 2 additions & 0 deletions src/dolphin/workflows/config/_yaml_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import sys
import textwrap
Expand Down
21 changes: 12 additions & 9 deletions tests/test_io_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ def binary_file_list(tmp_path_factory, slc_stack):
for i, slc in enumerate(slc_stack):
f = tmp_path / f"test_{i}.bin"
# Ignore warning
with pytest.warns(NotGeoreferencedWarning), rio.open(
f,
"w",
driver="ENVI",
width=shape[1],
height=shape[0],
count=1,
dtype=dtype,
) as dst:
with (
pytest.warns(NotGeoreferencedWarning),
rio.open(
f,
"w",
driver="ENVI",
width=shape[1],
height=shape[0],
count=1,
dtype=dtype,
) as dst,
):
dst.write(slc, 1)
files.append(f)

Expand Down

0 comments on commit e89276e

Please sign in to comment.