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

Type error when attempting to use a Literal[True] with sa.and_() #240

Open
gandhis1 opened this issue Nov 10, 2022 · 1 comment
Open

Type error when attempting to use a Literal[True] with sa.and_() #240

gandhis1 opened this issue Nov 10, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@gandhis1
Copy link

Relevant block of code:

sa.and_(
    tb.c.VERSION == version,
    tb.c.ISIN.in_(isins) if isins is not None else True,
    tb.c.ISIN != None,  # pylint: disable=singleton-comparison
     b.c.DATE.in_(dates))
)

Error I get from pyright is:

error: Argument of type "ColumnElement[Boolean] | Literal[True]" cannot be assigned to parameter "clauses" of type "_CLE@BooleanClauseList" in function "and_"
    Type "ColumnElement[Boolean] | Literal[True]" cannot be assigned to type "ColumnElement[Boolean]"
      "Literal[True]" is incompatible with "ColumnElement[Boolean]" (reportGeneralTypeIssues)
@gandhis1 gandhis1 added the requires triage New issue that requires categorization label Nov 10, 2022
@CaselIT
Copy link
Member

CaselIT commented Nov 10, 2022

Thanks for reporting,

You can use tb.c.ISIN.is_not(None) as an alternative.

@CaselIT CaselIT added bug Something isn't working and removed requires triage New issue that requires categorization labels Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants