Skip to content

Commit

Permalink
Document Path support
Browse files Browse the repository at this point in the history
  • Loading branch information
mthuurne committed Aug 18, 2023
1 parent 6c94011 commit 10dfb91
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ class Config:
port: int
```

### File System Paths

While you can of course store file system paths as strings, [pathlib](https://docs.python.org/3/library/pathlib.html) offers a nicer API for them.
To take advantage of this, annotate the field as `Path`:

```py
from pathlib import Path

@dataclass
class Config:
log_dir: Path

def create_log_dir(self) -> None:
log_dir.mkdir(parents=True)
```

### Dates and Times

TOML handles dates and timestamps as first-class values.
Expand Down Expand Up @@ -578,3 +594,7 @@ In version 0.3.0, the function `format_template()` has been replaced by the meth
### 0.3.3 - 2023-07-31:

- Add `Binder.format_toml()` method to generate more compact TOML that excludes unused optional parts ([#38](https://github.com/ProtixIT/dataclass-binder/pull/38))

### 0.3.4 - 2023-08-18:

- Support `pathlib.Path` as a field annotation ([#40](https://github.com/ProtixIT/dataclass-binder/issues/40))

0 comments on commit 10dfb91

Please sign in to comment.