Skip to content
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

Stubgen creating functions with signatures that will never be matched #8

Open
Lewis-E opened this issue May 10, 2023 · 0 comments
Open

Comments

@Lewis-E
Copy link
Contributor

Lewis-E commented May 10, 2023

Description

Wrote the following raw sql:

-- :name create :one
-- Create a new Recipient
INSERT INTO payments.recipient (
    stripe_account_id
) VALUES (
    NULL
)
RETURNING payments.recipient.*;

then generated stubs using yesql stubgen.

The stubs generated fine, but half of them were irrelevant and caused the following mypy linting errors:

src/payments/repository/recipient.pyi:176: error: Overloaded function signature 4 will never be matched: signature 1's parameter type(s) are the same or broader  [misc]
src/payments/repository/recipient.pyi:189: error: Overloaded function signature 5 will never be matched: signature 2's parameter type(s) are the same or broader  [misc]
src/payments/repository/recipient.pyi:203: error: Overloaded function signature 6 will never be matched: signature 3's parameter type(s) are the same or broader  [misc]

I expected stub generation to create only relevant function signatures.

Generated stubs included below:

    @typing.overload
    def create(
        self,
        /,
        *,
        instance: "Recipient | None" = None,
        connection: "yesql.types.ConnectionT" = None,
        timeout: "float" = 10,
        transaction: "bool" = True,
        rollback: "bool" = False,
        serializer: "yesql.types.SerializerT" = None,
        deserializer: "yesql.types.DeserializerT | None" = None,
    ) -> "typing.Awaitable[Recipient]":
        """Create a new Recipient"""
    @typing.overload
    def create(
        self,
        /,
        *,
        instance: "Recipient | None" = None,
        connection: "yesql.types.ConnectionT" = None,
        timeout: "float" = 10,
        transaction: "bool" = True,
        rollback: "bool" = False,
        serializer: "yesql.types.SerializerT" = None,
        deserializer: "yesql.types.DeserializerT | None" = None,
        coerce: "typing.Literal[True]",
    ) -> "typing.Awaitable[Recipient]":
        """Create a new Recipient"""
    @typing.overload
    def create(
        self,
        /,
        *,
        instance: "Recipient | None" = None,
        connection: "yesql.types.ConnectionT" = None,
        timeout: "float" = 10,
        transaction: "bool" = True,
        rollback: "bool" = False,
        serializer: "yesql.types.SerializerT" = None,
        deserializer: "yesql.types.DeserializerT | None" = None,
        coerce: "typing.Literal[False]",
    ) -> "typing.Awaitable[typing.Any]":
        """Create a new Recipient"""
    @typing.overload
    def create(
        self,
        /,
        *,
        connection: "yesql.types.ConnectionT" = None,
        timeout: "float" = 10,
        transaction: "bool" = True,
        rollback: "bool" = False,
        serializer: "yesql.types.SerializerT" = None,
        deserializer: "yesql.types.DeserializerT | None" = None,
    ) -> "typing.Awaitable[Recipient]":
        """Create a new Recipient"""
    @typing.overload
    def create(
        self,
        /,
        *,
        connection: "yesql.types.ConnectionT" = None,
        timeout: "float" = 10,
        transaction: "bool" = True,
        rollback: "bool" = False,
        serializer: "yesql.types.SerializerT" = None,
        deserializer: "yesql.types.DeserializerT | None" = None,
        coerce: "typing.Literal[True]",
    ) -> "typing.Awaitable[Recipient]":
        """Create a new Recipient"""
    @typing.overload
    def create(
        self,
        /,
        *,
        connection: "yesql.types.ConnectionT" = None,
        timeout: "float" = 10,
        transaction: "bool" = True,
        rollback: "bool" = False,
        serializer: "yesql.types.SerializerT" = None,
        deserializer: "yesql.types.DeserializerT | None" = None,
        coerce: "typing.Literal[False]",
    ) -> "typing.Awaitable[typing.Any]":
        """Create a new Recipient"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant