Skip to content

compose.Select fix type annotation #1682

@tauferp

Description

@tauferp

Versions

river version: 0.21.0
Python version: 3.12.4
Operating system: Ubuntu 24

Describe the bug

compose.Select init method has weird/likely wrong type annotations:

    def __init__(self, *keys: tuple[base.typing.FeatureName]):

This makes it seem like every key should be a tuple, when the real use case looks more like:

    def __init__(self, *keys: base.typing.FeatureName):

Steps/code to reproduce

Using example from https://riverml.xyz/dev/api/compose/Select/#examples

from river import compose

x = {'a': 42, 'b': 12, 'c': 13}
compose.Select('c').transform_one(x)

Running current mypy 1.15.0 yeilds:

$ mypy sample.py 
sample.py:4: error: Call to untyped function "transform_one" in typed context  [no-untyped-call]
sample.py:4: error: Argument 1 to "Select" has incompatible type "str"; expected "tuple[Hashable]"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)

Where using the proposed annotations yields:

$ mypy sample.py 
sample.py:4: error: Call to untyped function "transform_one" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions