Closed gavindsouza closed 9 months ago
Could you elaborate on this change a little bit more? I don't fully get it
@AzisK The previous type hints suggested that the builder
function took a Callable input and returned a Callable but they need not be a Callable
of the same type. This would confuse the type checkers while evaluating method chains, as you can see from the unhighlighted recurring where
and delete
chains in the "Before" section.
The change I'm proposing says that the Callable returned is that of the same type as the input received - which is of a query builder type that implements the accessed methods. Type checkers understand this and the consequence is that your IDE provides appropriate type hints as highlighted in the "After" section.
The example is usage from Frappe's codebase.
Interesting. Okay, thanks for the explanation as well as for your work
We need to lint the code as well as fix the unit test runners
@AzisK We should add a pre-commit config that "black"en's the codebase automatically by the way.
--
As for the failing 3.6 build, it's high time we drop it given that it's unmaintained and there are 6 new major versions released meanwhile - https://github.com/kayak/pypika/issues/747
I agree about the pre-commit hook. I just created an issue https://github.com/kayak/pypika/issues/748
I believe we can drop support for Python3.6, I am just not sure what to do with the version of the library. Do we have to bump the major version in this case?
@gavindsouza could you update this PR with the newest CI code from master?
@gavindsouza could you update this PR with the newest CI code from master?
Done 😄
Good job. I am merging this but new version and release will be coming later
Maintain that the Callable type received is the same as the Callable returned.
Additional Context for the screenshots: tbl is a
Table
object,frappe.qb
is a namespace that has typeMySQLQuery | PostgreSQLQuery
Before
After