Skip to content

Type annotations #6278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
45 changes: 45 additions & 0 deletions docs/migrations/25-10.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,51 @@ This page summarizes the upcoming changes in Nextflow 25.10, which will be relea
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.
:::

## New features

<h3>Type annotations</h3>

Type annotations are a way to denote the *type* of a variable. They are useful both for documenting and validating your pipeline code.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Type annotations are a way to denote the *type* of a variable. They are useful both for documenting and validating your pipeline code.
You can use type annotations to denote the **type** of a variable. They help document and validate your pipeline code.


```nextflow
workflow RNASEQ {
take:
reads: Channel<Path>
index: Channel<Path>

main:
samples_ch = QUANT( reads.combine(index) )

emit:
samples: Channel<Path> = samples_ch
}

def isSraId(id: String) -> Boolean {
return id.startsWith('SRA')
}
```

The following declarations can be annotated with types:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The following declarations can be annotated with types:
You can annotate the following declarations with types:


- Pipeline parameters (the `params` block)
- Workflow takes and emits
- Function parameters and returns
- Local variables
- Closure parameters
- Workflow outputs (the `output` block)

Type annotations can refer to any of the {ref}`standard types <stdlib-types>`.

Type annotations can be appended with `?` to denote that the value can be `null`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Type annotations can be appended with `?` to denote that the value can be `null`:
You can append an `?` to type annotations to denote that the value can be `null`:


```nextflow
def x_opt: String? = null
```

:::{note}
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`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.
Nextflow previously inherited type annotations in the form `<type> <name>` from Groovy, but this syntax is now deprecated under the <strict-syntax-page>`. Groovy-style type annotations are still allowed for functions and local variables. However, the language server and `nextflow lint` will automatically convert them to Nextflow-style type annotations when formatting code.

:::

## Breaking changes

- 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.
4 changes: 2 additions & 2 deletions docs/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ hello

### Input tuples (`tuple`)

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:
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
The `tuple` qualifier groups 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:


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

### Output tuples (`tuple`)

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:
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
The `tuple` qualifier outputs 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:


```nextflow
process blast {
Expand Down
5 changes: 1 addition & 4 deletions docs/reference/stdlib-namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ The global namespace contains globally available constants and functions.
`sleep( milliseconds: long )`
: Sleep for the given number of milliseconds.

`tuple( collection: List ) -> ArrayTuple`
: Create a tuple object from the given collection.

`tuple( args... ) -> ArrayTuple`
`tuple( args... ) -> Tuple`
: Create a tuple object from the given arguments.

(stdlib-namespaces-channel)=
Expand Down
Loading
Loading