Skip to content

Commit

Permalink
Offer improved customization options for user subclasses of UPath (#173)
Browse files Browse the repository at this point in the history
* customizable fsspec filesystem factory
* upath.core: fix _default_accessor override error
* upath.core: fix _fs_factory call
* upath.core: create a patched subclass for _fs_factory
* upath.core: fix has_custom_fs_factory check
* upath._protocol: move to upath protocol parsing
* tests: allow setting azurite port through envvar
* upath._flavour: factor out FSSpecFlavour
* upath._protocol: add 'data' protocol matching
* upath: allow customization of init args for UPath 3.12+
* upath._protocol: add allow_unkown kwarg for strip_upath_protocol
* upath.registry: correct class for fsspec file/local
* upath._flavour: allow unknown protocol
* upath: use single implementation
* upath: make flavour compatible with py3.8+
* upath.implementations: simplify UPath subclasses
* upath: provide single UPath implementation
* tests: skip/xfail obsolete tests
* tests: memory fs normalization now passes on py38+
* upath: typo fixes in implementations.local
* upath.implementations.local: fix issues with py312 base
* upath.implementations.local: fix minor issue in init for WindowsUPath
* tests: update pathlib3.12 tests to register subclasses
* upath.core: don't promote local paths with storage_options to FilePath
* upath.implementations.webdav: fix webdav for older fsspec versions
* upath.core: port glob fix for older fsspec version
* upath.core: remove inconsistent typing
* upath: fix typing issues
* repo: update pre-commit-config
* readme: adjust LocalPath -> FilePath
* upath: deprecate accessors more gracefully
* upath.core: _accessor shim can't use property
* upath.implementations.local: fix iterdir for fsspec local paths when called on a file
* upath._compat: fix warnings._deprecated is missing on older pythons
* upath.core: try to provide backwards compatibility for custom __new__ methods
* upath: align all migration related deprecation warnings
* upath.core: add comment explainin _protocol_dispatch
* tests: some subclassing tests in the pathlib3.12 test suite xpass
* tests: test the migration compat code with a GitHub implementation
* tests: add comment regarding webdav test
* tests: run github migration test only if GITHUB_TOKEN in env
* tests: make pathlib3.12 tests succeed
* upath.core: warn when importing _UriFlavour or PT
* upath.core: improve comment regarding storage_options combination
* upath._compat: fix backwards compat for custom accessors
* upath: backwards compat support for _drv, _root, and _parts
* upath: add comment regarding _url
* upath: backward compat support for _path
* upath: provide missing deprecated classmethods on py312
* upath: provide storage_options customization classmethod
  • Loading branch information
ap-- authored Feb 8, 2024
1 parent f7af174 commit 5c240c1
Show file tree
Hide file tree
Showing 28 changed files with 2,047 additions and 2,069 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ 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.9.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -25,30 +25,30 @@ repos:
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies: ["tomli"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.1.20
- flake8-comprehensions==3.10.1
- flake8-bugbear==24.1.17
- flake8-comprehensions==3.14.0
- flake8-debugger==4.1.2
- flake8-string-format==0.3.0
- repo: https://github.com/pycqa/bandit
rev: 1.7.5
rev: 1.7.7
hooks:
- id: bandit
args: [-c, pyproject.toml]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For more examples, see the [example notebook here](notebooks/examples.ipynb)

### Currently supported filesystems (and schemes)

- `file:` Local filessystem
- `file:` Local filesystem
- `memory:` Ephemeral filesystem in RAM
- `az:`, `adl:`, `abfs:` and `abfss:` Azure Storage (requires `adlfs` to be installed)
- `http:` and `https:` HTTP(S)-based filesystem
Expand Down Expand Up @@ -99,7 +99,7 @@ flowchart TB
U(UPath)
UP(PosixUPath)
UW(WindowsUPath)
UL(LocalPath)
UL(FilePath)
US3(S3Path)
UH(HttpPath)
UO(...Path)
Expand Down Expand Up @@ -168,13 +168,13 @@ register_implementation(my_protocol, MyPath)

#### Registration via entry points

```toml
```
# pyproject.toml
[project.entry-points."unversal_pathlib.implementations"]
myproto = "my_module.submodule:MyPath"
```

```ini
```
# setup.cfg
[options.entry_points]
universal_pathlib.implementations =
Expand Down
3 changes: 1 addition & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Automation using nox."""

import glob
import os

Expand Down Expand Up @@ -46,8 +47,6 @@ 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", "pylint", *locations)


@nox.session
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module = "fsspec.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "webdav4.fsspec.*"
module = "webdav4.*"
ignore_missing_imports = true

[tool.pylint.format]
Expand Down
11 changes: 2 additions & 9 deletions upath/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
"""Pathlib API extended to use fsspec backends."""

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
from upath.core import UPath

__all__ = ["UPath"]
Loading

0 comments on commit 5c240c1

Please sign in to comment.