Skip to content

Commit 3bffbf2

Browse files
authored
Fix typing example in README (#484)
- Function names and docstrings describe what the function does - Fix return types - Fix imports
1 parent e68f9a1 commit 3bffbf2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,14 @@ For code that needs to work with different path types, use the type hints from
691691
`upath.types` to properly specify your requirements:
692692

693693
```python
694+
import os
694695
from upath import UPath
695696
from upath.types import (
696-
JoinablePathLike,
697697
ReadablePathLike,
698698
WritablePathLike,
699699
)
700700

701-
def read_only_local_file(path: os.PathLike) -> None:
701+
def read_only_local_file(path: os.PathLike) -> str:
702702
"""Read a file on the local filesystem."""
703703
with open(path) as f:
704704
return f.read_text()
@@ -708,11 +708,11 @@ def write_only_local_file(path: os.PathLike) -> None:
708708
with open(path) as f:
709709
f.write_text("hello world")
710710

711-
def read_any_file(path: WritablePathLike) -> None:
712-
"""Write a file on any filesystem."""
711+
def read_any_file(path: ReadablePathLike) -> str:
712+
"""Read a file on any filesystem."""
713713
return UPath(path).read_text()
714714

715-
def read_any_file(path: WritablePathLike) -> None:
715+
def write_any_file(path: WritablePathLike) -> None:
716716
"""Write a file on any filesystem."""
717717
UPath(path).write_text("hello world")
718718
```

0 commit comments

Comments
 (0)