Skip to content

Commit

Permalink
Merge pull request #3651 from fable-compiler/python-list-sort-with
Browse files Browse the repository at this point in the history
  • Loading branch information
MangelMaxime authored Dec 12, 2023
2 parents 21b969f + dca9766 commit 9276528
Show file tree
Hide file tree
Showing 10 changed files with 2,534 additions and 68 deletions.
2 changes: 2 additions & 0 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Python

* [GH-3645](https://github.com/fable-compiler/Fable/pull/3645) Add `TimeSpan.Parse` and `TimeSpan.TryParse` support to Python (by @MangelMaxime)
* [GH-3649](https://github.com/fable-compiler/Fable/issues/3649) Fixes for `List.sortBy` (by @dbrattli)
* [GH-3638](https://github.com/fable-compiler/Fable/issues/3638) Fixes for `Array.sort` and `Array.sortDescending` (by @dbrattli)

## 4.7.0 - 2023-12-06

Expand Down
7 changes: 4 additions & 3 deletions src/Fable.Transforms/Python/Fable2Python.fs
Original file line number Diff line number Diff line change
Expand Up @@ -967,14 +967,14 @@ module Annotation =
stdlibModuleTypeHint
com
ctx
"typing"
"collections.abc"
"Callable"
(argTypes @ [ returnType ])
| Fable.DelegateType(argTypes, returnType) ->
stdlibModuleTypeHint
com
ctx
"typing"
"collections.abc"
"Callable"
(argTypes @ [ returnType ])
| Fable.Option(genArg, _) ->
Expand Down Expand Up @@ -1247,7 +1247,8 @@ module Annotation =
any
]

stdlibModuleAnnotation com ctx "typing" "Callable" genArgs, stmts
stdlibModuleAnnotation com ctx "collections.abc" "Callable" genArgs,
stmts
| _ ->
let ent = com.GetEntity(entRef)
// printfn "DeclaredType: %A" ent.FullName
Expand Down
8 changes: 0 additions & 8 deletions src/Fable.Transforms/Python/Replacements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3346,14 +3346,6 @@ let arrayModule
(Helper.GlobalCall("len", t, [ ar ], [ t ], ?loc = r))
(makeIntConst 0)
|> Some

| "SortInPlaceWith", args ->
let args, thisArg = List.splitLast args
let argTypes = List.take (List.length args) i.SignatureArgTypes
let meth = "sort"

Helper.InstanceCall(thisArg, meth, t, args, argTypes, ?loc = r) |> Some

| Patterns.DicContains nativeArrayFunctions meth, _ ->
let args, thisArg = List.splitLast args
let argTypes = List.take (List.length args) i.SignatureArgTypes
Expand Down
Loading

0 comments on commit 9276528

Please sign in to comment.