aioodbc
aioodbc copied to clipboard
Update type annotations in connection.py
What do these changes do?
- Converted
asyncio.Future-returning methods to native coroutines, updating the return types in the process^1 - Added type annotations to every identifier part of the public API
- Updated forward ref'd types to use postponed evaluation^2
Are there changes in behavior for the user?
Users should now have consistent type hinting when interacting the public API.
Related issue number
#275 #421
Checklist
- [ ] I think the code is well written
- [ ] Unit tests for the changes exist
- [ ] Documentation reflects the changes
- [ ] Add a new news fragment into the
CHANGESfolder- name it
<issue_id>.<type>(e.g.588.bugfix) - if you don't have an
issue_idchange it to the pr id after creating the PR - ensure type is one of the following:
-
.feature: Signifying a new feature. -
.bugfix: Signifying a bug fix. -
.doc: Signifying a documentation improvement. -
.removal: Signifying a deprecation or removal of public API. -
.misc: A ticket has been closed, but it is not of interest to users.
-
- Make sure to use full sentences with correct case and punctuation, for example:
Fix issue with non-ascii contents in doctest text files.
- name it
Changes looks good but connect kwargs need a fix, mypy not happy.
mypy --ignore-missing-imports aioodbc
[163](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:164)
aioodbc/pool.py:161: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "str" [arg-type]
[164](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:165)
aioodbc/pool.py:161: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "bool" [arg-type]
[165](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:166)
aioodbc/pool.py:161: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "int" [arg-type]
[166](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:167)
aioodbc/pool.py:161: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "Optional[AbstractEventLoop]" [arg-type]
[167](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:168)
aioodbc/pool.py:161: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "Optional[ThreadPoolExecutor]" [arg-type]
[168](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:169)
aioodbc/pool.py:161: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "Optional[Callable[[Any], Coroutine[Any, Any, Any]]]" [arg-type]
[169](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:170)
aioodbc/pool.py:173: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "str" [arg-type]
[170](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:171)
aioodbc/pool.py:173: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "bool" [arg-type]
[171](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:172)
aioodbc/pool.py:173: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "int" [arg-type]
[172](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:173)
aioodbc/pool.py:173: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "Optional[AbstractEventLoop]" [arg-type]
[173](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:174)
aioodbc/pool.py:173: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "Optional[ThreadPoolExecutor]" [arg-type]
[174](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:175)
aioodbc/pool.py:173: error: Argument 2 to "connect" has incompatible type "**Dict[str, Dict[Any, Any]]"; expected "Optional[Callable[[Any], Coroutine[Any, Any, Any]]]" [arg-type]
[175](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:176)
Found 12 errors in 1 file (checked 7 source files)
[176](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:177)
make: *** [Makefile:65: mypy] Error 1
[177](https://github.com/aio-libs/aioodbc/actions/runs/4887412629/jobs/8790975578?pr=429#step:5:178)
Error: Process completed with exit code 2.
you can run
make mypy
to repro.
Codecov Report
Merging #429 (7e3789f) into master (ecc52a6) will increase coverage by
0.08%. The diff coverage is93.33%.
@@ Coverage Diff @@
## master #429 +/- ##
==========================================
+ Coverage 86.93% 87.02% +0.08%
==========================================
Files 6 6
Lines 490 501 +11
Branches 73 73
==========================================
+ Hits 426 436 +10
- Misses 48 49 +1
Partials 16 16
| Impacted Files | Coverage Δ | |
|---|---|---|
| aioodbc/connection.py | 85.62% <93.33%> (+0.40%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
I rebased the branch with the recent changes. Note the changes in aa8d847; the commit contains the changes associated with the use of asyncio.Future that you recommended.