Skip to content

Commit

Permalink
Backport Python 3.11 support to 2.3.X (#1727)
Browse files Browse the repository at this point in the history
* Cherry-pick mrbean-bremen py311 last commit

* Update versions, add patch release note

* Add 3.11 to core tests

* Fixing typing warning and spelling mistake

* Pin mypy to a version still supported by Python 3.6

Co-authored-by: mrbean-bremen
  • Loading branch information
darcymason committed Nov 13, 2022
1 parent ef75019 commit ce7424b
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/merge-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- 2.3.X

jobs:
test-all:
Expand All @@ -12,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
include:
- os: ubuntu-latest
python-version: '3.10'
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/merge-typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: type-hints

on:
push:
branches: [ master ]
branches:
- master
- 2.3.X

jobs:

Expand All @@ -12,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pr-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: pr-unit-tests

on:
pull_request:
branches: [ master ]
branches:
- master
- 2.3.X

jobs:
test-pypy:
Expand Down Expand Up @@ -36,7 +38,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.11']
include:
- os: 'ubuntu-latest'
pytest-args: --cov=pydicom --cov-append
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pr-type-lint-spell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: pr-type-lint-spell

on:
pull_request:
branches: [ master ]
branches:
- master
- 2.3.X

jobs:

Expand All @@ -25,7 +27,7 @@ jobs:
- name: Install typing dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U mypy
python -m pip install mypy==0.971
python -m pip install -U types-requests types-pkg_resources types-setuptools
- name: Run typing check with mypy
Expand Down
8 changes: 8 additions & 0 deletions doc/release_notes/v2.3.0.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 2.3.1
=================================

Changes
-------
* updated for Python 3.11 compatibility


Version 2.3.0
=================================

Expand Down
2 changes: 1 addition & 1 deletion pydicom/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import cast, Match


__version__: str = '2.3.0'
__version__: str = '2.3.1'

result = cast(Match[str], re.match(r'(\d+\.\d+\.\d+).*', __version__))
__version_info__ = tuple(result.group(1).split('.'))
Expand Down
4 changes: 3 additions & 1 deletion pydicom/multival.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def extend(self, val: Iterable[_T]) -> None:
"""
self._list.extend([self.type_constructor(x) for x in val])

def __iadd__(self, other: Iterable[_T]) -> MutableSequence[_ItemType]:
def __iadd__( # type: ignore[override]
self, other: Iterable[_T]
) -> MutableSequence[_ItemType]:
"""Implement MultiValue() += Iterable[Any]."""
self._list += [self.type_constructor(x) for x in other]
return self
Expand Down
2 changes: 1 addition & 1 deletion pydicom/pixel_data_handlers/numpy_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_pixeldata(ds: "Dataset", read_only: bool = False) -> "np.ndarray":
'SamplesPerPixel', 'PhotometricInterpretation'
]
if px_keyword[0] == 'PixelData':
# Attributess required by Image Pixel Description Macro Attributes
# Attributes required by Image Pixel Description Macro Attributes
required_elements.extend(['PixelRepresentation', 'BitsStored'])
missing = [elem for elem in required_elements if elem not in ds]
if missing:
Expand Down
5 changes: 4 additions & 1 deletion pydicom/tests/test_fileset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import os
import sys
from pathlib import Path
import shutil
from tempfile import TemporaryDirectory
Expand Down Expand Up @@ -1225,7 +1226,9 @@ def test_path(self, tdir):
"""Test setting the File-set's path."""
fs = FileSet()
assert fs.path is None
with pytest.raises(AttributeError, match=r"can't set attribute"):
msg = (r"can't set attribute" if sys.version_info < (3, 11)
else r"property 'path' of 'FileSet' object has no setter")
with pytest.raises(AttributeError, match=msg):
fs.path = tdir.name

# Test with str
Expand Down
6 changes: 3 additions & 3 deletions pydicom/valuerep.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ class TM(_DateTimeBase, datetime.time):
"""
_RE_TIME = re.compile(
r"(?P<h>^([01][0-9]|2[0-3]))"
r"((?P<m>([0-5][0-9]))?"
r"(?(5)(?P<s>([0-5][0-9]|60))?)"
r"(?(7)(\.(?P<ms>([0-9]{1,6})?))?))$"
r"((?P<m>([0-5][0-9]))"
r"((?P<s>([0-5][0-9]|60))"
r"(\.(?P<ms>([0-9]{1,6})?))?)?)?$"
)

def __new__( # type: ignore[misc]
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def data_files_inventory():
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
"Topic :: Scientific/Engineering :: Physics",
Expand Down

0 comments on commit ce7424b

Please sign in to comment.