Bootstrap 2.0 migration docs for pydantic 2.0 change · networktocode/diffsync@fe4717e · GitHub
Skip to content

Commit fe4717e

Browse files
author
Leo Kirchner
committed
Bootstrap 2.0 migration docs for pydantic 2.0 change
1 parent 394c78f commit fe4717e

5 files changed

Lines changed: 65 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 15 deletions
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
###############
2-
Getting Started
3-
###############
1+
#########
2+
Upgrading
3+
#########
44

55
.. mdinclude:: 01-getting-started.md

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Welcome to DiffSync's documentation!
99
getting_started/index
1010
core_engine/index
1111
examples/index
12+
upgrading/index
1213
api/diffsync
1314
license/index
1415

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Upgrading to 2.0
2+
3+
With diffsync 2.0, there a couple of breaking changes. What they are and how to deal with them is described in this document.
4+
5+
## Upgrade to Pydantic's major version 2
6+
7+
A [migration guide](https://docs.pydantic.dev/latest/migration/) is available in the Pydantic documentation. Here are the key things that may apply to your usage of diffsync:
8+
9+
- Any fields that are of type `Optional` now need to provide an explicit `None` default (you can use [bump-pydantic](https://github.com/pydantic/bump-pydantic) to deal with this automatically for the most part)
10+
11+
```python
12+
from typing import Optional
13+
14+
from diffsync import DiffSyncModel
15+
16+
# Before
17+
class Person(DiffSyncModel):
18+
_identifiers = ("name",)
19+
_attributes = ("age",)
20+
21+
name: str
22+
age: Optional[int]
23+
24+
# After
25+
class BetterPerson(DiffSyncModel)
26+
_identifiers = ("name",)
27+
_attributes = ("age",)
28+
29+
name: str
30+
age: Optional[int] = None
31+
```

docs/source/upgrading/index.rst

Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)