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
10 changes: 4 additions & 6 deletions gmsh_interop/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,10 @@

@memoize_method
def gmsh_node_tuples(self) -> NodeTuples:
result: list[tuple[int, ...]] = []
for tup in generate_triangle_vertex_tuples(self.order):
result.append(tup)
for tup in generate_triangle_edge_tuples(self.order):
result.append(tup)
return result
return [
*generate_triangle_vertex_tuples(self.order),
*generate_triangle_edge_tuples(self.order)
]


class GmshTriangularElement(GmshSimplexElementBase):
Expand Down Expand Up @@ -606,7 +604,7 @@
"""
from gmsh_interop.runner import GmshRunner

runner = GmshRunner(source, dimensions, order=order,

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.

Check warning on line 607 in gmsh_interop/reader.py

View workflow job for this annotation

GitHub Actions / Pytest Conda Py3

Not specifying target_unit is deprecated. Set target_unit='MM' to retain prior behavior.
other_options=other_options, extension=extension,
gmsh_executable=gmsh_executable,
target_unit=target_unit,
Expand Down
14 changes: 7 additions & 7 deletions gmsh_interop/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from typing import TYPE_CHECKING, Literal, TextIO, TypeAlias

from packaging.version import Version
from typing_extensions import Self

from pytools import memoize_method

Expand Down Expand Up @@ -247,7 +248,7 @@ def version(self) -> Version:

return result

def __enter__(self) -> GmshRunner:
def __enter__(self) -> Self:
self.temp_dir_mgr = None
temp_dir_mgr = _TempDirManager()
try:
Expand Down Expand Up @@ -277,7 +278,7 @@ def __enter__(self) -> GmshRunner:
copyfile(f, join(working_dir, basename(f)))

else:
raise RuntimeError("'source' type unrecognized")
raise TypeError(f"'source' type unrecognized: {type(self.source)}")

# gmsh uses a "~/.gmsh-tmp" by default as a temporary file name.
# Unfortunately, GMSH also automatically prepends the home
Expand Down Expand Up @@ -387,10 +388,10 @@ def __enter__(self) -> GmshRunner:
i, _o, _e = select.select([sys.stdin], [], [], 10)
if i:
resp = sys.stdin.readline().strip()
if resp == "N" or resp == "n":
if resp in {"N", "n"}:
logger.info("Not overwriting.")
decision = 0
elif resp == "Y" or resp == "y" or not i:
elif resp in {"Y", "y"} or not i:
decision = 1
logger.info("Overwriting.")
else:
Expand All @@ -406,14 +407,13 @@ def __enter__(self) -> GmshRunner:
except OSError as exc:
if exc.errno == errno.ENOTDIR:
shutil.copy(tmp_output_file_path,
"/".join([self.save_tmp_files_in,
self.output_file_name]))
join(self.save_tmp_files_in, self.output_file_name))
else:
raise

self.temp_dir_mgr = temp_dir_mgr

return self
return self # noqa: TRY300
except Exception:
temp_dir_mgr.clean_up()
raise
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ classifiers = [
]
dependencies = [
"numpy>=1.6.0",
"pytools>=2022.1.14",
"packaging>=20.0",
"pytools>=2022.1.14",
"typing_extensions>=4.6"
]

[project.optional-dependencies]
Expand Down Expand Up @@ -76,6 +77,10 @@ extend-ignore = [
"UP032", # use f-strings instead of .format
]

[tool.ruff.lint.per-file-ignores]
"test/test_*.py" = ["S102"]
"doc/conf.py" = ["S102", "DTZ002"]

[tool.ruff.lint.flake8-quotes]
inline-quotes = "double"
docstring-quotes = "double"
Expand Down
Loading