Skip to content

Broaden the type hint for SQL.join() #127

@rpmrmartin

Description

@rpmrmartin

Passing a generator to SQL.join(), as suggested in the documentation for that method, produces errors in Mypy and Pyright:

import psycopg.sql as sql

sql.SQL(', ').join(sql.Identifier(n) for n in ['foo', 'bar', 'baz'])

Mypy:

Argument 1 to "join" of "SQL" has incompatible type "Generator[Identifier, None, None]"; expected "Sequence[Composable]"

Pyright:

Argument of type "Generator[Identifier, None, None]" cannot be assigned to parameter "seq" of type "Sequence[Composable]" in function "join"

Perhaps the seq parameter could be annotated with Iterable instead of Sequence.

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