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

build: drop support for python3.7 #245

Merged
merged 2 commits into from
Feb 19, 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
20 changes: 0 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,16 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
platform: [ubuntu-latest, macos-latest, windows-latest]
include:
- python-version: "3.7"
platform: ubuntu-latest

steps:
- uses: actions/checkout@v4

# we can't actually do the codegen on python3.7
# (there's an issue with jinja template ordering)
# so we build wheel before installing python 3.7
- name: Build Wheel
if: matrix.python-version == '3.7'
run: |
pip install -U pip build
python -m build --wheel

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install (3.7)
if: matrix.python-version == '3.7'
run: |
whl=$(ls dist/*.whl)
python -m pip install "${whl}[test,dev]"

- name: Install
if: matrix.python-version != '3.7'
run: |
python -m pip install -U pip
python -m pip install .[test,dev]
Expand All @@ -78,7 +59,6 @@ jobs:
pytest --cov --cov-report=xml --cov-append

- uses: codecov/codecov-action@v4
if: matrix.python-version != '3.7'
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "ome-types"
description = "Python dataclasses for the OME data model"
keywords = ["ome", "ome-model", "microscopy", "schema", "types"]
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
license = { text = "MIT" }
authors = [{ name = "Talley Lambert", email = "talley.lambert@gmail.com" }]
classifiers = [
Expand All @@ -21,7 +21,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -33,7 +32,6 @@ dependencies = [
"pydantic >=1.9.0",
"pydantic-compat >=0.1.0",
"xsdata >=23.6, <25",
"importlib_metadata; python_version < '3.8'",
]

[project.urls]
Expand Down Expand Up @@ -93,7 +91,7 @@ exclude = ["src/ome_types/_autogenerated"]
[tool.ruff]
line-length = 88
src = ["src", "tests"]
target-version = "py37"
target-version = "py38"
select = [
"E", # style errors
"F", # flakes
Expand Down
13 changes: 0 additions & 13 deletions src/ome_autogen/_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import sys
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Iterator, NamedTuple, cast
Expand Down Expand Up @@ -180,18 +179,6 @@ def class_params(self, obj: Class) -> Iterator[tuple[str, str, str]]: # type: i
# https://github.com/tefra/xsdata/issues/818
# The type ignore is because xsdata returns an iterator of 2-tuples
# but we want to return a 3-tuple.
if sys.version_info < (3, 8): # pragma: no cover
# i don't know why, but in python 3.7, it's not picking up our
# template ... so this method yields too many values to unpack
# xsdata/formats/dataclass/templates/docstrings.numpy.jinja2", line 6
# {%- for var_name, var_doc in obj | class_params %}
# ValueError: too many values to unpack (expected 2)
# however, it's not at all important that we be able to build docs correctly
# on python 3.7. The built wheel will still work fine (and won't be built
# on python 3.7 anyway)
yield from super().class_params(obj)
return

for attr in obj.attrs:
name = attr.name
name = (
Expand Down
6 changes: 3 additions & 3 deletions src/ome_autogen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ome_autogen._transformer import OMETransformer

BLACK_LINE_LENGTH = 88
BLACK_TARGET_VERSION = "py37"
BLACK_TARGET_VERSION = "py38"
BLACK_SKIP_TRAILING_COMMA = False # use trailing commas as a reason to split lines?
OUTPUT_PACKAGE = "ome_types._autogenerated.ome_2016_06"
DO_MYPY = os.environ.get("OME_AUTOGEN_MYPY", "0") == "1" or "--mypy" in sys.argv
Expand Down Expand Up @@ -106,8 +106,8 @@ def _print_green(text: str) -> None:

KWARGS_MODULE = """
from __future__ import annotations
from typing_extensions import TypedDict, TypeAlias
from typing import Union, List
from typing_extensions import TypeAlias
from typing import Union, List, TypedDict
from datetime import datetime
import ome_types.model as ome

Expand Down
5 changes: 1 addition & 4 deletions src/ome_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError: # pragma: no cover
from importlib_metadata import PackageNotFoundError, version # type: ignore
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("ome-types")
Expand Down
3 changes: 1 addition & 2 deletions src/ome_types/_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@


if TYPE_CHECKING:
from typing import Any, BinaryIO, ContextManager, TypedDict
from typing import Any, BinaryIO, ContextManager, Literal, TypedDict
from xml.etree import ElementTree

import xmlschema
from lxml.etree import _XSLTResultTree
from typing_extensions import Literal
from xsdata.formats.dataclass.parsers.mixins import XmlHandler

from ome_types._mixins._base_type import OMEType
Expand Down
3 changes: 2 additions & 1 deletion src/ome_types/_mixins/_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from ome_types._pydantic_compat import field_regex

if TYPE_CHECKING:
from typing import Final

from pydantic import BaseModel
from typing_extensions import Final

# Default value to support automatic numbering for id field values.
AUTO_SEQUENCE: Final = "__auto_sequence__"
Expand Down
7 changes: 1 addition & 6 deletions src/ome_types/_vendor/_pydantic_color_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
import sys
import typing
from colorsys import hls_to_rgb, rgb_to_hls
from typing import TYPE_CHECKING, Any, Callable, Tuple, Union, cast

if sys.version_info >= (3, 8): # pragma: no cover
from typing import Literal
else: # pragma: no cover
from typing_extensions import Literal
from typing import TYPE_CHECKING, Any, Callable, Tuple, Union, cast, Literal

from pydantic_core import CoreSchema, PydanticCustomError, core_schema

Expand Down
1 change: 0 additions & 1 deletion tests/test_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def imports_autogen(monkeypatch: MonkeyPatch) -> None:


@pytest.mark.filterwarnings("ignore:Support for class-based::pydantic")
@pytest.mark.skipif(sys.version_info < (3, 8), reason="docs fail on python3.7")
@pytest.mark.skipif(not os.getenv("CI"), reason="slow")
@pytest.mark.usefixtures("imports_autogen")
def test_autogen(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import datetime
import io
import sys
import warnings
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -206,7 +205,6 @@ def test_update_unset(pixels: model.Pixels) -> None:
assert from_xml(xml) == ome


@pytest.mark.skipif(sys.version_info < (3, 8), reason="transform doesn't work on 3.7")
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
def test_transformations() -> None:
from ome_types import etree_fixes
Expand Down
2 changes: 0 additions & 2 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import pickle
import re
import sys
from functools import lru_cache
from pathlib import Path
from typing import TYPE_CHECKING, cast
Expand Down Expand Up @@ -75,7 +74,6 @@ def test_dict_roundtrip(valid_xml: Path) -> None:
assert ome1 == ome2


@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires python3.8 or higher")
def test_xml_roundtrip(valid_xml: Path) -> None:
"""Ensure we can losslessly round-trip XML through the model and back."""
if true_stem(valid_xml) in SKIP_ROUNDTRIP:
Expand Down
Loading