Skip to content

Commit 7bf8d04

Browse files
authored
add pydantic tests (#127)
* add pydantic tests * update changelog * update readme
1 parent 1c5cd91 commit 7bf8d04

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Fixed
1414
- improved azure test separation (#123).
1515

16+
### Added
17+
- tests to confirm pydantic `BaseSettings` behavior (#127).
18+
1619
## [0.0.24] - 2023-06-19
1720
### Added
1821
- started a changelog to keep track of significant changes (#118).

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ For more examples, see the [example notebook here](notebooks/examples.ipynb)
6161
Other fsspec-compatible filesystems may also work, but are not supported and tested.
6262
Contributions for new filesystems are welcome!
6363

64-
### Class inheritance diagram
64+
### Class hierarchy
6565

6666
The individual `UPath` subclasses relate in the following way with `pathlib` classes:
6767

@@ -116,10 +116,15 @@ flowchart TB
116116
style s1 fill:none,stroke:#ca0020,stroke-width:3px,stroke-dasharray: 3 3,color:#ca0020
117117
```
118118

119-
`PosixUPath` and `WindowsUPath` subclasses are 100% compatible with the `PosixPath` and `WindowsPath` classes of their
119+
When instantiating `UPath` the returned instance type depends on the path that was provided to the constructor.
120+
For "URI"-style paths, `UPath` returns a subclass instance corresponding to the supported `fsppec` protocol, defined
121+
by the URI-scheme. If there is no specialized subclass implementation available, `UPath` with return a `UPath` instance
122+
and raise a warning that the protocol is currently not being tested in the test-suite, and correct behavior is not
123+
guaranteed.
124+
If a local path is provided, `UPath` will return a `PosixUPath` or `WindowsUPath` instance.
125+
These two subclasses are 100% compatible with the `PosixPath` and `WindowsPath` classes of their
120126
specific Python version, and are tested against all relevant tests of the CPython pathlib test-suite.
121127

122-
123128
## Contributing
124129

125130
Contributions are very welcome.

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ dev =
4646
cheroot
4747
hadoop-test-cluster
4848
pyarrow
49+
pydantic
50+
pydantic-settings
4951

5052
[options.package_data]
5153
upath =

upath/tests/third_party/__init__.py

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
try:
4+
from pydantic import BaseConfig
5+
from pydantic_settings import BaseSettings
6+
except ImportError:
7+
BaseConfig = BaseSettings = None
8+
pytestmark = pytest.mark.skip(reason="requires pydantic")
9+
10+
from upath.core import UPath
11+
12+
13+
def test_pydantic_settings_local_upath():
14+
class MySettings(BaseSettings):
15+
example_path: UPath = UPath(__file__)
16+
17+
assert isinstance(MySettings().example_path, UPath)

0 commit comments

Comments
 (0)