Skip to content
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

Update type annotations in connection.py #429

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

RA80533
Copy link
Contributor

@RA80533 RA80533 commented May 1, 2023

What do these changes do?

  • Converted asyncio.Future-returning methods to native coroutines, updating the return types in the process1
  • Added type annotations to every identifier part of the public API
  • Updated forward ref'd types to use postponed evaluation2

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 CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change 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.

Footnotes

  1. https://github.com/aio-libs/aioodbc/pull/429#discussion_r1183201672

  2. https://peps.python.org/pep-0563/

@RA80533 RA80533 changed the title Update typing in connection.py Update type annotations in connection.py May 1, 2023
@jettify jettify marked this pull request as ready for review May 3, 2023 02:56
aioodbc/connection.py Outdated Show resolved Hide resolved
@RA80533 RA80533 requested a review from jettify May 4, 2023 20:52
@jettify
Copy link
Member

jettify commented May 9, 2023

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.

@RA80533 RA80533 force-pushed the chore/typing/connection branch from 9e671b6 to 7e3789f Compare May 10, 2023 20:22
@codecov
Copy link

codecov bot commented May 10, 2023

Codecov Report

Merging #429 (7e3789f) into master (ecc52a6) will increase coverage by 0.08%.
The diff coverage is 93.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%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@RA80533
Copy link
Contributor Author

RA80533 commented May 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants