Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python 3.13 compatibility #3728

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/python-ci-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

matrix:
os: [ubuntu-24.04, macos-latest]
python-version: ['3.9', '3.12']
python-version: ['3.9', '3.12', '3.13']
include:
- os: ubuntu-24.04
cc: gcc-13
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/python-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '39', '310', '311', '312' ]
python-version: [ '39', '310', '311', '312', '313' ]
cibw_build: [ manylinux_x86_64, macosx_x86_64, macosx_arm64 ]
include:
- cibw_build: manylinux_x86_64
Expand Down Expand Up @@ -134,6 +134,8 @@ jobs:
dotted-version: '3.11'
- undotted-version: '312'
dotted-version: '3.12'
- undotted-version: '313'
dotted-version: '3.13'
wheel-name:
- manylinux_2_28
- macos-x86_64
Expand Down
1 change: 1 addition & 0 deletions apis/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def run(self):
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
package_dir={"": "src"},
packages=setuptools.find_packages("src"),
Expand Down
26 changes: 18 additions & 8 deletions apis/python/src/tiledbsoma/io/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import pathlib
import sys
from contextlib import contextmanager
from typing import (
ContextManager,
Expand Down Expand Up @@ -74,16 +75,25 @@
so here we just proxy all attributes except ``__fspath__``.
"""

def __new__(cls, _obj: object, path: Path) -> "_FSPathWrapper":
return super().__new__(cls, path)
if sys.version_info >= (3, 12):

# ``pathlib.Path`` construction references this attribute (``PosixFlavour`` or ``WindowsFlavour``)
_flavour = pathlib.Path().__class__._flavour # type: ignore[attr-defined]
def __init__(self, obj: object, path: Path) -> None:
super().__init__(path)
self._obj = obj
self._path = path

def __init__(self, obj: object, path: Path) -> None:
super().__init__()
self._obj = obj
self._path = path
else:

def __new__(cls, _obj: object, path: Path) -> "_FSPathWrapper":

Check warning on line 87 in apis/python/src/tiledbsoma/io/_util.py

View check run for this annotation

Codecov / codecov/patch

apis/python/src/tiledbsoma/io/_util.py#L87

Added line #L87 was not covered by tests
return super().__new__(cls, path)

# ``pathlib.Path`` construction references this attribute (``PosixFlavour`` or ``WindowsFlavour``)
_flavour = pathlib.Path().__class__._flavour # type: ignore[attr-defined]

Check warning on line 91 in apis/python/src/tiledbsoma/io/_util.py

View check run for this annotation

Codecov / codecov/patch

apis/python/src/tiledbsoma/io/_util.py#L91

Added line #L91 was not covered by tests

def __init__(self, obj: object, path: Path) -> None:
super().__init__()
self._obj = obj
self._path = path

Check warning on line 96 in apis/python/src/tiledbsoma/io/_util.py

View check run for this annotation

Codecov / codecov/patch

apis/python/src/tiledbsoma/io/_util.py#L93-L96

Added lines #L93 - L96 were not covered by tests

def __fspath__(self) -> str:
return self._path if isinstance(self._path, str) else str(self._path)
Expand Down
Loading