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

Remove support for Python 3.9 #2158

Merged
merged 4 commits into from
Oct 14, 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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
PYTEST_ADDOPTS: "--color=yes"
LINTING_PY_VERSION: "3.9" # The version of Python to use for linting (typically the minimum supported)
LINTING_PY_VERSION: "3.10" # The version of Python to use for linting (typically the minimum supported)

# Cancel running workflows when additional changes are pushed
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']

services:
mongo:
Expand Down Expand Up @@ -177,25 +177,25 @@ jobs:
pip install -e .

- name: Run non-server tests
run: pytest -rs -vvv --durations=0 --cov=./optimade/ --cov-report=xml tests/ --ignore tests/server
run: pytest -rs -vvv --durations=10 --cov=./optimade/ --cov-report=xml tests/ --ignore tests/server

- name: Install latest server dependencies
run: pip install -r requirements-server.txt

- name: Run server tests (using `mongomock`)
run: pytest -rs -vvv --durations=0 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
run: pytest -rs -vvv --durations=10 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'

- name: Run server tests with no API validation (using `mongomock`)
run:
pytest -rs -vvv --durations=0 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
pytest -rs -vvv --durations=10 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
OPTIMADE_VALIDATE_API_RESPONSE: false

- name: Run server tests (using a real MongoDB)
run: pytest -rs -vvv --durations=0 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
run: pytest -rs -vvv --durations=10 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd_updated_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ jobs:
fetch-depth: 0
submodules: true

- name: Set up Python 3.9
- name: Set up Python 3.10
if: steps.release_check.outputs.release_run == 'false'
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'

- name: Install dependencies
if: steps.release_check.outputs.release_run == 'false'
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ci:
submodules: true

default_language_version:
python: python3.9
python: python3.10

# pre-commit hooks
repos:
Expand All @@ -32,7 +32,7 @@ repos:
rev: v3.17.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]
args: [--py310-plus]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.6.3'
Expand Down
7 changes: 4 additions & 3 deletions optimade/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"""

import re
from collections.abc import Callable
from json import JSONDecodeError
from typing import Any, Callable, Optional, Union
from typing import Any

from pydantic import BaseModel

Expand Down Expand Up @@ -106,7 +107,7 @@ def convert(self, format: str) -> Any:
return self._converted[format]

@classmethod
def ingest_from(cls, data: Any, format: Optional[str] = None) -> Any:
def ingest_from(cls, data: Any, format: str | None = None) -> Any:
"""Convert desired format to OPTIMADE format.

Parameters:
Expand Down Expand Up @@ -182,7 +183,7 @@ def from_url(cls, url: str) -> Any:

@staticmethod
def _get_model_attributes(
starting_instances: Union[tuple[BaseModel, ...], list[BaseModel]], name: str
starting_instances: tuple[BaseModel, ...] | list[BaseModel], name: str
) -> Any:
"""Helper method for retrieving the OPTIMADE model's attribute, supporting "."-nested attributes"""
for res in starting_instances:
Expand Down
2 changes: 1 addition & 1 deletion optimade/adapters/structures/adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable
from collections.abc import Callable

from optimade.adapters.base import EntryAdapter
from optimade.models import StructureResource
Expand Down
3 changes: 1 addition & 2 deletions optimade/adapters/structures/aiida.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
This conversion function relies on the [`aiida-core`](https://github.com/aiidateam/aiida-core) package.
"""

from typing import Optional
from warnings import warn

from optimade.adapters.structures.utils import pad_cell, species_from_species_at_sites
Expand Down Expand Up @@ -49,7 +48,7 @@ def get_aiida_structure_data(optimade_structure: OptimadeStructure) -> Structure
structure = StructureData(cell=lattice_vectors)

# If species not provided, infer data from species_at_sites
species: Optional[list[OptimadeStructureSpecies]] = attributes.species
species: list[OptimadeStructureSpecies] | None = attributes.species
if not species:
species = species_from_species_at_sites(attributes.species_at_sites) # type: ignore[arg-type]

Expand Down
5 changes: 2 additions & 3 deletions optimade/adapters/structures/pymatgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
For more information on the pymatgen code see [their documentation](https://pymatgen.org).
"""

from typing import Optional, Union
from warnings import warn

from optimade.adapters.structures.utils import (
Expand Down Expand Up @@ -39,7 +38,7 @@
)


def get_pymatgen(optimade_structure: OptimadeStructure) -> Union[Structure, Molecule]:
def get_pymatgen(optimade_structure: OptimadeStructure) -> Structure | Molecule:
"""Get pymatgen `Structure` or `Molecule` from OPTIMADE structure.

This function will return either a pymatgen `Structure` or `Molecule` based
Expand Down Expand Up @@ -109,7 +108,7 @@ def _get_molecule(optimade_structure: OptimadeStructure) -> Molecule:

def _pymatgen_species(
nsites: int,
species: Optional[list[OptimadeStructureSpecies]],
species: list[OptimadeStructureSpecies] | None,
species_at_sites: list[str],
) -> list[dict[str, float]]:
"""
Expand Down
11 changes: 5 additions & 6 deletions optimade/adapters/structures/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

from collections.abc import Iterable
from typing import Optional

from optimade.models.structures import Species as OptimadeStructureSpecies
from optimade.models.structures import Vector3D
Expand Down Expand Up @@ -165,7 +164,7 @@ def unit_vector(x: Vector3D) -> Vector3D:
def cellpar_to_cell(
cellpar: list[float],
ab_normal: tuple[int, int, int] = (0, 0, 1),
a_direction: Optional[tuple[int, int, int]] = None,
a_direction: tuple[int, int, int] | None = None,
) -> list[Vector3D]:
"""Return a 3x3 cell matrix from `cellpar=[a,b,c,alpha,beta,gamma]`.

Expand Down Expand Up @@ -278,9 +277,9 @@ def cellpar_to_cell(

def _pad_iter_of_iters(
iterable: Iterable[Iterable],
padding: Optional[float] = None,
outer: Optional[type] = None,
inner: Optional[type] = None,
padding: float | None = None,
outer: type | None = None,
inner: type | None = None,
) -> tuple[Iterable[Iterable], bool]:
"""Turn any null/None values into a float in given iterable of iterables"""
try:
Expand Down Expand Up @@ -309,7 +308,7 @@ def _pad_iter_of_iters(

def pad_cell(
lattice_vectors: tuple[Vector3D, Vector3D, Vector3D],
padding: Optional[float] = None,
padding: float | None = None,
) -> tuple: # Setting this properly makes MkDocs fail.
"""Turn any `null`/`None` values into a `float` in given `tuple` of
[`lattice_vectors`][optimade.models.structures.StructureResourceAttributes.lattice_vectors].
Expand Down
Loading