Skip to content

Commit

Permalink
Merge branch 'main' into dark/spatial-datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-dark committed Sep 24, 2024
2 parents 77a3a35 + eb60084 commit 89e970b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 78 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/python-somacore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ jobs:
format-check:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.8"
PYTHON_VERSION: "3.9"
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: python-spec/requirements-py${{ env.PYTHON_VERSION }}-lint.txt
cache-dependency-path: "python-spec/requirements-py${{ env.PYTHON_VERSION }}*.txt"

- name: Install static analysis packages
run: |
pip install -r python-spec/requirements-py${{ env.PYTHON_VERSION }}-lint.txt
working-directory: python-spec
run: pip install -r requirements-py${PYTHON_VERSION}.txt -r requirements-py${PYTHON_VERSION}-lint.txt

- name: Restore pre-commit cache
uses: actions/cache@v3
Expand All @@ -45,14 +45,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# setuptools-scm needs a deep clone so it can look through history
# to find a relevant tag.
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand All @@ -78,8 +78,8 @@ jobs:
&& startsWith(github.event.release.tag_name, 'python-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: python-spec/requirements-py3.10.txt
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies = [
"shapely",
"typing-extensions>=4.1", # For LiteralString (py3.11)
]
requires-python = "~=3.8"
requires-python = ">=3.9"
urls = { repository = "https://github.com/single-cell-data/SOMA.git" }
classifiers = ["License :: OSI Approved :: MIT License"]

Expand All @@ -44,7 +44,7 @@ tag_regex = '^python-(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)?$'

[tool.ruff]
lint.extend-select = ["I"]
target-version = "py38"
target-version = "py39"

[tool.ruff.lint.isort]
force-single-line = true
Expand All @@ -55,7 +55,7 @@ single-line-exclusions = ["typing", "typing_extensions"]
check_untyped_defs = true
enable_error_code = ["ignore-without-code"]
warn_redundant_casts = true
python_version = 3.8
python_version = 3.9
# We want to enable this but it won't work when running locally due to the
# presence of _version.py (which invalidates the ignore, which causes an error).
#
Expand Down
39 changes: 0 additions & 39 deletions python-spec/requirements-py3.8-lint.txt

This file was deleted.

20 changes: 0 additions & 20 deletions python-spec/requirements-py3.8.txt

This file was deleted.

3 changes: 3 additions & 0 deletions python-spec/requirements-py3.9-lint.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mypy==1.11.2
pandas-stubs==2.2.2.240807 # last version which supports Python 3.9
pre-commit==3.8.0
4 changes: 1 addition & 3 deletions python-spec/src/somacore/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class Axis:


@attrs.define(frozen=True)
class CoordinateSpace(
collections.abc.Sequence
): # Change to Sequence[Axis] after 3.8 is dropped.
class CoordinateSpace(collections.abc.Sequence[Axis]):
"""A coordinate space for spatial data.
Args:
Expand Down
4 changes: 2 additions & 2 deletions python-spec/src/somacore/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def str_or_seq_length(obj: Union[str, Sequence[str]]) -> int:
class Slice(Protocol[_T_co]):
"""A slice which stores a certain type of object.
This protocol describes the built in ``slice`` type, with a hint to callers
This protocol describes the built-in ``slice`` type, with a hint to callers
about what type they should put *inside* the slice. It is for type
annotations only and is not runtime-checkable (i.e., you can't do
``isinstance(thing, Slice)``), because ``range`` objects also have
Expand Down Expand Up @@ -86,7 +86,7 @@ def stop(self) -> Optional[_T_co]: ...
def step(self) -> Optional[_T_co]: ...

if sys.version_info < (3, 10) and not TYPE_CHECKING:
# Python 3.9 and below have a bug where any Protocol with an @property
# Python 3.9 and below have a bug where any Protocol with a @property
# was always regarded as runtime-checkable.
@classmethod
def __subclasscheck__(cls, __subclass: type) -> NoReturn:
Expand Down
11 changes: 11 additions & 0 deletions python-spec/testing/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pytest

from somacore import AffineTransform
from somacore import Axis
from somacore import CoordinateSpace
from somacore import CoordinateTransform
from somacore import IdentityTransform
from somacore import ScaleTransform
Expand All @@ -28,6 +30,15 @@ def check_transform_is_equal(
assert False


def test_coordinate_space():
coord_space = CoordinateSpace(
(Axis("x", unit="nanometer"), Axis("y", unit="nanometer")) # type: ignore[arg-type]
)
assert len(coord_space) == 2
assert coord_space.axis_names == ("x", "y")
assert coord_space[0] == Axis("x", unit="nanometer")


@pytest.mark.parametrize(
("input", "expected"),
[
Expand Down
4 changes: 2 additions & 2 deletions python-spec/update-requirements-txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ TEMPDIR="$(mktemp -d)"
trap "trash $TEMPDIR" EXIT

# The version of Python we want to run lints under.
LINTVER=3.8
LINTVER=3.9

for PYVER in 3.8 3.9 3.10 3.11 3.12; do
for PYVER in 3.9 3.10 3.11 3.12; do
CONDIR="$TEMPDIR/py-$PYVER"
conda create -y -p "$CONDIR" "python=$PYVER"
(
Expand Down

0 comments on commit 89e970b

Please sign in to comment.