pypika
pypika copied to clipboard
Fix type hint
This pull request is intended to revised existing type hint in this project and fix all problems about typing reported by mypy.
Including fixes:
__eq__()and__ne__()accept any object as the argument.- new type comment for decorator
builder - improve type comments
- fix errors in terms.py, utils.py, dialects.py
TODO:
- find workarounds for old python (pypika requires python 3.6+)
I discover a failed test for terms.py:
ERROR: test__criterion_replace_table_with_value (pypika.tests.test_internals.TablesTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "~/Project/pypika/pypika/tests/test_internals.py", line 16, in test__criterion_replace_table_with_value
self.assertEqual(c.left, table)
File "/usr/lib64/pypy3.9/unittest/case.py", line 837, in assertEqual
assertion_func(first, second, msg=msg)
File "/usr/lib64/pypy3.9/unittest/case.py", line 827, in _baseAssertEqual
if not first == second:
File "~/Project/pypika/pypika/terms.py", line 265, in __eq__
return BasicCriterion(Equality.eq, self, Term._assert_guard(self.wrap_constant(other)))
File "~/Project/pypika/pypika/terms.py", line 301, in _assert_guard
raise TypeError("expect Term object, got {}".format(type(v).__name__))
TypeError: expect Term object, got Table
I wonder if the original behaviour in the test is intended.