Skip to content

Commit 45f6649

Browse files
committed
fix: Import BaseModel for Pydantic usage
1 parent b2d1719 commit 45f6649

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

Fable.Literate/App.fs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,7 @@ Utility functions for naming conversion and line classification:
7777

7878
module Utils =
7979
/// List of contributors to thank (Fable-style).
80-
let contributors = [|
81-
"@dbrattli"
82-
"@alfonsogarciacaro"
83-
"@ncave"
84-
"@MangelMaxime"
85-
"@claude 🤖"
86-
|]
80+
let contributors = [| "@dbrattli"; "@alfonsogarciacaro"; "@ncave"; "@MangelMaxime"; "@claude 🤖" |]
8781

8882
/// Returns a random contributor from the list.
8983
let randomContributor () : string =
@@ -257,7 +251,8 @@ module Parser =
257251
lines
258252
|> Seq.fold parseLine initial
259253
|> flushState
260-
|> _.Blocks |> List.rev
254+
|> _.Blocks
255+
|> List.rev
261256

262257
(**
263258
## Transform Module

chapters/Interop.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,21 @@ type DecoratedUser() =
336336
Control how class members are generated for Python frameworks like Pydantic:
337337
*)
338338

339+
// BaseModel from Pydantic (import this from Fable.Python.Pydantic in
340+
// real code to get proper bindings)
341+
[<Import("BaseModel", "pydantic")>]
342+
type BaseModel() = class end
343+
339344
[<Py.ClassAttributes(Py.ClassAttributeStyle.Attributes, false)>]
340345
type PydanticModel() =
346+
inherit BaseModel()
341347
member val Name: string = "" with get, set
342348
member val Age: int = 0 with get, set
343349

344-
(** This generates class-level type annotations suitable for Pydantic: *)
350+
(**
351+
This generates class-level type annotations suitable for Pydantic.
352+
See the Pydantic chapter for more on working with Pydantic models:
353+
*)
345354

346355
(*** include-python: PydanticModel ***)
347356

chapters/Summary.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ We've covered a lot of ground in this guide:
1616
- **Testing**: Running F# code with pytest and other Python test runners
1717
- **Fable v5**: The latest features including the Rust core and PyPI packages
1818
- **Pydantic**: Building validated data models with Python's favorite library
19-
- **Units of Measure**: Compile-time dimensional analysis that vanishes at runtime
19+
- **FastAPI**: Building type-safe web APIs in the Python ecosystem
20+
- **Units of Measure**: Compile-time dimensional analysis that vanishes (erased) at runtime
2021
- **Fable.Literate**: A self-documenting literate programming converter
2122
2223
## The Punchline

0 commit comments

Comments
 (0)