Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 3.9 support #1966

Merged
merged 5 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
- name: List pip dependencies
run: pip list
- name: Run pyupgrade checks
run: pyupgrade --py39-plus $(find . -path ./docs/src -prune -o -name "*.py" -print)
run: pyupgrade --py310-plus $(find . -path ./docs/src -prune -o -name "*.py" -print)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']
steps:
- name: Clone repo
uses: actions/checkout@v4.1.2
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5.0.0
with:
python-version: '3.9'
python-version: '3.10'
- name: Cache dependencies
uses: actions/cache@v4.0.2
id: cache
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
args: [--py310-plus]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
Expand Down
2 changes: 1 addition & 1 deletion docs/user/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ All of these tools should be used from the root of the project to ensure that ou

$ black .
$ isort .
$ pyupgrade --py39-plus $(find . -name "*.py")
$ pyupgrade --py310-plus $(find . -name "*.py")


Flake8, pydocstyle, and mypy won't format your code for you, but they will warn you about potential issues with your code or docstrings:
Expand Down
6 changes: 3 additions & 3 deletions experiments/ssl4eo/download_ssl4eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
from collections import defaultdict
from datetime import date, timedelta
from multiprocessing.dummy import Lock, Pool
from typing import Any, Optional
from typing import Any

import ee
import numpy as np
Expand Down Expand Up @@ -168,7 +168,7 @@ def get_patch(
new_resolutions: list[int],
dtype: str = "float32",
meta_cloud_name: str = "CLOUD_COVER",
default_value: Optional[float] = None,
default_value: float | None = None,
) -> dict[str, Any]:
image = collection.sort(meta_cloud_name).first()
region = ee.Geometry.Point(center_coord).buffer(radius).bounds()
Expand Down Expand Up @@ -214,7 +214,7 @@ def get_random_patches_match(
new_resolutions: list[int],
dtype: str,
meta_cloud_name: str,
default_value: Optional[float],
default_value: float | None,
dates: list[date],
radius: float,
debug: bool = False,
Expand Down
68 changes: 32 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
name = "torchgeo"
description = "TorchGeo: datasets, samplers, transforms, and pre-trained models for geospatial data"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{name = "Adam J. Stewart", email = "ajstewart426@gmail.com"},
Expand All @@ -29,7 +29,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -39,9 +38,8 @@ classifiers = [
dependencies = [
# einops 0.3+ required for einops.repeat
"einops>=0.3",
# fiona 1.8.19+ required to fix erroneous warning
# https://github.com/Toblerity/Fiona/issues/986
"fiona>=1.8.19",
# fiona 1.8.21+ required for Python 3.10 wheels
"fiona>=1.8.21",
# kornia 0.6.9+ required for kornia.augmentation.RandomBrightness
"kornia>=0.6.9",
# lightly 1.4.4+ required for MoCo v3 support
Expand All @@ -50,24 +48,24 @@ dependencies = [
"lightly>=1.4.4,!=1.4.26",
# lightning 2+ required for LightningCLI args + sys.argv support
"lightning[pytorch-extra]>=2",
# matplotlib 3.3.3+ required for Python 3.9 wheels
"matplotlib>=3.3.3",
# numpy 1.19.3+ required by Python 3.9 wheels
"numpy>=1.19.3",
# pandas 1.1.3+ required for Python 3.9 wheels
"pandas>=1.1.3",
# pillow 8+ required for Python 3.9 wheels
"pillow>=8",
# pyproj 3+ required for Python 3.9 wheels
"pyproj>=3",
# rasterio 1.2+ required for Python 3.9 wheels
"rasterio>=1.2",
# rtree 1+ required for len(index), index & index, index | index
# matplotlib 3.5+ required for Python 3.10 wheels
"matplotlib>=3.5",
# numpy 1.21.2+ required by Python 3.10 wheels
"numpy>=1.21.2",
# pandas 1.3.3+ required for Python 3.10 wheels
"pandas>=1.3.3",
# pillow 8.4+ required for Python 3.10 wheels
"pillow>=8.4",
# pyproj 3.3+ required for Python 3.10 wheels
"pyproj>=3.3",
# rasterio 1.3+ required for Python 3.10 wheels
"rasterio>=1.3",
# rtree 1+ required for Python 3.10 wheels
"rtree>=1",
# segmentation-models-pytorch 0.2+ required for smp.losses module
"segmentation-models-pytorch>=0.2",
# shapely 1.7.1+ required for Python 3.9 wheels
"shapely>=1.7.1",
# shapely 1.8+ required for Python 3.10 wheels
"shapely>=1.8",
# timm 0.4.12 required by segmentation-models-pytorch
"timm>=0.4.12",
# torch 1.13+ required by torchvision
Expand All @@ -81,27 +79,25 @@ dynamic = ["version"]

[project.optional-dependencies]
datasets = [
# h5py 3+ required for Python 3.9 wheels
"h5py>=3",
# h5py 3.6+ required for Python 3.10 wheels
"h5py>=3.6",
# laspy 2+ required for laspy.read
"laspy>=2",
# opencv-python 4.4.0.46+ required for Python 3.9 wheels
"opencv-python>=4.4.0.46",
# pycocotools 2.0.5+ required for cython 3+ support
"pycocotools>=2.0.5",
# opencv-python 4.5.4+ required for Python 3.10 wheels
"opencv-python>=4.5.4",
# pycocotools 2.0.7+ required for wheels
"pycocotools>=2.0.7",
# pyvista 0.34.2+ required to avoid ImportError in CI
"pyvista>=0.34.2",
# radiant-mlhub 0.3+ required for newer tqdm support required by lightning
"radiant-mlhub>=0.3",
# rarfile 4+ required for wheels
"rarfile>=4",
# scikit-image 0.18+ required for numpy 1.17+ compatibility
# https://github.com/scikit-image/scikit-image/issues/3655
"scikit-image>=0.18",
# scipy 1.6.2+ required for scikit-image 0.18+ compatibility
"scipy>=1.6.2",
# zipfile-deflate64 0.2+ required for extraction bugfix:
# https://github.com/brianhelba/zipfile-deflate64/issues/19
# scikit-image 0.19+ required for Python 3.10 wheels
"scikit-image>=0.19",
# scipy 1.7.2+ required for Python 3.10 wheels
"scipy>=1.7.2",
# zipfile-deflate64 0.2+ required for Python 3.10 wheels
"zipfile-deflate64>=0.2",
]
docs = [
Expand All @@ -126,7 +122,7 @@ style = [
"isort[colors]>=5.8",
# pydocstyle 6.1+ required for pyproject.toml support
"pydocstyle[toml]>=6.1",
# pyupgrade 2.8+ required for --py39-plus flag
# pyupgrade 2.8+ required for --py310-plus flag
"pyupgrade>=2.8",
]
tests = [
Expand All @@ -151,7 +147,7 @@ Homepage = "https://github.com/microsoft/torchgeo"
Documentation = "https://torchgeo.readthedocs.io"

[tool.black]
target-version = ["py39", "py310"]
target-version = ["py310"]
color = true
skip_magic_trailing_comma = true

Expand All @@ -170,7 +166,7 @@ skip_gitignore = true
color_output = true

[tool.mypy]
python_version = "3.9"
python_version = "3.10"
ignore_missing_imports = true
show_error_codes = true
exclude = "(build|data|dist|docs/src|images|logo|logs|output)/"
Expand Down
26 changes: 13 additions & 13 deletions requirements/min-reqs.old
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ setuptools==61.0.0

# install
einops==0.3.0
fiona==1.8.19
fiona==1.8.21
kornia==0.6.9
lightly==1.4.4
lightning[pytorch-extra]==2.0.0
matplotlib==3.3.3
numpy==1.19.3
pandas==1.1.3
pillow==8.0.0
pyproj==3.0.0
rasterio==1.2.0
matplotlib==3.5.0
numpy==1.21.2
pandas==1.3.3
pillow==8.4.0
pyproj==3.3.0
rasterio==1.3.0.post1
rtree==1.0.0
segmentation-models-pytorch==0.2.0
shapely==1.7.1
shapely==1.8.0
timm==0.4.12
torch==1.13.0
torchmetrics==0.10.0
torchvision==0.14.0

# datasets
h5py==3.0.0
h5py==3.6.0
laspy==2.0.0
opencv-python==4.4.0.46
pycocotools==2.0.5
opencv-python==4.5.4.58
pycocotools==2.0.7
pyvista==0.34.2
radiant-mlhub==0.3.0
rarfile==4.0
scikit-image==0.18.0
scipy==1.6.2
scikit-image==0.19.0
scipy==1.7.2
zipfile-deflate64==0.2.0

# docs
Expand Down
3 changes: 1 addition & 2 deletions tests/data/raster/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.

import os
from typing import Optional

import numpy as np
import rasterio as rio
Expand All @@ -18,7 +17,7 @@ def write_raster(
res: int = RES[0],
epsg: int = EPSG[0],
dtype: str = "uint8",
path: Optional[str] = None,
path: str | None = None,
) -> None:
"""Write a raster file.

Expand Down
5 changes: 2 additions & 3 deletions tests/datasets/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sys
from collections.abc import Iterable
from pathlib import Path
from typing import Optional, Union

import pytest
import torch
Expand Down Expand Up @@ -35,7 +34,7 @@ def __init__(
bounds: BoundingBox = BoundingBox(0, 1, 2, 3, 4, 5),
crs: CRS = CRS.from_epsg(4087),
res: float = 1,
paths: Optional[Union[str, Iterable[str]]] = None,
paths: str | Iterable[str] | None = None,
) -> None:
super().__init__()
self.index.insert(0, tuple(bounds))
Expand Down Expand Up @@ -249,7 +248,7 @@ def sentinel(self, request: SubRequest) -> Sentinel2:
},
],
)
def test_files(self, paths: Union[str, Iterable[str]]) -> None:
def test_files(self, paths: str | Iterable[str]) -> None:
assert 1 <= len(NAIP(paths).files) <= 2

def test_getitem_single_file(self, naip: NAIP) -> None:
Expand Down
7 changes: 3 additions & 4 deletions tests/datasets/test_splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from collections.abc import Sequence
from math import floor, isclose
from typing import Any, Union
from typing import Any

import pytest
from rasterio.crs import CRS
Expand Down Expand Up @@ -65,7 +65,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
],
)
def test_random_bbox_assignment(
lengths: Sequence[Union[int, float]], expected_lengths: Sequence[int]
lengths: Sequence[int | float], expected_lengths: Sequence[int]
) -> None:
ds = CustomGeoDataset(
[
Expand Down Expand Up @@ -255,8 +255,7 @@ def test_roi_split() -> None:
],
)
def test_time_series_split(
lengths: Sequence[Union[tuple[int, int], int, float]],
expected_lengths: Sequence[int],
lengths: Sequence[tuple[int, int] | int | float], expected_lengths: Sequence[int]
) -> None:
ds = CustomGeoDataset(
[
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.

import enum
from typing import Callable
from collections.abc import Callable

import pytest
import torch.nn as nn
Expand Down
4 changes: 2 additions & 2 deletions tests/samplers/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.

import math
from typing import Optional, Union
from typing import Union

import pytest

Expand Down Expand Up @@ -33,7 +33,7 @@
],
)
def test_tile_to_chips(
size: MAYBE_TUPLE, stride: Optional[MAYBE_TUPLE], expected: MAYBE_TUPLE
size: MAYBE_TUPLE, stride: MAYBE_TUPLE | None, expected: MAYBE_TUPLE
) -> None:
bounds = BoundingBox(0, 10, 20, 30, 40, 50)
size = _to_tuple(size)
Expand Down
6 changes: 3 additions & 3 deletions torchgeo/datamodules/agrifieldnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""AgriFieldNet datamodule."""

from typing import Any, Optional, Union
from typing import Any

import kornia.augmentation as K
import torch
Expand All @@ -25,8 +25,8 @@ class AgriFieldNetDataModule(GeoDataModule):
def __init__(
self,
batch_size: int = 64,
patch_size: Union[int, tuple[int, int]] = 256,
length: Optional[int] = None,
patch_size: int | tuple[int, int] = 256,
length: int | None = None,
num_workers: int = 0,
**kwargs: Any,
) -> None:
Expand Down
4 changes: 2 additions & 2 deletions torchgeo/datamodules/chesapeake.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""Chesapeake Bay High-Resolution Land Cover Project datamodule."""

from typing import Any, Optional
from typing import Any

import kornia.augmentation as K
import torch.nn as nn
Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(
test_splits: list[str],
batch_size: int = 64,
patch_size: int = 256,
length: Optional[int] = None,
length: int | None = None,
num_workers: int = 0,
class_set: int = 7,
use_prior_labels: bool = False,
Expand Down
Loading
Loading