Skip to content

Commit 59f9378

Browse files
committed
Type annotations
Signed-off-by: Ben Sherman <[email protected]>
1 parent b7fa6f4 commit 59f9378

37 files changed

+842
-333
lines changed

docs/migrations/25-10.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,51 @@ This page summarizes the upcoming changes in Nextflow 25.10, which will be relea
88
This page is a work in progress and will be updated as features are finalized. It should not be considered complete until the 25.10 release.
99
:::
1010

11+
## New features
12+
13+
<h3>Type annotations</h3>
14+
15+
Type annotations are a way to denote the *type* of a variable. They are useful both for documenting and validating your pipeline code.
16+
17+
```nextflow
18+
workflow RNASEQ {
19+
take:
20+
reads: Channel<Path>
21+
index: Channel<Path>
22+
23+
main:
24+
samples_ch = QUANT( reads.combine(index) )
25+
26+
emit:
27+
samples: Channel<Path> = samples_ch
28+
}
29+
30+
def isSraId(id: String) -> Boolean {
31+
return id.startsWith('SRA')
32+
}
33+
```
34+
35+
The following declarations can be annotated with types:
36+
37+
- Pipeline parameters (the `params` block)
38+
- Workflow takes and emits
39+
- Function parameters and returns
40+
- Local variables
41+
- Closure parameters
42+
- Workflow outputs (the `output` block)
43+
44+
Type annotations can refer to any of the {ref}`standard types <stdlib-types>`.
45+
46+
Type annotations can be appended with `?` to denote that the value can be `null`:
47+
48+
```nextflow
49+
def x_opt: String? = null
50+
```
51+
52+
:::{note}
53+
While Nextflow inherited type annotations of the form `<type> <name>` from Groovy, this syntax was deprecated in the {ref}`strict syntax <strict-syntax-page>`. Groovy-style type annotations are still allowed for functions and local variables, but will be automatically converted to Nextflow-stype type annotations when formatting code with the language server or `nextflow lint`.
54+
:::
55+
1156
## Breaking changes
1257

1358
- The AWS Java SDK used by Nextflow was upgraded from v1 to v2, which introduced some breaking changes to the `aws.client` config options. See {ref}`the guide <aws-java-sdk-v2-page>` for details.

docs/process.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ hello
655655

656656
### Input tuples (`tuple`)
657657

658-
The `tuple` qualifier allows you to group multiple values into a single input definition. It can be useful when a channel emits tuples of values that need to be handled separately. Each element in the tuple is associated with a corresponding element in the `tuple` definition. For example:
658+
The `tuple` qualifier allows you to group multiple values into a single input definition. It can be useful when a channel emits {ref}`tuples <script-tuples>` of values that need to be handled separately. Each element in the tuple is associated with a corresponding element in the `tuple` definition. For example:
659659

660660
```nextflow
661661
process cat {
@@ -1056,7 +1056,7 @@ If the command fails, the task will also fail. In Bash, you can append `|| true`
10561056

10571057
### Output tuples (`tuple`)
10581058

1059-
The `tuple` qualifier allows you to output multiple values in a single channel. It is useful when you need to associate outputs with metadata, for example:
1059+
The `tuple` qualifier allows you to output multiple values in a single channel as a {ref}`tuple <script-tuples>`. It is useful when you need to associate outputs with metadata, for example:
10601060

10611061
```nextflow
10621062
process blast {

docs/reference/stdlib-namespaces.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ The global namespace contains globally available constants and functions.
105105
`sleep( milliseconds: long )`
106106
: Sleep for the given number of milliseconds.
107107

108-
`tuple( collection: List ) -> ArrayTuple`
109-
: Create a tuple object from the given collection.
110-
111-
`tuple( args... ) -> ArrayTuple`
108+
`tuple( args... ) -> Tuple`
112109
: Create a tuple object from the given arguments.
113110

114111
(stdlib-namespaces-channel)=

0 commit comments

Comments
 (0)