Skip to content

Commit

Permalink
📌 Update minimum Python version to 3.9
Browse files Browse the repository at this point in the history
Signed-off-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com>
  • Loading branch information
shaneahmed committed Feb 14, 2024
1 parent b6a371b commit 6ec9190
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy-type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pip-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-22.04, windows-latest, macos-latest]
steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Prepare a computer as a convenient platform for further development of the Pytho
5. Create virtual environment for TIAToolbox using

```sh
$ conda create -n tiatoolbox-dev python=3.8 # select version of your choice
$ conda create -n tiatoolbox-dev python=3.9 # select version of your choice
$ conda activate tiatoolbox-dev
$ pip install -r requirements/requirements_dev.txt
```
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ line-length = 88
# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Minimum Python version 3.8.
target-version = "py38"
# Minimum Python version 3.9.
target-version = "py39"

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
Expand All @@ -174,4 +174,4 @@ max-args = 10

[tool.mypy]
ignore_missing_imports = true
python_version = 3.8
python_version = 3.9
2 changes: 1 addition & 1 deletion requirements/requirements.conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies:
- openslide
- pip>=20.0.2
- pixman>=0.39.0
- python>=3.8, <=3.11
- python>=3.9, <=3.12
- pip:
- -r requirements.txt
2 changes: 1 addition & 1 deletion requirements/requirements.dev.conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies:
- openslide
- pip>=20.0.2
- pixman>=0.39.0
- python>=3.8, <=3.11
- python>=3.9, <=3.12
- pip:
- -r requirements_dev.txt
2 changes: 1 addition & 1 deletion requirements/requirements.win64.conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies:
- openjpeg>=2.4.0
- pip>=20.0.2
- pixman>=0.39.0
- python>=3.8, <=3.11
- python>=3.9, <=3.12
- pip:
- -r requirements.txt
2 changes: 1 addition & 1 deletion requirements/requirements.win64.dev.conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies:
- openjpeg>=2.4.0
- pip>=20.0.2
- pixman>=0.39.0
- python>=3.8, <=3.11
- python>=3.9, <=3.12
- pip:
- -r requirements_dev.txt
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
setup(
author="TIA Centre",
author_email="tia@dcs.warwick.ac.uk",
python_requires=">=3.8, <3.12",
python_requires=">=3.9, <3.13",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
description="Computational pathology toolbox developed by TIA Centre.",
dependency_links=dependency_links,
Expand Down
7 changes: 4 additions & 3 deletions tests/test_annotation_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import pickle
import sqlite3
import sys
from collections.abc import Generator
from itertools import repeat, zip_longest
from pathlib import Path
from timeit import timeit
from typing import TYPE_CHECKING, Callable, ClassVar, Generator
from typing import TYPE_CHECKING, Callable, ClassVar

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -1806,8 +1807,8 @@ def test_py38_init(
store_cls: type[AnnotationStore],
monkeypatch: object,
) -> None:
"""Test that __init__ is compatible with Python 3.8."""
py38_version = (3, 8, 0)
"""Test that __init__ is compatible with Python 3.9."""
py38_version = (3, 9, 0)

class Connection(sqlite3.Connection):
"""Mock SQLite connection."""
Expand Down
11 changes: 3 additions & 8 deletions tests/test_app_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@

from __future__ import annotations

import importlib.resources as importlib_resources
import io
import json
import multiprocessing
import re
import sys
import time
from collections.abc import Generator
from pathlib import Path
from typing import TYPE_CHECKING, Generator
from typing import TYPE_CHECKING

import bokeh.models as bkmodels
import matplotlib.pyplot as plt
import numpy as np

if sys.version_info >= (3, 9): # pragma: no cover
import importlib.resources as importlib_resources
else: # pragma: no cover
# To support Python 3.8
import importlib_resources # type: ignore[import-not-found]
import pytest
import requests
from bokeh.application import Application
Expand Down
8 changes: 1 addition & 7 deletions tiatoolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

from __future__ import annotations

import importlib.resources as importlib_resources
import importlib.util
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Dict, TypedDict

if sys.version_info >= (3, 9): # pragma: no cover
import importlib.resources as importlib_resources
else: # pragma: no cover
# To support Python 3.8
import importlib_resources # type: ignore[import-not-found]

import yaml

if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -92,7 +87,6 @@ def read_registry_files(path_to_registry: str | Path) -> dict:
"""
path_to_registry = str(path_to_registry) # To pass tests with Python 3.8
pretrained_files_registry_path = importlib_resources.as_file(
importlib_resources.files("tiatoolbox") / path_to_registry,
)
Expand Down
7 changes: 2 additions & 5 deletions tiatoolbox/annotation/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import zlib
from abc import ABC, abstractmethod
from collections import defaultdict
from collections.abc import MutableMapping
from collections.abc import Generator, Iterable, Iterator, MutableMapping
from dataclasses import dataclass, field
from functools import lru_cache
from pathlib import Path
Expand All @@ -50,9 +50,6 @@
Any,
Callable,
ClassVar,
Generator,
Iterable,
Iterator,
)

import numpy as np
Expand Down Expand Up @@ -2278,7 +2275,7 @@ def register_custom_function(
) -> None:
"""Register a custom SQLite function.
Only Python >= 3.8 supports deterministic functions,
Only Python >= 3.9 supports deterministic functions,
fallback to without this argument if not available.
Args:
Expand Down
8 changes: 1 addition & 7 deletions tiatoolbox/cli/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@

from __future__ import annotations

import importlib.resources as importlib_resources
import os
import subprocess
import sys
from pathlib import Path
from threading import Thread

import click

if sys.version_info >= (3, 9): # pragma: no cover
import importlib.resources as importlib_resources
else: # pragma: no cover
# To support Python 3.8
import importlib_resources # type: ignore[import-not-found]
from flask_cors import CORS

from tiatoolbox.cli.common import tiatoolbox_cli
Expand Down
6 changes: 1 addition & 5 deletions tiatoolbox/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
"""Package to define datasets available to download via TIAToolbox."""
from __future__ import annotations

import importlib.resources as importlib_resources
import sys
import tempfile
import zipfile
from pathlib import Path
from typing import TYPE_CHECKING
from urllib.parse import urlparse

if sys.version_info >= (3, 9): # pragma: no cover
import importlib.resources as importlib_resources
else: # pragma: no cover
import importlib_resources # To support Python 3.8

from tiatoolbox import logger, read_registry_files

if TYPE_CHECKING: # pragma: no cover
Expand Down
6 changes: 1 addition & 5 deletions tiatoolbox/tools/stainextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
from tiatoolbox.utils.transforms import rgb2od

if TYPE_CHECKING: # pragma: no cover
import sys

if sys.version_info >= (3, 9):
from typing import Self
else: # pragma: no cover
from typing_extensions import Self # To support Python 3.8
from typing import Self


def vectors_in_correct_direction(e_vectors: np.ndarray) -> np.ndarray:
Expand Down

0 comments on commit 6ec9190

Please sign in to comment.