Skip to content

Commit 4513307

Browse files
authored
MOTOR-1212 Update QA Checks to Match PyMongo (#234)
* clean up config * cleanup * clean up * fix pytest config * clean up typing
1 parent 8f71800 commit 4513307

File tree

12 files changed

+73
-71
lines changed

12 files changed

+73
-71
lines changed

.github/workflows/test-python.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,12 @@ jobs:
102102
typing:
103103
name: Typing Tests
104104
runs-on: ubuntu-latest
105-
strategy:
106-
matrix:
107-
python-version: ['3.7', '3.12']
108-
fail-fast: false
109105
steps:
110106
- uses: actions/checkout@v2
111-
- name: Set up Python ${{ matrix.python-version }}
107+
- name: Set up Python
112108
uses: actions/setup-python@v4
113109
with:
114-
python-version: ${{ matrix.python-version }}
110+
python-version: "3.10"
115111
cache: 'pip'
116112
cache-dependency-path: 'pyproject.toml'
117113
allow-prereleases: true

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
include README.rst
22
include LICENSE
33
include tox.ini
4-
include pytest.ini
54
include pyproject.toml
6-
include mypy.ini
75
include doc/Makefile
86
include doc/examples/tornado_change_stream_templates/index.html
97
recursive-include doc *.rst

motor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
try:
22-
import tornado # type:ignore[import]
22+
import tornado
2323
except ImportError:
2424
tornado = None
2525
else:

motor/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def get_version_string() -> str:
2020
if isinstance(version_tuple[-1], str):
2121
return ".".join(map(str, version_tuple[:-1])) + version_tuple[-1]
22-
return ".".join(map(str, version_tuple))
22+
return ".".join(map(str, version_tuple)) # type:ignore[unreachable]
2323

2424

2525
version = get_version_string()

motor/metaprogramming.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Dynamic class-creation for Motor."""
1616
import functools
1717
import inspect
18-
from typing import Any, Callable, Dict
18+
from typing import Any, Callable, Dict, TypeVar
1919

2020
_class_cache: Dict[Any, Any] = {}
2121

@@ -264,7 +264,10 @@ def return_clone(self, *args, **kwargs):
264264
return return_clone
265265

266266

267-
def create_class_with_framework(cls, framework, module_name):
267+
T = TypeVar("T")
268+
269+
270+
def create_class_with_framework(cls: T, framework: Any, module_name: str) -> T:
268271
motor_class_name = framework.CLASS_PREFIX + cls.__motor_class_name__
269272
cache_key = (cls, motor_class_name, framework)
270273
cached_class = _class_cache.get(cache_key)

motor/motor_asyncio.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
# limitations under the License.
1414

1515
"""Asyncio support for Motor, an asynchronous driver for MongoDB."""
16-
from typing import TypeVar
17-
1816
from . import core, motor_gridfs
1917
from .frameworks import asyncio as asyncio_framework
20-
from .metaprogramming import create_class_with_framework
18+
from .metaprogramming import T, create_class_with_framework
2119

2220
__all__ = [
2321
"AsyncIOMotorClient",
@@ -34,8 +32,6 @@
3432
"AsyncIOMotorClientEncryption",
3533
]
3634

37-
T = TypeVar("T")
38-
3935

4036
def create_asyncio_class(cls: T) -> T:
4137
return create_class_with_framework(cls, asyncio_framework, "motor.motor_asyncio")

motor/motor_tornado.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
# limitations under the License.
1414

1515
"""Tornado support for Motor, an asynchronous driver for MongoDB."""
16-
from typing import TypeVar
1716

1817
from . import core, motor_gridfs
1918
from .frameworks import tornado as tornado_framework
20-
from .metaprogramming import create_class_with_framework
19+
from .metaprogramming import T, create_class_with_framework
2120

2221
__all__ = [
2322
"MotorClient",
@@ -34,8 +33,6 @@
3433
"MotorClientEncryption",
3534
]
3635

37-
T = TypeVar("T")
38-
3936

4037
def create_motor_class(cls: T) -> T:
4138
return create_class_with_framework(cls, tornado_framework, "motor.motor_tornado")

mypy.ini

Lines changed: 0 additions & 11 deletions
This file was deleted.

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,37 @@ version = {attr = "motor._version.version"}
8181
[tool.setuptools.packages.find]
8282
include = ["motor"]
8383

84+
[tool.mypy]
85+
python_version = "3.7"
86+
strict = true
87+
pretty = true
88+
show_error_context = true
89+
show_error_codes = true
90+
warn_redundant_casts = true
91+
warn_unreachable = true
92+
disable_error_code = ["type-arg"]
93+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
94+
95+
[tool.pytest.ini_options]
96+
minversion = "7"
97+
testpaths = ["test"]
98+
xfail_strict = true
99+
log_cli_level = "INFO"
100+
addopts = ["-ra", "--strict-config", "--strict-markers",
101+
"--maxfail=10", "--durations=5", "--junitxml=xunit-results/TEST-results.xml"]
102+
faulthandler_timeout = 1500
103+
filterwarnings = [
104+
"error",
105+
"ignore:Bare functions are deprecated, use async ones:DeprecationWarning",
106+
"ignore:Application.make_handler:DeprecationWarning",
107+
"ignore:unclosed <socket.socket:ResourceWarning",
108+
"ignore:unclosed event loop:ResourceWarning",
109+
"ignore: The fetch_next property is deprecated:DeprecationWarning",
110+
"ignore:The next_object method is deprecated:DeprecationWarning",
111+
"ignore:unclosed <ssl.SSLSocket:ResourceWarning",
112+
"ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning",
113+
"ignore:datetime.datetime.utcnow:DeprecationWarning",
114+
]
84115

85116
[tool.ruff]
86117
target-version = "py37"

pytest.ini

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)