Skip to content

Commit 1c5cd91

Browse files
authored
Add a class inheritance diagram to the readme (#126)
1 parent 662c294 commit 1c5cd91

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

README.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ conda install -c conda-forge universal_pathlib
2828

2929
## Basic Usage
3030

31-
```python
31+
```pycon
32+
# pip install universal_pathlib s3fs
3233
>>> from upath import UPath
33-
>>> import s3fs
34-
34+
>>>
3535
>>> s3path = UPath("s3://test_bucket") / "example.txt"
3636
>>> s3path.name
3737
example.txt
@@ -61,6 +61,65 @@ 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
65+
66+
The individual `UPath` subclasses relate in the following way with `pathlib` classes:
67+
68+
```mermaid
69+
flowchart TB
70+
subgraph s0[pathlib]
71+
A---> B
72+
A--> AP
73+
A--> AW
74+
75+
B--> BP
76+
AP---> BP
77+
B--> BW
78+
AW---> BW
79+
end
80+
subgraph s1[upath]
81+
B ---> U
82+
U --> UP
83+
U --> UW
84+
BP --> UP
85+
BW --> UW
86+
U --> UL
87+
U --> US3
88+
U --> UH
89+
U -.-> UO
90+
end
91+
92+
A(PurePath)
93+
AP(PurePosixPath)
94+
AW(PureWindowsPath)
95+
B(Path)
96+
BP(PosixPath)
97+
BW(WindowsPath)
98+
99+
U(UPath)
100+
UP(PosixUPath)
101+
UW(WindowsUPath)
102+
UL(LocalPath)
103+
US3(S3Path)
104+
UH(HttpPath)
105+
UO(...Path)
106+
107+
classDef np fill:#f7f7f7,stroke:#2166ac,stroke-width:2px,color:#333
108+
classDef nu fill:#f7f7f7,stroke:#b2182b,stroke-width:2px,color:#333
109+
110+
class A,AP,AW,B,BP,BW,UP,UW np
111+
class U,UL,US3,UH,UO nu
112+
113+
style UO stroke-dasharray: 3 3
114+
115+
style s0 fill:none,stroke:#0571b0,stroke-width:3px,stroke-dasharray: 3 3,color:#0571b0
116+
style s1 fill:none,stroke:#ca0020,stroke-width:3px,stroke-dasharray: 3 3,color:#ca0020
117+
```
118+
119+
`PosixUPath` and `WindowsUPath` subclasses are 100% compatible with the `PosixPath` and `WindowsPath` classes of their
120+
specific Python version, and are tested against all relevant tests of the CPython pathlib test-suite.
121+
122+
64123
## Contributing
65124

66125
Contributions are very welcome.

0 commit comments

Comments
 (0)