Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

* [Python] Added `ClassAttributes` attribute to control Python class generation (@dbrattli)

### Fixed

* [TS/Dart] Fixed optional parameter types (by @ncave)
Expand Down Expand Up @@ -105,14 +109,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [Python] Fix date formatting when repeating a format token more than the known format (example repeating 'd' more than 4 times) (by @MangelMaxime)
* [JS/TS] Fix #4010: Supports direct nested types when using `jsOptions` (by @MangelMaxime)

```fs
```fs
let opts =
jsOptions<Level1> (fun o ->
o.level2.level3.valueA <- 10
o.level2.level3.valueB <- 20
o.topValueA <- 20
)
```
```

* [JS/TS] Fix numeric formats (by @MangelMaxime)

Expand Down
4 changes: 4 additions & 0 deletions src/Fable.Core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

* [Python] Added `ClassAttributes` attribute to control Python class generation (@dbrattli)

## 5.0.0-beta.1 - 2025-07-25

### Added
Expand Down
16 changes: 16 additions & 0 deletions src/Fable.Core/Fable.Core.Py.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ module Py =

abstract Decorate: fn: Callable * info: Reflection.MethodInfo -> Callable

/// <summary>
/// Used on a class to provide Python-specific control over how F# types are transpiled to Python classes.
/// This attribute implies member attachment (similar to AttachMembers) while offering Python-specific parameters.
/// </summary>
/// <remarks>
/// <para>When placed on a class, all members are attached without mangling (like AttachMembers).</para>
/// <para>Additional Python-specific parameters control the generated Python class style and features.</para>
/// </remarks>
[<AttributeUsage(AttributeTargets.Class)>]
type ClassAttributes() =
inherit Attribute()

new(style: string) = ClassAttributes()

new(style: string, init: bool) = ClassAttributes()

// Hack because currently Fable doesn't keep information about spread for anonymous functions
[<Emit("lambda *args: $0(args)")>]
let argsFunc (fn: obj[] -> obj) : Callable = nativeOnly
Expand Down
1 change: 1 addition & 0 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,7 @@ module Util =
// Should we make sure the attribute is not an alias?
match att.AttributeType.TryFullName with
| Some Atts.attachMembers -> true
| Some Atts.pyClassAttributes -> true
| _ -> false
))

Expand Down
Loading
Loading