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
7 changes: 4 additions & 3 deletions mph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from .config import option

import jpype
import jpype.imports
import jpype.imports # noqa: F401 (imported, but not used)
import os
import faulthandler
from pathlib import Path
from logging import getLogger

from typing import overload, Iterator
from jpype import JClass
from typing import overload
from collections.abc import Iterator
from jpype import JClass


# The following look-up table is used by the `modules()` method. It is
Expand Down
9 changes: 3 additions & 6 deletions mph/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ def search_path() -> Path | None:
process = subprocess.run(
command, shell=True, check=True, timeout=3,
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
universal_newlines=True, encoding='UTF-8',
text=True, encoding='UTF-8',
)
# `universal_newlines` instead of `text` to support Python 3.6.
except subprocess.CalledProcessError:
log.debug('Command exited with an error.')
return
Expand Down Expand Up @@ -376,14 +375,12 @@ def find_backends() -> list[Backend]:
# Get version information from Comsol server.
command: list[Path | str]
command = server + ['--version']
command[0] = str(command[0]) # Needed to support Python 3.6 and 3.7.
try:
arguments = dict( # noqa: C408 (unnecessary dict() call)
arguments = dict( # noqa: C408 (unnecessary `dict()` call)
check=True, timeout=15,
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
universal_newlines=True, encoding='ascii', errors='ignore',
text=True, encoding='ascii', errors='ignore',
)
# `universal_newlines` instead of `text` to support Python 3.6.
if system == 'Windows':
arguments['creationflags'] = 0x08000000
process = subprocess.run(
Expand Down
9 changes: 5 additions & 4 deletions mph/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
from re import match
from logging import getLogger

from jpype import JClass
from typing import overload, Literal, Iterator
from numpy.typing import ArrayLike, NDArray
from numpy import int32, float64
from jpype import JClass
from typing import overload, Literal
from collections.abc import Iterator
from numpy.typing import ArrayLike, NDArray
from numpy import int32, float64


# The following look-up table is used by the `modules()` method. It maps
Expand Down
9 changes: 5 additions & 4 deletions mph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
from functools import lru_cache
from logging import getLogger

from typing import TYPE_CHECKING, overload, Iterator, Sequence, Literal
from numpy.typing import ArrayLike, NDArray
from numpy import int32
from typing import TYPE_CHECKING, overload, Literal
from collections.abc import Iterator, Sequence
from numpy.typing import ArrayLike, NDArray
from numpy import int32
if TYPE_CHECKING:
from .model import Model
from .model import Model


log = getLogger(__package__)
Expand Down
1 change: 0 additions & 1 deletion mph/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def __init__(self,
log.error(error)
raise ValueError(error)
command = server + arguments + extra_arguments
command[0] = str(command[0]) # Required for Python 3.6 and 3.7.
process = start(command, stdin=PIPE, stdout=PIPE, errors='ignore')

# Remember the requested port (if any).
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ license = 'MIT'
license-files = ['license.txt']
readme = 'PyPI.md'

requires-python = '>= 3.6'
requires-python = '>= 3.10'
dependencies = [
'JPype1',
'NumPy',
Expand Down Expand Up @@ -64,7 +64,7 @@ name = 'mph'
[tool.ruff]
line-length = 79
indent-width = 4
target-version = 'py37'
target-version = 'py310'
include = [
'mph/*.py',
'tests/*.py',
Expand Down Expand Up @@ -119,8 +119,6 @@ include = [
'PT012', # `pytest.raises()` with multiple statements
'PT013', # incorrect pytest import
'PTH201', # Never use `Path('.')`.
'UP021', # `universal_newlines` instead of `text`
'UP022', # `PIPE` instead of `capture_output`
'UP024', # Replace `IOError` with `OSError`.
]

Expand Down
2 changes: 1 addition & 1 deletion tests/exit_nojvm_exc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Process exiting with exception when no Java VM is running."""

import mph # noqa F401
import mph # noqa: F401 (imported but not used)


raise RuntimeError
2 changes: 1 addition & 1 deletion tests/exit_nojvm_sys.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Process exiting via `sys.exit()` with no Java VM running."""

import mph # noqa F401
import mph # noqa: F401 (imported but not used)

import sys

Expand Down
7 changes: 3 additions & 4 deletions tests/test_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

from fixtures import setup_logging

from subprocess import run, PIPE
from subprocess import run
from pathlib import Path
from sys import executable as python


def run_script(name):
def run_script(name: str):
# Runs the named script from the project's root folder so that coverage
# reporting doesn't get confused about source file locations.
here = Path(__file__).resolve().parent
file = here/name
assert file.is_file()
assert file.suffix == '.py'
root = here.parent
process = run([python, str(file)], cwd=root,
stdout=PIPE, stderr=PIPE, universal_newlines=True)
process = run([python, file], cwd=root, capture_output=True, text=True)
return process


Expand Down