Skip to content

Commit

Permalink
Support python 3.13 (#275)
Browse files Browse the repository at this point in the history
* nox: add 3.13 session

* tests: xfail unsupported access to private attrs _drv, _root, _parts

* upath.core: add parser alias for _flavour

* upath.core: replace _make_child_relpath usage in iterdir

* ci: add 3.13 to tests

* upath: update classifier in package metadata

* tests: don't install moto on 3.13 windows for now (skips s3 windows tests)

* upath: prevent pywin32 installation on windows 3.13 until release available
  • Loading branch information
ap-- authored Sep 8, 2024
1 parent b03e845 commit 53eae02
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ['3.8', '3.9', '3.10', '3.11', '3.12']
pyv: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
fsspec: ['']

include:
Expand All @@ -41,6 +41,7 @@ jobs:
PIP_DISABLE_PIP_VERSION_CHECK: ${{ matrix.pyv == '3.8' && matrix.os == 'macos-latest' }}
with:
python-version: ${{ matrix.pyv }}
allow-prereleases: true

- name: Upgrade pip and nox
run: |
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
locations = ("upath",)


@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9"])
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"])
def tests(session: nox.Session) -> None:
# workaround in case no aiohttp binary wheels are available
session.env["AIOHTTP_NO_EXTENSIONS"] = "1"
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 4 - Beta",
]
keywords = ["filesystem-spec", "pathlib"]
Expand All @@ -44,12 +45,13 @@ tests = [
"packaging",
]
dev = [
"adlfs",
"adlfs; python_version<='3.12' or (python_version>'3.12' and os_name!='nt') ",
"aiohttp",
"requests",
"gcsfs",
"s3fs",
"moto[s3,server]",
# exclude moto installation on 3.13 windows until pywin32 wheels are available:
"moto[s3,server]; python_version<='3.12' or (python_version>'3.12' and os_name!='nt') ",
"webdav4[fsspec]",
"paramiko",
"wsgidav",
Expand Down
5 changes: 4 additions & 1 deletion upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def with_suffix(self, suffix: str) -> Self: ...
_protocol_dispatch: bool | None = None
_flavour = LazyFlavourDescriptor()

if sys.version_info >= (3, 13):
parser = _flavour

# === upath.UPath constructor =====================================

def __new__(
Expand Down Expand Up @@ -868,7 +871,7 @@ def iterdir(self) -> Generator[UPath, None, None]:
continue
# only want the path name with iterdir
_, _, name = str_remove_suffix(name, "/").rpartition(self._flavour.sep)
yield self._make_child_relpath(name)
yield self.with_segments(*self.parts, name)

def _scandir(self):
raise NotImplementedError # todo
Expand Down
4 changes: 4 additions & 0 deletions upath/tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ def test_read_with_fsspec(self):
with fs.open(path) as f:
assert f.read() == b"hello world"

@pytest.mark.xfail(
sys.version_info >= (3, 13),
reason="no support for private `._drv`, `._root`, `._parts` in 3.13",
)
def test_access_to_private_api(self):
# DO NOT access these private attributes in your code
p = UPath(str(self.path), **self.path.storage_options)
Expand Down

0 comments on commit 53eae02

Please sign in to comment.