-
Notifications
You must be signed in to change notification settings - Fork 112
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
Add type annotations #464
Add type annotations #464
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks for this PR!!!
Another thing: it could be nice to add some tests with mypy to check the annotations are correct. |
Also, I think we have to add a |
As far as I understand |
I'm not so familiar with the CI pipeline being used for this project but I'm curious as to why the linting step in tox fails only for python==3.8? |
I'm not sure either, I never setup type hints for a library that will be used in other codes. Did you try to run Mypy on another code that includes GeoAlchemy2 objects?
It's just because the lint tox job is run only in the Py38 CI job. |
That makes sense about the single job failing if that's the only place the liniting is run. I've pushed a couple of commits to attempt to deal with the linter complaints |
Sorry I should have tell you that before but you can run |
Now it's good, thanks :-) |
I'm not familiar with that package, in other projects I've added a mypy check as part of the CI run. One other question I had was the types found in geoalchemy2/comparator.py, do we want to annotate return types there? I wasn't sure exactly what those types were supposed to be so I didn't annotate them in this PR. |
For comparators I'm not sure. We should check the type annotations in SQLAlchemy and do the same. |
It seems that the comparators can get a WKT |
I'm not so sure how best to annotate the types of the Comparator class, are these changes worth merging as is? Or is anyone able to push a commit with a fix? |
As far as I can see, the comparators should actually return |
Looks great! Now I think we just have to fix mypy tests, do you need help for it? |
There was some missing type stub files in the last run, I've attempted to install those in 98d592e I think there's a few things that will fail however, but I'd like to see what those are from the CI runner. I suspect that we will need to add to the tox configuration some mypy options including the following:
|
Nice!
Yeah indeed we will probably have to add some custom config for mypy. |
Looks like my idea of using |
Looks like we encounter this issue: sqlalchemy/sqlalchemy2-stubs#242 |
Since this issue is supposed to be fixed in |
If you could change the mypy test run to only run vs SQLAlchemy >= 2 that would be great. |
In the end I could make it work for both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me.
Thank you very much for this work @shuttle1987 ! |
@shuttle1987 I just released the |
These changes add in type annotations to the code.