Skip to content

Commit c5deee6

Browse files
committed
Drop support for Python 3.6, 3.7, 3.8, 3.9.
These older Python versions have reached end of life, no longer receive even security fixes. What hurts us more, however, is that modern dev tools, such as UV and Ruff, are not aware of Python 3.6, and thus require work-arounds to include it.
1 parent 6806d4d commit c5deee6

File tree

7 files changed

+20
-24
lines changed

7 files changed

+20
-24
lines changed

mph/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
from pathlib import Path
1414
from logging import getLogger
1515

16-
from typing import overload, Iterator
17-
from jpype import JClass
16+
from typing import overload
17+
from collections.abc import Iterator
18+
from jpype import JClass
1819

1920

2021
# The following look-up table is used by the `modules()` method. It is

mph/discovery.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,8 @@ def search_path() -> Path | None:
245245
process = subprocess.run(
246246
command, shell=True, check=True, timeout=3,
247247
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
248-
universal_newlines=True, encoding='UTF-8',
248+
text=True, encoding='UTF-8',
249249
)
250-
# `universal_newlines` instead of `text` to support Python 3.6.
251250
except subprocess.CalledProcessError:
252251
log.debug('Command exited with an error.')
253252
return
@@ -376,14 +375,12 @@ def find_backends() -> list[Backend]:
376375
# Get version information from Comsol server.
377376
command: list[Path | str]
378377
command = server + ['--version']
379-
command[0] = str(command[0]) # Needed to support Python 3.6 and 3.7.
380378
try:
381379
arguments = dict( # noqa: C408 (unnecessary `dict()` call)
382380
check=True, timeout=15,
383381
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
384-
universal_newlines=True, encoding='ascii', errors='ignore',
382+
text=True, encoding='ascii', errors='ignore',
385383
)
386-
# `universal_newlines` instead of `text` to support Python 3.6.
387384
if system == 'Windows':
388385
arguments['creationflags'] = 0x08000000
389386
process = subprocess.run(

mph/model.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
from re import match
1111
from logging import getLogger
1212

13-
from jpype import JClass
14-
from typing import overload, Literal, Iterator
15-
from numpy.typing import ArrayLike, NDArray
16-
from numpy import int32, float64
13+
from jpype import JClass
14+
from typing import overload, Literal
15+
from collections.abc import Iterator
16+
from numpy.typing import ArrayLike, NDArray
17+
from numpy import int32, float64
1718

1819

1920
# The following look-up table is used by the `modules()` method. It maps

mph/node.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
from functools import lru_cache
1212
from logging import getLogger
1313

14-
from typing import TYPE_CHECKING, overload, Iterator, Sequence, Literal
15-
from numpy.typing import ArrayLike, NDArray
16-
from numpy import int32
14+
from typing import TYPE_CHECKING, overload, Literal
15+
from collections.abc import Iterator, Sequence
16+
from numpy.typing import ArrayLike, NDArray
17+
from numpy import int32
1718
if TYPE_CHECKING:
18-
from .model import Model
19+
from .model import Model
1920

2021

2122
log = getLogger(__package__)

mph/server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def __init__(self,
106106
log.error(error)
107107
raise ValueError(error)
108108
command = server + arguments + extra_arguments
109-
command[0] = str(command[0]) # Required for Python 3.6 and 3.7.
110109
process = start(command, stdin=PIPE, stdout=PIPE, errors='ignore')
111110

112111
# Remember the requested port (if any).

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ license = 'MIT'
2121
license-files = ['license.txt']
2222
readme = 'PyPI.md'
2323

24-
requires-python = '>= 3.6'
24+
requires-python = '>= 3.10'
2525
dependencies = [
2626
'JPype1',
2727
'NumPy',
@@ -64,7 +64,7 @@ name = 'mph'
6464
[tool.ruff]
6565
line-length = 79
6666
indent-width = 4
67-
target-version = 'py37'
67+
target-version = 'py310'
6868
include = [
6969
'mph/*.py',
7070
'tests/*.py',
@@ -119,8 +119,6 @@ include = [
119119
'PT012', # `pytest.raises()` with multiple statements
120120
'PT013', # incorrect pytest import
121121
'PTH201', # Never use `Path('.')`.
122-
'UP021', # `universal_newlines` instead of `text`
123-
'UP022', # `PIPE` instead of `capture_output`
124122
'UP024', # Replace `IOError` with `OSError`.
125123
]
126124

tests/test_exit.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
from fixtures import setup_logging
44

5-
from subprocess import run, PIPE
5+
from subprocess import run
66
from pathlib import Path
77
from sys import executable as python
88

99

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

2221

0 commit comments

Comments
 (0)