-
-
Notifications
You must be signed in to change notification settings - Fork 514
Type hints and mypy support? #977
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
Comments
It would be lovely! Would you like to work on it? |
I may give it a try soon, we're currently integrating typing into our projects so I'm still getting my head around various aspects. The main concern would probably be Python 2.7 compatibility as it would be preferred to have the types inline with the code but I'm pretty sure Python 2.7 won't like that. Peraps if the next major version is Python 3.x compatible only, that will make it a lot easier 😄 Thanks a lot for the reply 😄 |
You can create separate pyi files to give to mypy if you don't want to inline in the code. |
Are there any plans yet to drop support for Python 2 in e.g. psycopg3 as I would welcome that change |
Psycopg3 is Python >= 3.6 only, and it's being developed at |
Does anyone have some type stubs for psycopg2 ? I'm new to pyright and I have |
Maybe this types package is relevant to someone |
With support for Python 3.7 dropped in #1729, it should be easy enough to merge typeshed's stub's annotations into psycopg2's source code. Then at least run https://github.com/python/mypy for sanity checking (you can disable rules that fail related to checking psycopg's own code rather than just the annotations' validity) And maybe Ruff's flake8-future-annotations (FA), late-future-import (F404), flake8-pyi (PYI) and some pyupgrade (UP) which can help staying up to date with annotation best practices. |
@Avasam, I have experience of porting large codebases to type checking and I can confidently say that you don't know what you are talking about. Psycopg 3 had to be designed ground-up to support type checking (introducing it when the codebase was 3 weeks old was already a massive work), it's not a thing you can slap on a project not designed for it and especially not running a bunch of code linters. If you want type checking you either use psycopg 3 or you pay me by the hour so that I can provide you some sub-optimal type annotation for a C library that was designed 15 years before type hinting was a thing in Python. This topic doesn't require further discussion. If you want badly code annotation, my email is public and I will be happy to quote you a few days of work. |
Hey there guys, hope you're doing well! 😄
Are there any plans to add typing information and support mypy in the future?
Kindest Regards
Fotis
The text was updated successfully, but these errors were encountered: