From 0763cd7b95f38cd985a0ead3d6fd67ce4c0f13cc Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Tue, 9 May 2023 17:33:07 +0100 Subject: [PATCH] Add pyright strict type checking --- Makefile | 1 + examples/in_memory/main.py | 1 + examples/redis/main.py | 3 +- fastapi_cache/backends/dynamodb.py | 2 +- fastapi_cache/coder.py | 20 +++-- fastapi_cache/decorator.py | 2 +- poetry.lock | 140 ++++++++++++++++++++--------- pyproject.toml | 12 ++- tests/test_decorator.py | 4 +- 9 files changed, 124 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 0cdeb49..7cf944a 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ check: deps @black $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false) @flake8 $(checkfiles) @mypy ${checkfiles} + @pyright ${checkfiles} test: deps $(py_warn) pytest diff --git a/examples/in_memory/main.py b/examples/in_memory/main.py index 3e78454..44ad088 100644 --- a/examples/in_memory/main.py +++ b/examples/in_memory/main.py @@ -1,3 +1,4 @@ +# pyright: reportGeneralTypeIssues=false from typing import Dict, Optional import pendulum diff --git a/examples/redis/main.py b/examples/redis/main.py index e05eda5..bac677d 100644 --- a/examples/redis/main.py +++ b/examples/redis/main.py @@ -1,3 +1,4 @@ +# pyright: reportGeneralTypeIssues=false import time import pendulum @@ -87,4 +88,4 @@ async def startup(): if __name__ == "__main__": - uvicorn.run("main:app", debug=True, reload=True) + uvicorn.run("main:app", reload=True) diff --git a/fastapi_cache/backends/dynamodb.py b/fastapi_cache/backends/dynamodb.py index 5d9130a..94318c9 100644 --- a/fastapi_cache/backends/dynamodb.py +++ b/fastapi_cache/backends/dynamodb.py @@ -41,7 +41,7 @@ class DynamoBackend(Backend): self.region = region async def init(self) -> None: - self.client = await self.session.create_client( + self.client = await self.session.create_client( # pyright: ignore[reportUnknownMemberType] "dynamodb", region_name=self.region ).__aenter__() diff --git a/fastapi_cache/coder.py b/fastapi_cache/coder.py index c568bc2..1652d7b 100644 --- a/fastapi_cache/coder.py +++ b/fastapi_cache/coder.py @@ -8,7 +8,9 @@ import pendulum from fastapi.encoders import jsonable_encoder from pydantic import BaseConfig, ValidationError, fields from starlette.responses import JSONResponse -from starlette.templating import _TemplateResponse as TemplateResponse +from starlette.templating import ( + _TemplateResponse as TemplateResponse, # pyright: ignore[reportPrivateUsage] +) _T = TypeVar("_T", bound=type) @@ -22,15 +24,15 @@ CONVERTERS: Dict[str, Callable[[str], Any]] = { class JsonEncoder(json.JSONEncoder): - def default(self, obj: Any) -> Any: - if isinstance(obj, datetime.datetime): - return {"val": str(obj), "_spec_type": "datetime"} - elif isinstance(obj, datetime.date): - return {"val": str(obj), "_spec_type": "date"} - elif isinstance(obj, Decimal): - return {"val": str(obj), "_spec_type": "decimal"} + def default(self, o: Any) -> Any: + if isinstance(o, datetime.datetime): + return {"val": str(o), "_spec_type": "datetime"} + elif isinstance(o, datetime.date): + return {"val": str(o), "_spec_type": "date"} + elif isinstance(o, Decimal): + return {"val": str(o), "_spec_type": "decimal"} else: - return jsonable_encoder(obj) + return jsonable_encoder(o) def object_hook(obj: Any) -> Any: diff --git a/fastapi_cache/decorator.py b/fastapi_cache/decorator.py index f103a34..0089dbc 100644 --- a/fastapi_cache/decorator.py +++ b/fastapi_cache/decorator.py @@ -29,7 +29,7 @@ def _augment_signature(signature: Signature, *extra: Parameter) -> Signature: return signature parameters = list(signature.parameters.values()) - variadic_keyword_params = [] + variadic_keyword_params: List[Parameter] = [] while parameters and parameters[-1].kind is Parameter.VAR_KEYWORD: variadic_keyword_params.append(parameters.pop()) diff --git a/poetry.lock b/poetry.lock index ec62bb2..488191e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -306,8 +306,8 @@ crt = ["awscrt (==0.11.24)"] name = "botocore-stubs" version = "1.29.130" description = "Type annotations and code completion for botocore" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.7,<4.0" files = [ {file = "botocore_stubs-1.29.130-py3-none-any.whl", hash = "sha256:622c4a5cd740498439008d81c5ded612146f4f0d575341c12591f978edbbe733"}, @@ -997,38 +997,38 @@ files = [ [[package]] name = "mypy" -version = "1.2.0" +version = "1.3.0" description = "Optional static typing for Python" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "mypy-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:701189408b460a2ff42b984e6bd45c3f41f0ac9f5f58b8873bbedc511900086d"}, - {file = "mypy-1.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fe91be1c51c90e2afe6827601ca14353bbf3953f343c2129fa1e247d55fd95ba"}, - {file = "mypy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d26b513225ffd3eacece727f4387bdce6469192ef029ca9dd469940158bc89e"}, - {file = "mypy-1.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3a2d219775a120581a0ae8ca392b31f238d452729adbcb6892fa89688cb8306a"}, - {file = "mypy-1.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:2e93a8a553e0394b26c4ca683923b85a69f7ccdc0139e6acd1354cc884fe0128"}, - {file = "mypy-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3efde4af6f2d3ccf58ae825495dbb8d74abd6d176ee686ce2ab19bd025273f41"}, - {file = "mypy-1.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:695c45cea7e8abb6f088a34a6034b1d273122e5530aeebb9c09626cea6dca4cb"}, - {file = "mypy-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0e9464a0af6715852267bf29c9553e4555b61f5904a4fc538547a4d67617937"}, - {file = "mypy-1.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8293a216e902ac12779eb7a08f2bc39ec6c878d7c6025aa59464e0c4c16f7eb9"}, - {file = "mypy-1.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:f46af8d162f3d470d8ffc997aaf7a269996d205f9d746124a179d3abe05ac602"}, - {file = "mypy-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:031fc69c9a7e12bcc5660b74122ed84b3f1c505e762cc4296884096c6d8ee140"}, - {file = "mypy-1.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:390bc685ec209ada4e9d35068ac6988c60160b2b703072d2850457b62499e336"}, - {file = "mypy-1.2.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:4b41412df69ec06ab141808d12e0bf2823717b1c363bd77b4c0820feaa37249e"}, - {file = "mypy-1.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:4e4a682b3f2489d218751981639cffc4e281d548f9d517addfd5a2917ac78119"}, - {file = "mypy-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a197ad3a774f8e74f21e428f0de7f60ad26a8d23437b69638aac2764d1e06a6a"}, - {file = "mypy-1.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c9a084bce1061e55cdc0493a2ad890375af359c766b8ac311ac8120d3a472950"}, - {file = "mypy-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaeaa0888b7f3ccb7bcd40b50497ca30923dba14f385bde4af78fac713d6d6f6"}, - {file = "mypy-1.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bea55fc25b96c53affab852ad94bf111a3083bc1d8b0c76a61dd101d8a388cf5"}, - {file = "mypy-1.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:4c8d8c6b80aa4a1689f2a179d31d86ae1367ea4a12855cc13aa3ba24bb36b2d8"}, - {file = "mypy-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:70894c5345bea98321a2fe84df35f43ee7bb0feec117a71420c60459fc3e1eed"}, - {file = "mypy-1.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4a99fe1768925e4a139aace8f3fb66db3576ee1c30b9c0f70f744ead7e329c9f"}, - {file = "mypy-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:023fe9e618182ca6317ae89833ba422c411469156b690fde6a315ad10695a521"}, - {file = "mypy-1.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4d19f1a239d59f10fdc31263d48b7937c585810288376671eaf75380b074f238"}, - {file = "mypy-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:2de7babe398cb7a85ac7f1fd5c42f396c215ab3eff731b4d761d68d0f6a80f48"}, - {file = "mypy-1.2.0-py3-none-any.whl", hash = "sha256:d8e9187bfcd5ffedbe87403195e1fc340189a68463903c39e2b63307c9fa0394"}, - {file = "mypy-1.2.0.tar.gz", hash = "sha256:f70a40410d774ae23fcb4afbbeca652905a04de7948eaf0b1789c8d1426b72d1"}, + {file = "mypy-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c1eb485cea53f4f5284e5baf92902cd0088b24984f4209e25981cc359d64448d"}, + {file = "mypy-1.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4c99c3ecf223cf2952638da9cd82793d8f3c0c5fa8b6ae2b2d9ed1e1ff51ba85"}, + {file = "mypy-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:550a8b3a19bb6589679a7c3c31f64312e7ff482a816c96e0cecec9ad3a7564dd"}, + {file = "mypy-1.3.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cbc07246253b9e3d7d74c9ff948cd0fd7a71afcc2b77c7f0a59c26e9395cb152"}, + {file = "mypy-1.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:a22435632710a4fcf8acf86cbd0d69f68ac389a3892cb23fbad176d1cddaf228"}, + {file = "mypy-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6e33bb8b2613614a33dff70565f4c803f889ebd2f859466e42b46e1df76018dd"}, + {file = "mypy-1.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7d23370d2a6b7a71dc65d1266f9a34e4cde9e8e21511322415db4b26f46f6b8c"}, + {file = "mypy-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:658fe7b674769a0770d4b26cb4d6f005e88a442fe82446f020be8e5f5efb2fae"}, + {file = "mypy-1.3.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:6e42d29e324cdda61daaec2336c42512e59c7c375340bd202efa1fe0f7b8f8ca"}, + {file = "mypy-1.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:d0b6c62206e04061e27009481cb0ec966f7d6172b5b936f3ead3d74f29fe3dcf"}, + {file = "mypy-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:76ec771e2342f1b558c36d49900dfe81d140361dd0d2df6cd71b3db1be155409"}, + {file = "mypy-1.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ebc95f8386314272bbc817026f8ce8f4f0d2ef7ae44f947c4664efac9adec929"}, + {file = "mypy-1.3.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:faff86aa10c1aa4a10e1a301de160f3d8fc8703b88c7e98de46b531ff1276a9a"}, + {file = "mypy-1.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:8c5979d0deb27e0f4479bee18ea0f83732a893e81b78e62e2dda3e7e518c92ee"}, + {file = "mypy-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c5d2cc54175bab47011b09688b418db71403aefad07cbcd62d44010543fc143f"}, + {file = "mypy-1.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:87df44954c31d86df96c8bd6e80dfcd773473e877ac6176a8e29898bfb3501cb"}, + {file = "mypy-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:473117e310febe632ddf10e745a355714e771ffe534f06db40702775056614c4"}, + {file = "mypy-1.3.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:74bc9b6e0e79808bf8678d7678b2ae3736ea72d56eede3820bd3849823e7f305"}, + {file = "mypy-1.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:44797d031a41516fcf5cbfa652265bb994e53e51994c1bd649ffcd0c3a7eccbf"}, + {file = "mypy-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ddae0f39ca146972ff6bb4399f3b2943884a774b8771ea0a8f50e971f5ea5ba8"}, + {file = "mypy-1.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1c4c42c60a8103ead4c1c060ac3cdd3ff01e18fddce6f1016e08939647a0e703"}, + {file = "mypy-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e86c2c6852f62f8f2b24cb7a613ebe8e0c7dc1402c61d36a609174f63e0ff017"}, + {file = "mypy-1.3.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f9dca1e257d4cc129517779226753dbefb4f2266c4eaad610fc15c6a7e14283e"}, + {file = "mypy-1.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:95d8d31a7713510685b05fbb18d6ac287a56c8f6554d88c19e73f724a445448a"}, + {file = "mypy-1.3.0-py3-none-any.whl", hash = "sha256:a8763e72d5d9574d45ce5881962bc8e9046bf7b375b0abf031f3e6811732a897"}, + {file = "mypy-1.3.0.tar.gz", hash = "sha256:e1f4d16e296f5135624b34e8fb741eb0eadedca90862405b1f1fde2040b9bd11"}, ] [package.dependencies] @@ -1055,6 +1055,21 @@ files = [ {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, ] +[[package]] +name = "nodeenv" +version = "1.7.0" +description = "Node.js virtual environment builder" +category = "dev" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.7.0-py2.py3-none-any.whl", hash = "sha256:27083a7b96a25f2f5e1d8cb4b6317ee8aeda3bdd121394e5ac54e498028a042e"}, + {file = "nodeenv-1.7.0.tar.gz", hash = "sha256:e0e7f7dfb85fc5394c6fe1e8fa98131a2473e04311a45afb6508f7cf1836fa2b"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "packaging" version = "23.1" @@ -1241,6 +1256,26 @@ files = [ {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, ] +[[package]] +name = "pyright" +version = "1.1.307" +description = "Command line wrapper for pyright" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pyright-1.1.307-py3-none-any.whl", hash = "sha256:6b360d2e018311bdf8acea73ef1f21bf0b5b502345aa94bc6763cf197b2e75b3"}, + {file = "pyright-1.1.307.tar.gz", hash = "sha256:b7a8734fad4a2438b8bb0dfbe462f529c9d4eb31947bdae85b9b4e7a97ff6a49"}, +] + +[package.dependencies] +nodeenv = ">=1.6.0" +typing-extensions = {version = ">=3.7", markers = "python_version < \"3.8\""} + +[package.extras] +all = ["twine (>=3.4.1)"] +dev = ["twine (>=3.4.1)"] + [[package]] name = "pytest" version = "7.3.1" @@ -1335,6 +1370,23 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "setuptools" +version = "67.7.2" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "setuptools-67.7.2-py3-none-any.whl", hash = "sha256:23aaf86b85ca52ceb801d32703f12d77517b2556af839621c641fca11287952b"}, + {file = "setuptools-67.7.2.tar.gz", hash = "sha256:f104fa03692a2602fa0fec6c6a9e63b6c8a968de13e17c026957dd1f53d80990"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "six" version = "1.16.0" @@ -1428,8 +1480,8 @@ files = [ name = "types-aiobotocore" version = "2.5.0.post2" description = "Type annotations for aiobotocore 2.5.0 generated with mypy-boto3-builder 7.14.5" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.7" files = [ {file = "types-aiobotocore-2.5.0.post2.tar.gz", hash = "sha256:e0e46a6834841db86083ce0dad3d5efbaebe0a43c18f783b0e8c95ea1f7e80c5"}, @@ -1790,8 +1842,8 @@ xray = ["types-aiobotocore-xray (>=2.5.0,<2.6.0)"] name = "types-aiobotocore-dynamodb" version = "2.5.0.post1" description = "Type annotations for aiobotocore.DynamoDB 2.5.0 service generated with mypy-boto3-builder 7.13.0" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.7" files = [ {file = "types-aiobotocore-dynamodb-2.5.0.post1.tar.gz", hash = "sha256:21ed5a55c6aa4e7ac3660b8b1af7b85a88294b292e4232afea4c771d794ebc84"}, @@ -1805,8 +1857,8 @@ typing-extensions = ">=4.1.0" name = "types-awscrt" version = "0.16.17" description = "Type annotations and code completion for awscrt" -category = "main" -optional = true +category = "dev" +optional = false python-versions = ">=3.7,<4.0" files = [ {file = "types_awscrt-0.16.17-py3-none-any.whl", hash = "sha256:e28fb3f20568ce9e96e33e01e0b87b891822f36b8f368adb582553b016d4aa08"}, @@ -1815,14 +1867,14 @@ files = [ [[package]] name = "types-pyopenssl" -version = "23.1.0.2" +version = "23.1.0.3" description = "Typing stubs for pyOpenSSL" category = "dev" optional = false python-versions = "*" files = [ - {file = "types-pyOpenSSL-23.1.0.2.tar.gz", hash = "sha256:20b80971b86240e8432a1832bd8124cea49c3088c7bfc77dfd23be27ffe4a517"}, - {file = "types_pyOpenSSL-23.1.0.2-py3-none-any.whl", hash = "sha256:b050641aeff6dfebf231ad719bdac12d53b8ee818d4afb67b886333484629957"}, + {file = "types-pyOpenSSL-23.1.0.3.tar.gz", hash = "sha256:e7211088eff3e20d359888dedecb0994f7181d5cce0f26354dd47ca0484dc8a6"}, + {file = "types_pyOpenSSL-23.1.0.3-py3-none-any.whl", hash = "sha256:ad024b07a1f4bffbca44699543c71efd04733a6c22781fa9673a971e410a3086"}, ] [package.dependencies] @@ -1830,14 +1882,14 @@ cryptography = ">=35.0.0" [[package]] name = "types-redis" -version = "4.5.5.0" +version = "4.5.5.1" description = "Typing stubs for redis" category = "dev" optional = false python-versions = "*" files = [ - {file = "types-redis-4.5.5.0.tar.gz", hash = "sha256:26547d91f011a4024375d9216cd4d917b4678c984201d46f72c604526c138523"}, - {file = "types_redis-4.5.5.0-py3-none-any.whl", hash = "sha256:c7132e0cedeb52a83d20138c0440721bfae89cd2027c1ef57a294b56dfde4ee8"}, + {file = "types-redis-4.5.5.1.tar.gz", hash = "sha256:0193d0522cccd6d46e9e17b811c30fc407e1800e0381da0e95f5c9239bdca58b"}, + {file = "types_redis-4.5.5.1-py3-none-any.whl", hash = "sha256:569b9795618c95d5f8fad2156dceb622614162761b4382892b99c519c378f776"}, ] [package.dependencies] @@ -2083,12 +2135,12 @@ docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] [extras] -all = ["aiobotocore", "aiomcache", "redis", "types-aiobotocore"] -dynamodb = ["aiobotocore", "types-aiobotocore"] +all = ["aiobotocore", "aiomcache", "redis"] +dynamodb = ["aiobotocore"] memcache = ["aiomcache"] redis = ["redis"] [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "31a6d15bd2f6d3bf3047f8cb739cd7951fa92b642c334bd752247eb401428f55" +content-hash = "3ccacd20507af6c47bf9895f36104fb39abf32b686ff00882fb131668fc9d167" diff --git a/pyproject.toml b/pyproject.toml index 488c8d5..0fd4078 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ redis = { version = "^4.2.0rc1", optional = true } aiomcache = { version = "*", optional = true } pendulum = "*" aiobotocore = { version = "^1.4.1", optional = true } -types-aiobotocore = { extras = ["dynamodb"], version = "^2.5.0.post2", optional = true } typing-extensions = { version = ">=4.1.0" } aiohttp = { version = ">=3.8.3", markers = "python_version >= \"3.11\"" } @@ -36,6 +35,8 @@ coverage = "^6.5.0" httpx = "*" mypy = "^1.2.0" types-redis = "^4.5.4.2" +pyright = "^1.1.306" +types-aiobotocore = { extras = ["dynamodb"], version = "^2.5.0.post2" } [build-system] requires = ["poetry>=0.12"] @@ -44,8 +45,8 @@ build-backend = "poetry.masonry.api" [tool.poetry.extras] redis = ["redis"] memcache = ["aiomcache"] -dynamodb = ["aiobotocore", "types-aiobotocore"] -all = ["redis", "aiomcache", "aiobotocore", "types-aiobotocore"] +dynamodb = ["aiobotocore"] +all = ["redis", "aiomcache", "aiobotocore"] [tool.black] line-length = 100 @@ -73,3 +74,8 @@ strict_concatenate = true [[tool.mypy.overrides]] module = "examples.*.main" ignore_errors = true + +[tool.pyright] +include = ["fastapi_cache", "tests", "examples"] +strict = ["fastapi_cache", "tests"] +pythonVersion = "3.7" diff --git a/tests/test_decorator.py b/tests/test_decorator.py index d79a568..5d3c472 100644 --- a/tests/test_decorator.py +++ b/tests/test_decorator.py @@ -45,10 +45,10 @@ def test_date() -> None: assert pendulum.parse(response.json()) == pendulum.today() # type: ignore[attr-defined] # now test with cache disabled, as that's a separate code path - FastAPICache._enable = False + FastAPICache._enable = False # pyright: ignore[reportPrivateUsage] response = client.get("/date") assert pendulum.parse(response.json()) == pendulum.today() # type: ignore[attr-defined] - FastAPICache._enable = True + FastAPICache._enable = True # pyright: ignore[reportPrivateUsage] def test_sync() -> None: