You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/migrations/25-10.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,55 @@ This page summarizes the upcoming changes in Nextflow 25.10, which will be relea
8
8
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.
9
9
:::
10
10
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>` as well as the following primitive types:
45
+
46
+
- Boolean
47
+
- Integer
48
+
- Number
49
+
50
+
Type annotations can be appended with `?` to denote that the value can be `null`:
51
+
52
+
```nextflow
53
+
def x_opt: String? = null
54
+
```
55
+
56
+
:::{note}
57
+
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`.
58
+
:::
59
+
11
60
## Breaking changes
12
61
13
62
- 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.
Copy file name to clipboardExpand all lines: docs/strict-syntax.md
+25-8Lines changed: 25 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -299,10 +299,22 @@ def str = 'hello'
299
299
def meta = [:]
300
300
```
301
301
302
-
:::{note}
303
-
Because type annotations are useful for providing type checking at runtime, the language server will not report errors for Groovy-style type annotations at this time. Type annotations will be addressed in a future version of the Nextflow language specification.
302
+
:::{versionadded} 25.10.0
304
303
:::
305
304
305
+
Local variables can be declared with a type annotation:
306
+
307
+
```nextflow
308
+
def a: Integer = 1
309
+
def b: Integer = 2
310
+
def (c: Integer, d: Integer) = [3, 4]
311
+
def (e: Integer, f: Integer) = [5, 6]
312
+
def str: String = 'hello'
313
+
def meta: Map = [:]
314
+
```
315
+
316
+
While Groovy-style type annotations are still supported, the linter and language server will automatically convert them to Nextflow-style type annotations when formatting code. Groovy-style type annotations will not be supported in a future version.
317
+
306
318
### Strings
307
319
308
320
Groovy supports a wide variety of strings, including multi-line strings, dynamic strings, slashy strings, multi-line dynamic slashy strings, and more.
In the strict syntax, only hard casts are supported. However, hard casts are discouraged because they can cause unexpected behavior if used improperly. Groovy-style type annotations should be used instead:
383
+
In the strict syntax, only hard casts are supported.
384
+
385
+
When casting a value to a different type, it is always better to use an explicit method if one is available. For example, to parse a string as a number:
372
386
373
387
```groovy
374
-
def Map map = readJson(json)
388
+
def x = '42' as Integer
389
+
def x = '42'.toInteger() // preferred
375
390
```
376
391
377
-
Nextflow will raise an error at runtime if the `readJson()` function does not return a `Map`.
392
+
:::{versionadded} 25.10.0
393
+
:::
378
394
379
-
When converting a value to a different type, it is better to use an explicit method rather than a cast. For example, to parse a string as a number:
395
+
In cases where a function returns an unknown type, use a type annotation:
380
396
381
397
```groovy
382
-
def x = '42' as Integer
383
-
def x = '42'.toInteger() // preferred
398
+
def map: Map = readJson(json)
384
399
```
385
400
401
+
Nextflow will raise an error at runtime if the `readJson()` function does not return a `Map`.
402
+
386
403
### Process env inputs and outputs
387
404
388
405
In Nextflow DSL2, the name of a process `env` input/output can be specified with or without quotes:
0 commit comments