Skip to content

Conversation

@waketzheng
Copy link
Contributor

Description

  • Introduce a new _compare function to reduce duplicated code within comparisons(__and__/__or__/__xor__)
  • Add a new dev dependency typing-extensions to imports the Self for python<3.11
  • Improve type hints for Criterion functions:
    • For __and__, __or__, __xor__, if the other parameter is instance of EmptyCriterion, return value is Self, not ComplexCriterion.
    • For the any function, if terms is empty, return value is instance of EmptyCriterion, and if there is only one element of terms, return value is this element, at that time, the return type is Term, otherwise return type is ComplexCriterion.
    • For the all function, as type of terms is any, it will return any if only one element in terms.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • All new and existing tests passed.

@waketzheng waketzheng requested a review from a team as a code owner October 21, 2025 15:42
@coveralls
Copy link

Coverage Status

coverage: 98.246% (-0.06%) from 98.307%
when pulling 1454437 on waketzheng:refactor-share-comparision-logic
into f400e39 on kayak:master.

@AzisK
Copy link
Contributor

AzisK commented Oct 25, 2025

Thank you for your work. Could you pull the master code since there was a similar change related to typing-extensions merged?

@waketzheng
Copy link
Contributor Author

Could you pull the master code since there was a similar change related to typing-extensions merged?

done.

@waketzheng
Copy link
Contributor Author

BTW: you can add from __future__ import annotations at the beginning of python files, and run ruff check --extend-select=I,UP --fix --unsafe-fixes pypika/ to improve type hints. For example: #853

Copy link
Contributor

@AzisK AzisK left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you for the work

@AzisK AzisK merged commit 3094e3f into kayak:master Oct 26, 2025
18 of 20 checks passed
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

Successfully merging this pull request may close these issues.

3 participants