typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Additional return types for psycopg2 connections

Open OldSneerJaw opened this issue 2 years ago • 3 comments

Adds correct return types for DB connection and cursor methods that deal with namedtuple and dict-like cursors. Currently the types are either incomplete (e.g. the connections' cursor methods do not specify return types) or wrong (e.g. DictCursor's fetch* methods should not return tuples, which is currently inherited from DictCursorBase).

OldSneerJaw avatar Aug 11 '22 01:08 OldSneerJaw

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 11 '22 01:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 11 '22 02:08 github-actions[bot]

I'm not sure of the best approach to solving the mypy errors in CI. The cases where it is reporting that an override's return types are incompatible with the super return types are how it is actually implemented in the underlying library's code (i.e. the stubs I've added merely reflect the reality of the code). Thoughts?

OldSneerJaw avatar Aug 11 '22 02:08 OldSneerJaw

Stubs should reflect what the library actually does. We use # type: ignore[override] to silence type checker errors in situations like this.

Akuli avatar Aug 11 '22 16:08 Akuli

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 11 '22 23:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 11 '22 23:08 github-actions[bot]

All right. I have made several changes, including adding # type: ignore for the incompatible return types. I believe this PR is ready for review now.

OldSneerJaw avatar Aug 11 '22 23:08 OldSneerJaw

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 13 '22 04:08 github-actions[bot]

One new commit for review.

OldSneerJaw avatar Aug 13 '22 04:08 OldSneerJaw

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 16 '22 01:08 github-actions[bot]