Skip to content
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: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Dropping Python 3.9 support (pyupgrade)
d099b3b4bb80a3461f7f174a6c2944aa13b10a05
6 changes: 3 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']
should-release:
- ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
exclude:
Expand All @@ -113,7 +113,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
- name: Benchmarks
working-directory: tests/benchmarks
run: |
poetry run pytest -v --license-server=1055@$LICENSE_SERVER --no-server-log-files --docker-image=$IMAGE_NAME --build-benchmark-image --benchmark-json benchmark_output.json --benchmark-group-by=fullname ${{ (matrix.python-version == '3.9' && github.ref == 'refs/heads/main') && ' ' || '--validate-benchmarks-only' }}
poetry run pytest -v --license-server=1055@$LICENSE_SERVER --no-server-log-files --docker-image=$IMAGE_NAME --build-benchmark-image --benchmark-json benchmark_output.json --benchmark-group-by=fullname ${{ (matrix.python-version == '3.10' && github.ref == 'refs/heads/main') && ' ' || '--validate-benchmarks-only' }}
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
IMAGE_NAME: ${{ env.DOCKER_IMAGE_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']
timeout-minutes: 30

steps:
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py39-plus]
args: [--py310-plus]

- repo: https://github.com/psf/black
rev: "24.4.2" # when changed, also update the version in blacken-docs
rev: "24.8.0" # when changed, also update the version in blacken-docs
hooks:
- id: black

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies: [black==24.4.2]
additional_dependencies: [black==24.8.0]

- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: "7.1.0"
rev: "7.1.1"
hooks:
- id: flake8

Expand Down Expand Up @@ -61,7 +61,7 @@ repos:
]

- repo: https://github.com/ansys/pre-commit-hooks
rev: v0.3.1
rev: v0.4.3
hooks:
- id: add-license-headers
args: ["--start_year", "2022"]
Expand Down
172 changes: 77 additions & 95 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ include = ["src/**/docker-compose.yaml"]
# Less than critical but helpful
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -33,7 +32,7 @@ Issues = "https://github.com/ansys/pyacp/issues"
Releases = "https://github.com/ansys/pyacp/releases"

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
python = ">=3.10,<3.13"
numpy = ">=1.22"
grpcio-health-checking = ">=1.43"
packaging = ">=15.0"
Expand Down Expand Up @@ -139,7 +138,7 @@ ignore-words-list = 'ans,uptodate,notuptodate,eyt'
quiet-level = 3

[tool.mypy]
python_version = "3.9"
python_version = "3.10"
mypy_path = "$MYPY_CONFIG_FILE_DIR/src:$MYPY_CONFIG_FILE_DIR/tests"
disable_error_code = "type-abstract"
show_error_context = true
Expand Down
5 changes: 2 additions & 3 deletions src/ansys/acp/core/_model_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# SOFTWARE.

import os
from typing import Optional

from ._tree_objects.model import Model
from ._utils.visualization import _replace_underscores_and_capitalize
Expand All @@ -40,11 +39,11 @@ class Node:
Children of the node.
"""

def __init__(self, label: str, children: Optional[list["Node"]] = None):
def __init__(self, label: str, children: list["Node"] | None = None):
self.label = label
self.children: list["Node"] = children if children else []

def __str__(self, level: Optional[int] = 0) -> str:
def __str__(self, level: int | None = 0) -> str:
assert level is not None
four_spaces = " "
ret = four_spaces * level + self.label + os.linesep
Expand Down
8 changes: 4 additions & 4 deletions src/ansys/acp/core/_server/direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import dataclasses
import os
import subprocess
from typing import Optional, TextIO, Union
from typing import TextIO

import grpc

Expand All @@ -48,7 +48,7 @@ def _get_latest_ansys_installation() -> str:
if not installations:
raise ValueError("No Ansys installation found.")

def sort_key(version_nr: int) -> Union[int, float]:
def sort_key(version_nr: int) -> int | float:
# prefer regular over student installs
if version_nr < 0:
return abs(version_nr) - 0.5
Expand Down Expand Up @@ -117,7 +117,7 @@ def start(self) -> None:
text=True,
)

def stop(self, *, timeout: Optional[float] = None) -> None:
def stop(self, *, timeout: float | None = None) -> None:
self._process.terminate()
try:
self._process.wait(timeout=timeout)
Expand All @@ -127,7 +127,7 @@ def stop(self, *, timeout: Optional[float] = None) -> None:
self._stdout.close()
self._stderr.close()

def check(self, timeout: Optional[float] = None) -> bool:
def check(self, timeout: float | None = None) -> bool:
channel = grpc.insecure_channel(self.urls[ServerKey.MAIN])
return check_grpc_health(channel=channel, timeout=timeout)

Expand Down
9 changes: 4 additions & 5 deletions src/ansys/acp/core/_server/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import os
import pathlib
import subprocess
from typing import Optional
import uuid

import grpc
Expand Down Expand Up @@ -85,7 +84,7 @@ class DockerComposeLaunchConfig:
default=False,
metadata={METADATA_KEY_DOC: "If true, keep the volume after docker compose is stopped."},
)
compose_file: Optional[str] = dataclasses.field(
compose_file: str | None = dataclasses.field(
default=None,
metadata={
METADATA_KEY_DOC: (
Expand Down Expand Up @@ -134,7 +133,7 @@ def __init__(self, *, config: DockerComposeLaunchConfig):
self._keep_volume = config.keep_volume

if config.compose_file is not None:
self._compose_file: Optional[pathlib.Path] = pathlib.Path(config.compose_file)
self._compose_file: pathlib.Path | None = pathlib.Path(config.compose_file)
else:
self._compose_file = None

Expand Down Expand Up @@ -193,7 +192,7 @@ def start(self) -> None:
cmd, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
)

def stop(self, *, timeout: Optional[float] = None) -> None:
def stop(self, *, timeout: float | None = None) -> None:
# The compose file needs to be passed for all commands with docker-compose 1.X.
# With docker-compose 2.X, this no longer seems to be necessary.
with self._get_compose_file() as compose_file:
Expand All @@ -211,7 +210,7 @@ def stop(self, *, timeout: Optional[float] = None) -> None:
cmd.append("--volumes")
subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def check(self, timeout: Optional[float] = None) -> bool:
def check(self, timeout: float | None = None) -> bool:
for url in self.urls.values():
channel = grpc.insecure_channel(url)
if not check_grpc_health(channel=channel, timeout=timeout):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

from __future__ import annotations

from collections.abc import Iterable, Iterator, MutableSequence
from collections.abc import Callable, Iterable, Iterator, MutableSequence
import sys
import textwrap
from typing import Any, Callable, Protocol, TypeVar, cast, overload
from typing import Any, Concatenate, Protocol, TypeVar, cast, overload

from google.protobuf.message import Message
from typing_extensions import Concatenate, ParamSpec, Self
from typing_extensions import ParamSpec, Self

from .._object_cache import ObjectCacheMixin, constructor_with_cache
from ..base import CreatableTreeObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from typing import Any, Callable, Optional
from collections.abc import Callable
from typing import Any

__all__ = ["wrap_to_string_enum"]

Expand All @@ -37,7 +38,7 @@ def wrap_to_string_enum(
key_converter: Callable[[str], str] = lambda val: val,
value_converter: Callable[[str], str] = lambda val: val.lower(),
doc: str,
explicit_value_list: Optional[tuple[int, ...]] = None,
explicit_value_list: tuple[int, ...] | None = None,
) -> tuple[StrEnum, Callable[[StrEnum], int], Callable[[int], StrEnum]]:
"""Create a string Enum with the same keys as the given protobuf Enum.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# SOFTWARE.

from collections.abc import Iterable
from typing import Union

from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.message import Message
Expand All @@ -39,7 +38,7 @@ def unlink_objects(pb_object: Message) -> None:

def linked_path_fields(
pb_object: Message,
) -> Iterable[tuple[Message, FieldDescriptor, Union[ResourcePath, CollectionPath]]]:
) -> Iterable[tuple[Message, FieldDescriptor, ResourcePath | CollectionPath]]:
"""Get all linked paths from a protobuf object.

Get tuples (parent_message, field_descriptor, {resource_path or collection_path})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

from __future__ import annotations

from collections.abc import Iterable, Iterator, MutableSequence
from collections.abc import Callable, Iterable, Iterator, MutableSequence
from functools import partial
import sys
from typing import Any, Callable, TypeVar, cast, overload
from typing import Any, TypeVar, cast, overload

from grpc import Channel
import numpy as np
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/acp/core/_tree_objects/_grpc_helpers/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

from __future__ import annotations

from collections.abc import Iterator
from typing import Any, Callable, Generic, TypeVar
from collections.abc import Callable, Iterator
from typing import Any, Concatenate, Generic, TypeVar

from grpc import Channel
from typing_extensions import Concatenate, ParamSpec, Self
from typing_extensions import ParamSpec, Self

from ansys.api.acp.v0.base_pb2 import CollectionPath, DeleteRequest, ListRequest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"""
from __future__ import annotations

from collections.abc import Callable
from functools import reduce
from typing import Any, Callable, TypeVar
from typing import Any, TypeVar

from google.protobuf.message import Message

Expand Down
6 changes: 3 additions & 3 deletions src/ansys/acp/core/_tree_objects/_object_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from collections.abc import Iterable
from typing import Any, Callable, TypeVar
from collections.abc import Callable, Iterable
from typing import Any, Concatenate, TypeAlias, TypeVar
from weakref import WeakValueDictionary

from typing_extensions import Concatenate, ParamSpec, Self, TypeAlias
from typing_extensions import ParamSpec, Self

__all__ = ["ObjectCacheMixin", "constructor_with_cache"]

Expand Down
6 changes: 3 additions & 3 deletions src/ansys/acp/core/_tree_objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
from __future__ import annotations

from abc import abstractmethod
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from dataclasses import dataclass
from functools import wraps
import typing
from typing import Any, Callable, Generic, TypeVar, cast
from typing import Any, Concatenate, Generic, TypeAlias, TypeVar, cast

from grpc import Channel
from packaging.version import Version
from packaging.version import parse as parse_version
from typing_extensions import Concatenate, ParamSpec, Self, TypeAlias
from typing_extensions import ParamSpec, Self

from ansys.api.acp.v0.base_pb2 import CollectionPath, DeleteRequest, GetRequest, ResourcePath

Expand Down
3 changes: 2 additions & 1 deletion src/ansys/acp/core/_tree_objects/linked_selection_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

from __future__ import annotations

from collections.abc import Callable
import typing
from typing import Callable, Union
from typing import Union

from typing_extensions import Self

Expand Down
4 changes: 2 additions & 2 deletions src/ansys/acp/core/_tree_objects/modeling_ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

from __future__ import annotations

from collections.abc import Container, Iterable
from collections.abc import Callable, Container, Iterable
import dataclasses
from typing import Any, Callable
from typing import Any

import numpy as np
from typing_extensions import Self
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/acp/core/_tree_objects/stackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

from __future__ import annotations

from collections.abc import Iterable, Sequence
from typing import Any, Callable
from collections.abc import Callable, Iterable, Sequence
from typing import Any

from ansys.api.acp.v0 import stackup_pb2, stackup_pb2_grpc

Expand Down
4 changes: 2 additions & 2 deletions src/ansys/acp/core/_tree_objects/sublaminate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

from __future__ import annotations

from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence
import typing
from typing import Any, Callable, Union, get_args
from typing import Any, Union, get_args

from ansys.api.acp.v0 import sublaminate_pb2, sublaminate_pb2_grpc

Expand Down
4 changes: 2 additions & 2 deletions src/ansys/acp/core/_tree_objects/virtual_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

from __future__ import annotations

from collections.abc import Iterable
from collections.abc import Callable, Iterable
import typing
from typing import Any, Callable
from typing import Any

from ansys.api.acp.v0 import base_pb2, virtual_geometry_pb2, virtual_geometry_pb2_grpc

Expand Down
Loading