Skip to content

Commit

Permalink
Merge branch 'main' into maint/activate_2d_meshing_tests_for_251
Browse files Browse the repository at this point in the history
  • Loading branch information
prmukherj authored Sep 11, 2024
2 parents b19db6e + 95666ae commit 60488aa
Show file tree
Hide file tree
Showing 59 changed files with 547 additions and 573 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Getting started

Launching Fluent
~~~~~~~~~~~~~~~~
To launch Fluent from Python, use the ``launch_fluent`` method:
To launch Fluent from Python, use the ``launch_fluent`` function:

.. code:: python
Expand Down
7 changes: 2 additions & 5 deletions doc/rstgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pathlib
from pathlib import Path
import re
from typing import Optional

_THIS_DIRNAME = os.path.dirname(__file__)

Expand Down Expand Up @@ -167,9 +166,7 @@ def _get_menu_name_path(menu: type, is_datamodel: bool):
return full_name, full_path


def _get_docdir(
mode: str, path: Optional[str] = None, is_datamodel: Optional[bool] = None
):
def _get_docdir(mode: str, path: str | None = None, is_datamodel: bool | None = None):
"""Get tui doc directory to generate all RST files.
Parameters
Expand All @@ -191,7 +188,7 @@ def _get_docdir(
return doc_path / f"doc/source/api/{mode}/tui/{path}"


def _get_path(mode: str, is_datamodel: Optional[bool] = None):
def _get_path(mode: str, is_datamodel: bool | None = None):
"""Get datamodel_* or tui_*.py file path.
Parameters
Expand Down
11 changes: 5 additions & 6 deletions docker/copy_docker_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
from pathlib import Path
import shutil
import sys
from typing import Union


def create_file_folders_list(files_list: list, fluent_version: Union[Path, str]):
def create_file_folders_list(files_list: list, fluent_version: Path | str):
"""Create a list of files and folders specified in a text file.
Parameters
----------
files_list: list
List of text files containing relative paths of files and folders.
fluent_version: Union[Path, str]
fluent_version: Path | str
Path of ``docker/fluent_<version>`` folder.
Returns
Expand All @@ -29,14 +28,14 @@ def create_file_folders_list(files_list: list, fluent_version: Union[Path, str])
return file_folders


def copy_files(src: Union[Path, str], fluent_version: Union[Path, str]):
def copy_files(src: Path | str, fluent_version: Path | str):
"""Copy files from the Ansys installation directory.
Parameters
----------
src: Union[Path, str]
src: Path | str
Path of ``ansys_inc`` folder in the Ansys installation directory.
fluent_version: Union[Path, str]
fluent_version: Path | str
Path of ``docker/fluent_<version>`` folder.
"""
copy_files = ["cadList.txt", "ceiList.txt", "cfdpostList.txt", "fluentList.txt"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Client side implementation of the stand-alone datamodel server."""

from pathlib import Path
from typing import Union

import grpc

Expand All @@ -12,7 +11,7 @@
from tests.run_stateengine_server import kill_server, run_server


def run_datamodel_server(batch_file_name: Union[str, Path], rules):
def run_datamodel_server(batch_file_name: str | Path, rules):
"""Run the datamodel server."""
run_command = str(batch_file_name) + " " + rules
run_server(run_command)
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/fluent/core/codegen/settingsgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ def __init__(self, doc, args_info):
_arg_type_strings = {
flobject.Boolean: "bool",
flobject.Integer: "int",
flobject.Real: "Union[float, str]",
flobject.Real: "float | str",
flobject.String: "str",
flobject.Filename: "str",
flobject.BooleanList: "List[bool]",
flobject.IntegerList: "List[int]",
flobject.RealVector: "Tuple[Union[float, str], Union[float, str], Union[float, str]",
flobject.RealList: "List[Union[float, str]]",
flobject.RealVector: "Tuple[float | str, float | str, float | str",
flobject.RealList: "List[float | str]",
flobject.StringList: "List[str]",
flobject.FilenameList: "List[str]",
}
Expand Down
28 changes: 14 additions & 14 deletions src/ansys/fluent/core/data_model_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
import copy
from enum import Enum
from threading import RLock
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List

from ansys.api.fluent.v0.variant_pb2 import Variant

StateType = Union[
bool,
int,
float,
str,
List[bool],
List[int],
List[float],
List[str],
List["StateType"],
Dict[str, "StateType"],
]
StateType = (
bool
| int
| float
| str
| List[bool]
| List[int]
| List[float]
| List[str]
| List["StateType"]
| Dict[str, "StateType"]
)


class NameKey(Enum):
Expand Down Expand Up @@ -292,7 +292,7 @@ def _dm_path_comp_list(obj):
return [DataModelCache._dm_path_comp(comp) for comp in obj.path]

def get_state(
self, rules: str, obj: object, name_key: Optional[NameKey] = None
self, rules: str, obj: object, name_key: NameKey | None = None
) -> Any:
"""Retrieve state from datamodel cache.
Expand Down
13 changes: 6 additions & 7 deletions src/ansys/fluent/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pathlib import Path
import re
import shutil
from typing import Optional
import warnings
import zipfile

Expand Down Expand Up @@ -44,7 +43,7 @@ def _decompress(file_name: str) -> None:
return zip_ref.close()


def _get_file_url(file_name: str, directory: Optional[str] = None) -> str:
def _get_file_url(file_name: str, directory: str | None = None) -> str:
"""Get file URL."""
if directory:
return (
Expand All @@ -57,8 +56,8 @@ def _get_file_url(file_name: str, directory: Optional[str] = None) -> str:
def _retrieve_file(
url: str,
file_name: str,
save_path: Optional[str] = None,
return_without_path: Optional[bool] = False,
save_path: str | None = None,
return_without_path: bool | None = False,
) -> str:
"""Download specified file from specified URL."""
file_name = os.path.basename(file_name)
Expand Down Expand Up @@ -110,9 +109,9 @@ def _retrieve_file(

def download_file(
file_name: str,
directory: Optional[str] = None,
save_path: Optional[str] = None,
return_without_path: Optional[bool] = None,
directory: str | None = None,
save_path: str | None = None,
return_without_path: bool | None = None,
) -> str:
"""Download specified example file from the Ansys example data repository.
Expand Down
8 changes: 4 additions & 4 deletions src/ansys/fluent/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Custom common higher level exceptions."""

from typing import Any, Optional
from typing import Any

from ansys.fluent.core.solver.error_message import allowed_name_error_message

Expand All @@ -10,9 +10,9 @@ class DisallowedValuesError(ValueError):

def __init__(
self,
context: Optional[Any] = None,
name: Optional[Any] = None,
allowed_values: Optional[Any] = None,
context: Any | None = None,
name: Any | None = None,
allowed_values: Any | None = None,
):
super().__init__(
allowed_name_error_message(
Expand Down
Loading

0 comments on commit 60488aa

Please sign in to comment.