Skip to content

Commit

Permalink
Support Python 3.12 (#152)
Browse files Browse the repository at this point in the history
Implement Python 3.12 support in UPath:

* initial work on py312 support
* tests: don't test private interface
* core312plus: remove commented pathlib functionality
* cloud, local and memory versions
* upath.core version switch in init
* tests: xfail some tests on python3.12
* tests: fix minor issues with tests
* tests: DummyFS should overwrite _strip_protocol too
* upath.core imports and minor fixes
* ci: enable 3.12 tests
* test: fix private url attr test
* upath: fix subclassing issue
* local: inherit __init__ from UPath
* upath.implementations.cloud: deprecate lists as args to joinpath
* upath.implementations.cloud: use correct flavour/pathmod
* tests: xfail non-applicable __new__ test
* upath.core312plus: fix typing issues
* upath: 312 fix glob
* upath: fix relative_to issues
* tests: add missing nox session
* tests: adjust webdav test to include base_url in storage_options
* upath.implementations.local: remove debugging print
* upath: make storage_options readonly
* upath: minor error message improvement
* upath: fix pickling issue if subclasses change __init__ args
* tests: relax kwargs test
* upath.implementations.webdav: working webdav implementation
* upath.implementations.azure: fix touch
* tests: update for empty parts paths
* upath: working http implementation
* upath: working hdfs implementation
* upath: always add netloc to ensure fsspec compatibility
* upath: add memory path and rework netloc handling for memory
* upath: fix parts handling for http
* tests: update pathlib 3.12 tests
* upath: fix os.Pathlike support in get_upath_protocol
* fix mypy issues
* upath.registry: clear implementation cache when overriding registration
* upath.implementations.local: on 3.12 keep UPath.with_segments and storage_options
* upath: make instance creation in UPath.__new__ more explicit
* upath: on 3.12 add some comments regarding missing functionality
* tests: minor adjustments to pathlib compatibility tests on 3.12
* upath: py312 UPath.__new__ further clarify behavior
* tests: minor fixes in tests
* upath: refactor local implementation
* typing: ignore types for __new__ in PosixUPath/WindowsUPath
* upath.implementations.local: fix FilePath superclass
* tests: windows 3.12 walk recursion tests increase recursion_limit for test
* upath.implementations.memory: normalize to two slashes for py312 and adjust tests for netloc only memory path
* tests: adjust pathlib tests to accommodate fix from py-3.12.1
* upath: switch to FSSpecFlavour implementation
* nox: always set aiohttp workaround
* nox: disable mypy in lint session for now
* tests: update pytest and plugins
  • Loading branch information
ap-- authored Jan 30, 2024
1 parent a7cc6e6 commit f7af174
Show file tree
Hide file tree
Showing 22 changed files with 1,194 additions and 153 deletions.
2 changes: 1 addition & 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']
pyv: ['3.8', '3.9', '3.10', '3.11', '3.12']
fsspec: ['']

include:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
exclude: ^upath/tests/pathlib/test_pathlib.*\.py|^upath/tests/pathlib/_test_support\.py
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -30,7 +30,7 @@ repos:
- id: codespell
additional_dependencies: ["tomli"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.6.0
rev: v3.13.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand All @@ -39,7 +39,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
10 changes: 6 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
locations = ("upath",)


@nox.session(python=["3.8", "3.9", "3.10", "3.11", "pypy3.8", "pypy3.9"])
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9"])
def tests(session: nox.Session) -> None:
# workaround in case no aiohttp binary wheels are available
session.env["AIOHTTP_NO_EXTENSIONS"] = "1"
session.install(".[dev]")
session.run(
"pytest",
Expand Down Expand Up @@ -44,7 +46,7 @@ def lint(session: nox.Session) -> None:

args = *(session.posargs or ("--show-diff-on-failure",)), "--all-files"
session.run("pre-commit", "run", *args)
session.run("python", "-m", "mypy")
# session.run("python", "-m", "mypy")
# session.run("python", "-m", "pylint", *locations)


Expand Down Expand Up @@ -86,8 +88,8 @@ def black(session):

@nox.session
def type_checking(session):
print("please run `nox -s lint` instead")
raise SystemExit(1)
session.install("-e", ".[tests]")
session.run("python", "-m", "mypy")


@nox.session()
Expand Down
14 changes: 7 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ install_requires=

[options.extras_require]
tests =
pytest==7.3.2
pytest-sugar==0.9.6
pytest==8.0.0
pytest-sugar==0.9.7
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-mock==3.12.0
pylint==2.17.4
mypy==1.3.0
mypy==1.8.0
packaging
dev =
%(tests)s
Expand All @@ -41,12 +41,12 @@ dev =
requests
gcsfs
s3fs
moto[s3,server]
moto[s3,server]<5
webdav4[fsspec]
wsgidav
cheroot
hadoop-test-cluster
pyarrow
# hadoop-test-cluster
# pyarrow
pydantic
pydantic-settings

Expand Down
12 changes: 11 additions & 1 deletion upath/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
"""Pathlib API extended to use fsspec backends."""
from upath.core import UPath
import sys

try:
from upath._version import __version__
except ImportError:
__version__ = "not-installed"

if sys.version_info >= (3, 12):
import upath.core312plus as core

sys.modules["upath.core"] = core

else:
import upath.core as core

UPath = core.UPath

__all__ = ["UPath"]
Loading

0 comments on commit f7af174

Please sign in to comment.