Skip to content

Commit

Permalink
Add mypy to the dev dependencies. (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
jettify authored Apr 1, 2023
1 parent 5632a83 commit 816d671
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ cscope.files
cscope.out
sqlite_*.db
_version.py
.mypy_cache/
.eggs/
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@ checkbuild:
python setup.py sdist bdist_wheel
twine check dist/*

mypy:
mypy --ignore-missing-imports aioodbc

mypy_strict:
mypy --strict --ignore-missing-imports aioodbc

.PHONY: all flake test vtest cov clean doc
10 changes: 9 additions & 1 deletion aioodbc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@

from ._version import version, version_tuple
from .connection import Connection, connect
from .cursor import Cursor
from .pool import Pool, create_pool

__version__ = version
__version_tuple__ = version_tuple
__all__ = ("connect", "Connection", "create_pool", "Pool", "dataSources")
__all__ = (
"connect",
"Connection",
"create_pool",
"Pool",
"dataSources",
"Cursor",
)


async def dataSources(loop=None, executor=None):
Expand Down
5 changes: 3 additions & 2 deletions aioodbc/utils.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from collections.abc import Coroutine
from typing import Dict, Union

from pyodbc import Error

# Issue #195. Don't pollute the pool with bad conns
# Unfortunately occasionally sqlite will return 'HY000' for invalid query,
# so we need specialize the check
_CONN_CLOSE_ERRORS = {
_CONN_CLOSE_ERRORS: Dict[str, Union[str, None]] = {
# [Microsoft][ODBC Driver 17 for SQL Server]Communication link failure
"08S01": None,
# [HY000] server closed the connection unexpectedly
"HY000": "[HY000] server closed the connection unexpectedly",
}


def _is_conn_close_error(e):
def _is_conn_close_error(e: Exception) -> bool:
if not isinstance(e, Error) or len(e.args) < 2:
return False

Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ black==23.3.0
flake8-bugbear==23.3.23
flake8==6.0.0
ipdb==0.13.13
twine==4.0.2
ipython==8.12.0
isort==5.12.0
mypy==1.1.1
pyodbc==4.0.35
pytest-asyncio==0.21.0
pytest-cov==4.0.0
Expand All @@ -16,4 +16,5 @@ pytest-sugar
pytest==7.2.2
sphinx==6.1.3
sphinxcontrib-asyncio==0.3.0
twine==4.0.2
uvloop==0.17.0

0 comments on commit 816d671

Please sign in to comment.