From 6e994a67b6fe7ab8300b95697f7f557bee3ce124 Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Sat, 14 Sep 2024 14:18:04 +0300 Subject: [PATCH 1/2] chore: Update ruff --- coreschema-stubs/schemas.pyi | 8 +- poetry.lock | 205 +++------------------------ pyproject.toml | 16 +-- rest_framework-stubs/renderers.pyi | 2 +- rest_framework-stubs/reverse.pyi | 4 +- rest_framework-stubs/serializers.pyi | 1 + rest_framework-stubs/test.pyi | 26 ++-- rest_framework-stubs/versioning.pyi | 2 +- s/lint | 8 +- 9 files changed, 56 insertions(+), 216 deletions(-) diff --git a/coreschema-stubs/schemas.pyi b/coreschema-stubs/schemas.pyi index 63207b4fa..db8b73656 100644 --- a/coreschema-stubs/schemas.pyi +++ b/coreschema-stubs/schemas.pyi @@ -43,7 +43,7 @@ class Object(Schema): min_properties: Any | None = ..., pattern_properties: Any | None = ..., additional_properties: bool = ..., - **kwargs: Any + **kwargs: Any, ) -> None: ... def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ... @@ -61,7 +61,7 @@ class Array(Schema): min_items: Any | None = ..., unique_items: bool = ..., additional_items: bool = ..., - **kwargs: Any + **kwargs: Any, ) -> None: ... def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ... @@ -80,7 +80,7 @@ class Number(Schema): exclusive_minimum: bool = ..., exclusive_maximum: bool = ..., multiple_of: int | None = ..., - **kwargs: Any + **kwargs: Any, ) -> None: ... def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ... @@ -101,7 +101,7 @@ class String(Schema): min_length: int | None = ..., pattern: str | None = ..., format: Any | None = ..., - **kwargs: Any + **kwargs: Any, ) -> None: ... def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ... diff --git a/poetry.lock b/poetry.lock index 4a66c8a19..23fcdacbf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "appnope" @@ -22,9 +22,6 @@ files = [ {file = "asgiref-3.5.0.tar.gz", hash = "sha256:2f8abc20f7248433085eda803936d98992f1343ddb022065779f37c5da0181d0"}, ] -[package.dependencies] -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} - [package.extras] tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] @@ -56,66 +53,6 @@ files = [ {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"}, ] -[[package]] -name = "black" -version = "22.10.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.7" -files = [ - {file = "black-22.10.0-1fixedarch-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:5cc42ca67989e9c3cf859e84c2bf014f6633db63d1cbdf8fdb666dcd9e77e3fa"}, - {file = "black-22.10.0-1fixedarch-cp311-cp311-macosx_11_0_x86_64.whl", hash = "sha256:5d8f74030e67087b219b032aa33a919fae8806d49c867846bfacde57f43972ef"}, - {file = "black-22.10.0-1fixedarch-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:197df8509263b0b8614e1df1756b1dd41be6738eed2ba9e9769f3880c2b9d7b6"}, - {file = "black-22.10.0-1fixedarch-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:2644b5d63633702bc2c5f3754b1b475378fbbfb481f62319388235d0cd104c2d"}, - {file = "black-22.10.0-1fixedarch-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:e41a86c6c650bcecc6633ee3180d80a025db041a8e2398dcc059b3afa8382cd4"}, - {file = "black-22.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2039230db3c6c639bd84efe3292ec7b06e9214a2992cd9beb293d639c6402edb"}, - {file = "black-22.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14ff67aec0a47c424bc99b71005202045dc09270da44a27848d534600ac64fc7"}, - {file = "black-22.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:819dc789f4498ecc91438a7de64427c73b45035e2e3680c92e18795a839ebb66"}, - {file = "black-22.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5b9b29da4f564ba8787c119f37d174f2b69cdfdf9015b7d8c5c16121ddc054ae"}, - {file = "black-22.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8b49776299fece66bffaafe357d929ca9451450f5466e997a7285ab0fe28e3b"}, - {file = "black-22.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:21199526696b8f09c3997e2b4db8d0b108d801a348414264d2eb8eb2532e540d"}, - {file = "black-22.10.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e464456d24e23d11fced2bc8c47ef66d471f845c7b7a42f3bd77bf3d1789650"}, - {file = "black-22.10.0-cp37-cp37m-win_amd64.whl", hash = "sha256:9311e99228ae10023300ecac05be5a296f60d2fd10fff31cf5c1fa4ca4b1988d"}, - {file = "black-22.10.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:fba8a281e570adafb79f7755ac8721b6cf1bbf691186a287e990c7929c7692ff"}, - {file = "black-22.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:915ace4ff03fdfff953962fa672d44be269deb2eaf88499a0f8805221bc68c87"}, - {file = "black-22.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:444ebfb4e441254e87bad00c661fe32df9969b2bf224373a448d8aca2132b395"}, - {file = "black-22.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:974308c58d057a651d182208a484ce80a26dac0caef2895836a92dd6ebd725e0"}, - {file = "black-22.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72ef3925f30e12a184889aac03d77d031056860ccae8a1e519f6cbb742736383"}, - {file = "black-22.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:432247333090c8c5366e69627ccb363bc58514ae3e63f7fc75c54b1ea80fa7de"}, - {file = "black-22.10.0-py3-none-any.whl", hash = "sha256:c957b2b4ea88587b46cf49d1dc17681c1e672864fd7af32fc1e9664d572b3458"}, - {file = "black-22.10.0.tar.gz", hash = "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} -typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - -[[package]] -name = "click" -version = "8.1.3" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, - {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} - [[package]] name = "colorama" version = "0.4.4" @@ -181,7 +118,6 @@ files = [ ] [package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} mccabe = ">=0.6.0,<0.7.0" pycodestyle = ">=2.7.0,<2.8.0" pyflakes = ">=2.3.0,<2.4.0" @@ -202,26 +138,6 @@ attrs = "*" flake8 = ">=3.2.1" pyflakes = ">=2.1.1" -[[package]] -name = "importlib-metadata" -version = "4.10.1" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.7" -files = [ - {file = "importlib_metadata-4.10.1-py3-none-any.whl", hash = "sha256:899e2a40a8c4a1aec681feef45733de8a6c58f3f6a0dbed2eb6574b4387a77b6"}, - {file = "importlib_metadata-4.10.1.tar.gz", hash = "sha256:951f0d8a5b7260e9db5e41d429285b5f451e928479f19d80818878527d36e95e"}, -] - -[package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} -zipp = ">=0.5" - -[package.extras] -docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] -perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy", "pytest-perf (>=0.9.2)"] - [[package]] name = "ipython" version = "7.31.1" @@ -356,7 +272,6 @@ files = [ [package.dependencies] mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} typing-extensions = ">=4.1.0" [package.extras] @@ -405,17 +320,6 @@ files = [ qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] testing = ["docopt", "pytest (<6.0.0)"] -[[package]] -name = "pathspec" -version = "0.10.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.7" -files = [ - {file = "pathspec-0.10.1-py3-none-any.whl", hash = "sha256:46846318467efc4556ccfd27816e004270a9eeeeb4d062ce5e6fc7a87c573f93"}, - {file = "pathspec-0.10.1.tar.gz", hash = "sha256:7ace6161b621d31e7902eb6b5ae148d12cfd23f4a249b9ffb6b9fee12084323d"}, -] - [[package]] name = "pexpect" version = "4.8.0" @@ -441,21 +345,6 @@ files = [ {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"}, ] -[[package]] -name = "platformdirs" -version = "2.5.2" -description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.7" -files = [ - {file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"}, - {file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"}, -] - -[package.extras] -docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx (>=4)", "sphinx-autodoc-typehints (>=1.12)"] -test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"] - [[package]] name = "prompt-toolkit" version = "3.0.26" @@ -527,7 +416,6 @@ files = [ [package.dependencies] nodeenv = ">=1.6.0" -typing-extensions = {version = ">=3.7", markers = "python_version < \"3.8\""} [package.extras] all = ["twine (>=3.4.1)"] @@ -546,28 +434,29 @@ files = [ [[package]] name = "ruff" -version = "0.0.261" -description = "An extremely fast Python linter, written in Rust." +version = "0.6.5" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.261-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:6624a966c4a21110cee6780333e2216522a831364896f3d98f13120936eff40a"}, - {file = "ruff-0.0.261-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:2dba68a9e558ab33e6dd5d280af798a2d9d3c80c913ad9c8b8e97d7b287f1cc9"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8dbd0cee5a81b0785dc0feeb2640c1e31abe93f0d77c5233507ac59731a626f1"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:581e64fa1518df495ca890a605ee65065101a86db56b6858f848bade69fc6489"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cc970f6ece0b4950e419f0252895ee42e9e8e5689c6494d18f5dc2c6ebb7f798"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:8fa98e747e0fe185d65a40b0ea13f55c492f3b5f9a032a1097e82edaddb9e52e"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f268d52a71bf410aa45c232870c17049df322a7d20e871cfe622c9fc784aab7b"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d1293acc64eba16a11109678dc4743df08c207ed2edbeaf38b3e10eb2597321b"}, - {file = "ruff-0.0.261-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d95596e2f4cafead19a6d1ec0b86f8fda45ba66fe934de3956d71146a87959b3"}, - {file = "ruff-0.0.261-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4bcec45abdf65c1328a269cf6cc193f7ff85b777fa2865c64cf2c96b80148a2c"}, - {file = "ruff-0.0.261-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:6c5f397ec0af42a434ad4b6f86565027406c5d0d0ebeea0d5b3f90c4bf55bc82"}, - {file = "ruff-0.0.261-py3-none-musllinux_1_2_i686.whl", hash = "sha256:39abd02342cec0c131b2ddcaace08b2eae9700cab3ca7dba64ae5fd4f4881bd0"}, - {file = "ruff-0.0.261-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:aaa4f52a6e513f8daa450dac4859e80390d947052f592f0d8e796baab24df2fc"}, - {file = "ruff-0.0.261-py3-none-win32.whl", hash = "sha256:daff64b4e86e42ce69e6367d63aab9562fc213cd4db0e146859df8abc283dba0"}, - {file = "ruff-0.0.261-py3-none-win_amd64.whl", hash = "sha256:0fbc689c23609edda36169c8708bb91bab111d8f44cb4a88330541757770ab30"}, - {file = "ruff-0.0.261-py3-none-win_arm64.whl", hash = "sha256:d2eddc60ae75fc87f8bb8fd6e8d5339cf884cd6de81e82a50287424309c187ba"}, - {file = "ruff-0.0.261.tar.gz", hash = "sha256:c1c715b0d1e18f9c509d7c411ca61da3543a4aa459325b1b1e52b8301d65c6d2"}, + {file = "ruff-0.6.5-py3-none-linux_armv6l.whl", hash = "sha256:7e4e308f16e07c95fc7753fc1aaac690a323b2bb9f4ec5e844a97bb7fbebd748"}, + {file = "ruff-0.6.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:932cd69eefe4daf8c7d92bd6689f7e8182571cb934ea720af218929da7bd7d69"}, + {file = "ruff-0.6.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3a8d42d11fff8d3143ff4da41742a98f8f233bf8890e9fe23077826818f8d680"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a50af6e828ee692fb10ff2dfe53f05caecf077f4210fae9677e06a808275754f"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:794ada3400a0d0b89e3015f1a7e01f4c97320ac665b7bc3ade24b50b54cb2972"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:381413ec47f71ce1d1c614f7779d88886f406f1fd53d289c77e4e533dc6ea200"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:52e75a82bbc9b42e63c08d22ad0ac525117e72aee9729a069d7c4f235fc4d276"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:09c72a833fd3551135ceddcba5ebdb68ff89225d30758027280968c9acdc7810"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:800c50371bdcb99b3c1551d5691e14d16d6f07063a518770254227f7f6e8c178"}, + {file = "ruff-0.6.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8e25ddd9cd63ba1f3bd51c1f09903904a6adf8429df34f17d728a8fa11174253"}, + {file = "ruff-0.6.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7291e64d7129f24d1b0c947ec3ec4c0076e958d1475c61202497c6aced35dd19"}, + {file = "ruff-0.6.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:9ad7dfbd138d09d9a7e6931e6a7e797651ce29becd688be8a0d4d5f8177b4b0c"}, + {file = "ruff-0.6.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:005256d977021790cc52aa23d78f06bb5090dc0bfbd42de46d49c201533982ae"}, + {file = "ruff-0.6.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:482c1e6bfeb615eafc5899127b805d28e387bd87db38b2c0c41d271f5e58d8cc"}, + {file = "ruff-0.6.5-py3-none-win32.whl", hash = "sha256:cf4d3fa53644137f6a4a27a2b397381d16454a1566ae5335855c187fbf67e4f5"}, + {file = "ruff-0.6.5-py3-none-win_amd64.whl", hash = "sha256:3e42a57b58e3612051a636bc1ac4e6b838679530235520e8f095f7c44f706ff9"}, + {file = "ruff-0.6.5-py3-none-win_arm64.whl", hash = "sha256:51935067740773afdf97493ba9b8231279e9beef0f2a8079188c4776c25688e0"}, + {file = "ruff-0.6.5.tar.gz", hash = "sha256:4d32d87fab433c0cf285c3683dd4dae63be05fd7a1d65b3f5bf7cdd05a6b96fb"}, ] [[package]] @@ -622,39 +511,6 @@ files = [ [package.extras] test = ["pytest"] -[[package]] -name = "typed-ast" -version = "1.5.4" -description = "a fork of Python 2 and 3 ast modules with type comment support" -optional = false -python-versions = ">=3.6" -files = [ - {file = "typed_ast-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:669dd0c4167f6f2cd9f57041e03c3c2ebf9063d0757dc89f79ba1daa2bfca9d4"}, - {file = "typed_ast-1.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:211260621ab1cd7324e0798d6be953d00b74e0428382991adfddb352252f1d62"}, - {file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:267e3f78697a6c00c689c03db4876dd1efdfea2f251a5ad6555e82a26847b4ac"}, - {file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:c542eeda69212fa10a7ada75e668876fdec5f856cd3d06829e6aa64ad17c8dfe"}, - {file = "typed_ast-1.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:a9916d2bb8865f973824fb47436fa45e1ebf2efd920f2b9f99342cb7fab93f72"}, - {file = "typed_ast-1.5.4-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:79b1e0869db7c830ba6a981d58711c88b6677506e648496b1f64ac7d15633aec"}, - {file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a94d55d142c9265f4ea46fab70977a1944ecae359ae867397757d836ea5a3f47"}, - {file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:183afdf0ec5b1b211724dfef3d2cad2d767cbefac291f24d69b00546c1837fb6"}, - {file = "typed_ast-1.5.4-cp36-cp36m-win_amd64.whl", hash = "sha256:639c5f0b21776605dd6c9dbe592d5228f021404dafd377e2b7ac046b0349b1a1"}, - {file = "typed_ast-1.5.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf4afcfac006ece570e32d6fa90ab74a17245b83dfd6655a6f68568098345ff6"}, - {file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed855bbe3eb3715fca349c80174cfcfd699c2f9de574d40527b8429acae23a66"}, - {file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6778e1b2f81dfc7bc58e4b259363b83d2e509a65198e85d5700dfae4c6c8ff1c"}, - {file = "typed_ast-1.5.4-cp37-cp37m-win_amd64.whl", hash = "sha256:0261195c2062caf107831e92a76764c81227dae162c4f75192c0d489faf751a2"}, - {file = "typed_ast-1.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2efae9db7a8c05ad5547d522e7dbe62c83d838d3906a3716d1478b6c1d61388d"}, - {file = "typed_ast-1.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7d5d014b7daa8b0bf2eaef684295acae12b036d79f54178b92a2b6a56f92278f"}, - {file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:370788a63915e82fd6f212865a596a0fefcbb7d408bbbb13dea723d971ed8bdc"}, - {file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4e964b4ff86550a7a7d56345c7864b18f403f5bd7380edf44a3c1fb4ee7ac6c6"}, - {file = "typed_ast-1.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:683407d92dc953c8a7347119596f0b0e6c55eb98ebebd9b23437501b28dcbb8e"}, - {file = "typed_ast-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4879da6c9b73443f97e731b617184a596ac1235fe91f98d279a7af36c796da35"}, - {file = "typed_ast-1.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3e123d878ba170397916557d31c8f589951e353cc95fb7f24f6bb69adc1a8a97"}, - {file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ebd9d7f80ccf7a82ac5f88c521115cc55d84e35bf8b446fcd7836eb6b98929a3"}, - {file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98f80dee3c03455e92796b58b98ff6ca0b2a6f652120c263efdba4d6c5e58f72"}, - {file = "typed_ast-1.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:0fdbcf2fef0ca421a3f5912555804296f0b0960f0418c440f5d6d3abb549f3e1"}, - {file = "typed_ast-1.5.4.tar.gz", hash = "sha256:39e21ceb7388e4bb37f4c679d72707ed46c2fbf2a5609b8b8ebc4b067d977df2"}, -] - [[package]] name = "types-requests" version = "2.28.11.2" @@ -702,22 +558,7 @@ files = [ {file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"}, ] -[[package]] -name = "zipp" -version = "3.7.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.7" -files = [ - {file = "zipp-3.7.0-py3-none-any.whl", hash = "sha256:b47250dd24f92b7dd6a0a8fc5244da14608f3ca90a5efcd37a3b1642fac9a375"}, - {file = "zipp-3.7.0.tar.gz", hash = "sha256:9f50f446828eb9d45b267433fd3e9da8d801f614129124863f9c51ebceafb87d"}, -] - -[package.extras] -docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] -testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] - [metadata] lock-version = "2.0" -python-versions = "^3.7" -content-hash = "5bd39ed8c7e9a6ce152283ea9464361fd19625e27ff95c5a86a1ae2b33ba3c92" +python-versions = "^3.8" +content-hash = "8ab480b9c1f7c7f80734f32da3dc92277e0446c3c4634ca8b6c0474218608dad" diff --git a/pyproject.toml b/pyproject.toml index d2eab8b65..dc88d98e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ packages = [ ] [tool.poetry.dependencies] -python = "^3.7" +python = "^3.8" typing_extensions = { version = "^4.6", python = "<3.11" } [tool.poetry.group.dev.dependencies] @@ -27,16 +27,15 @@ flake8 = "^3.8" flake8-pyi = "^20.10" mypy = "^1.4" isort = "5.10.1" -black = "^22.10.0" types-requests = "^2.28.11" -ruff = "^0.0.261" +ruff = "^0.6.5" pyright = "^1.1.318" -[tool.black] +[tool.ruff] +target-version = "py38" line-length = 120 -include = '\.pyi?$' -[tool.ruff] +[tool.ruff.lint] select = [ "E", "F", @@ -78,14 +77,13 @@ ignore = [ "N818", # some exceptions have bad names "N801", # some class names have bad names "ERA001", # false positives + "UP007", # We're using Union/Optional here. ] unfixable = [ "ERA001", ] # we want to check ourselves before we delete commented out code. -update-check = false -target-version = "py38" -[tool.ruff.flake8-tidy-imports] +[tool.ruff.lint.flake8-tidy-imports] # Disallow all relative imports. ban-relative-imports = "all" diff --git a/rest_framework-stubs/renderers.pyi b/rest_framework-stubs/renderers.pyi index 8fe5d8136..280cf0502 100644 --- a/rest_framework-stubs/renderers.pyi +++ b/rest_framework-stubs/renderers.pyi @@ -64,7 +64,7 @@ class BrowsableAPIRenderer(BaseRenderer): view_instance: APIView, request: Request, *args: Any, - **kwargs: Any + **kwargs: Any, ) -> BaseSerializer: ... def get_rendered_html_form(self, data: Any, view: APIView, method: str, request: Request) -> Any: ... def render_form_for_serializer(self, serializer: BaseSerializer) -> Any: ... diff --git a/rest_framework-stubs/reverse.pyi b/rest_framework-stubs/reverse.pyi index 9c2c5f1f5..72aeb86a5 100644 --- a/rest_framework-stubs/reverse.pyi +++ b/rest_framework-stubs/reverse.pyi @@ -10,7 +10,7 @@ def reverse( kwargs: Mapping[str, Any] | None = ..., request: HttpRequest | None = ..., format: str | None = ..., - **extra: Any + **extra: Any, ) -> str: ... def _reverse( viewname: str, @@ -18,7 +18,7 @@ def _reverse( kwargs: Mapping[str, Any] | None = ..., request: HttpRequest | None = ..., format: str | None = ..., - **extra: Any + **extra: Any, ) -> str: ... reverse_lazy: Callable[..., str] = ... diff --git a/rest_framework-stubs/serializers.pyi b/rest_framework-stubs/serializers.pyi index 13eb2c805..e0afe36ee 100644 --- a/rest_framework-stubs/serializers.pyi +++ b/rest_framework-stubs/serializers.pyi @@ -198,6 +198,7 @@ class ModelSerializer(Serializer, BaseSerializer): exclude: Sequence[str] | None depth: int | None extra_kwargs: dict[str, dict[str, Any]] + def __init__( self, instance: None | Any | Sequence[Any] | QuerySet[Any] | Manager[Any] = ..., diff --git a/rest_framework-stubs/test.pyi b/rest_framework-stubs/test.pyi index f0177bbdc..5c3d8e605 100644 --- a/rest_framework-stubs/test.pyi +++ b/rest_framework-stubs/test.pyi @@ -59,7 +59,7 @@ class APIRequestFactory(DjangoRequestFactory): secure: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... def post( # type: ignore [override] self, @@ -69,7 +69,7 @@ class APIRequestFactory(DjangoRequestFactory): content_type: str | None = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... def put( # type: ignore [override] self, @@ -79,7 +79,7 @@ class APIRequestFactory(DjangoRequestFactory): content_type: str | None = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... def patch( # type: ignore [override] self, @@ -89,7 +89,7 @@ class APIRequestFactory(DjangoRequestFactory): content_type: str | None = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... def delete( # type: ignore [override] self, @@ -99,7 +99,7 @@ class APIRequestFactory(DjangoRequestFactory): content_type: str | None = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... def options( # type: ignore [override] self, @@ -109,7 +109,7 @@ class APIRequestFactory(DjangoRequestFactory): content_type: Any | None = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... def generic( # type: ignore[override] self, @@ -120,7 +120,7 @@ class APIRequestFactory(DjangoRequestFactory): secure: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Request: ... class ForceAuthClientHandler(ClientHandler): @@ -139,7 +139,7 @@ class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncom follow: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Response: ... def post( # type: ignore [override] self, @@ -150,7 +150,7 @@ class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncom follow: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Response: ... def put( # type: ignore [override] self, @@ -161,7 +161,7 @@ class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncom follow: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Response: ... def patch( # type: ignore [override] self, @@ -172,7 +172,7 @@ class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncom follow: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Response: ... def delete( # type: ignore [override] self, @@ -183,7 +183,7 @@ class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncom follow: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Response: ... def options( # type: ignore [override] self, @@ -194,7 +194,7 @@ class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncom follow: bool = ..., *, QUERY_STRING: str = ..., - **extra: str + **extra: str, ) -> Response: ... def logout(self) -> None: ... diff --git a/rest_framework-stubs/versioning.pyi b/rest_framework-stubs/versioning.pyi index a23983178..2dae40332 100644 --- a/rest_framework-stubs/versioning.pyi +++ b/rest_framework-stubs/versioning.pyi @@ -16,7 +16,7 @@ class BaseVersioning: kwargs: Mapping[str, Any] | None = ..., request: Request | None = ..., format: str | None = ..., - **extra: Any + **extra: Any, ) -> str: ... def is_allowed_version(self, version: str | None) -> bool: ... diff --git a/s/lint b/s/lint index 890a7d1ba..dac7808e9 100755 --- a/s/lint +++ b/s/lint @@ -4,11 +4,11 @@ set -ex # format code if [[ $CI ]]; then - ./.venv/bin/black --check . - ./.venv/bin/ruff . + ./.venv/bin/ruff format --check + ./.venv/bin/ruff check else - ./.venv/bin/black . - ./.venv/bin/ruff . --fix + ./.venv/bin/ruff format + ./.venv/bin/ruff check --fix fi ./.venv/bin/pyright tests typings From 8edba739d46f35913bb280fc79e10bce6a084548 Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Sat, 14 Sep 2024 16:20:21 +0300 Subject: [PATCH 2/2] fix: Fix FilterBackendProtocol for django-filter --- rest_framework-stubs/decorators.pyi | 4 ++-- rest_framework-stubs/filters.pyi | 7 +++---- rest_framework-stubs/generics.pyi | 4 ++-- tests/test_restframework.py | 27 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/rest_framework-stubs/decorators.pyi b/rest_framework-stubs/decorators.pyi index 30ef41896..cfc278ed1 100644 --- a/rest_framework-stubs/decorators.pyi +++ b/rest_framework-stubs/decorators.pyi @@ -10,7 +10,7 @@ from typing import ( from django.db.models import QuerySet from django.http.response import HttpResponseBase from rest_framework.authentication import BaseAuthentication -from rest_framework.filters import _FilterBackendProtocol +from rest_framework.filters import FilterBackendProtocol from rest_framework.parsers import BaseParser from rest_framework.permissions import _PermissionClass from rest_framework.renderers import BaseRenderer @@ -112,7 +112,7 @@ def action( authentication_classes: _AuthClassesParam = ..., renderer_classes: _RenderClassesParam = ..., parser_classes: _ParserClassesParam = ..., - filter_backends: Sequence[type[_FilterBackendProtocol]] = ..., + filter_backends: Sequence[type[FilterBackendProtocol]] = ..., lookup_field: str = ..., lookup_url_kwarg: str | None = ..., queryset: QuerySet[Any] = ..., diff --git a/rest_framework-stubs/filters.pyi b/rest_framework-stubs/filters.pyi index b9476d694..af7b256bf 100644 --- a/rest_framework-stubs/filters.pyi +++ b/rest_framework-stubs/filters.pyi @@ -10,13 +10,12 @@ from rest_framework.request import Request from rest_framework.views import APIView _MT = TypeVar("_MT", bound=Model) -_Q = TypeVar("_Q", bound=QuerySet[Any]) -class _FilterBackendProtocol(Protocol): - def filter_queryset(self, request: Any, queryset: _Q, view: APIView) -> _Q: ... +class FilterBackendProtocol(Protocol): + def filter_queryset(self, request: Request, queryset: QuerySet[_MT], view: APIView) -> QuerySet[_MT]: ... class BaseFilterBackend: - def filter_queryset(self, request: Any, queryset: _Q, view: APIView) -> _Q: ... + def filter_queryset(self, request: Request, queryset: QuerySet[_MT], view: APIView) -> QuerySet[_MT]: ... def get_schema_fields(self, view: APIView) -> list[Any]: ... def get_schema_operation_parameters(self, view: APIView) -> Any: ... diff --git a/rest_framework-stubs/generics.pyi b/rest_framework-stubs/generics.pyi index 91eceaafe..e1f36379d 100644 --- a/rest_framework-stubs/generics.pyi +++ b/rest_framework-stubs/generics.pyi @@ -5,7 +5,7 @@ from django.db.models import Manager, Model from django.db.models.query import QuerySet from django.http.response import HttpResponse from rest_framework import mixins, views -from rest_framework.filters import _FilterBackendProtocol +from rest_framework.filters import FilterBackendProtocol from rest_framework.pagination import BasePagination from rest_framework.request import Request from rest_framework.response import Response @@ -24,7 +24,7 @@ class GenericAPIView(views.APIView): serializer_class: type[BaseSerializer] | None = ... lookup_field: str = ... lookup_url_kwarg: str | None = ... - filter_backends: Sequence[type[_FilterBackendProtocol]] = ... + filter_backends: Sequence[type[FilterBackendProtocol]] = ... pagination_class: type[BasePagination] | None = ... def get_object(self) -> Any: ... def get_serializer(self, *args: Any, **kwargs: Any) -> BaseSerializer: ... diff --git a/tests/test_restframework.py b/tests/test_restframework.py index 0a9733be8..684cb45ea 100644 --- a/tests/test_restframework.py +++ b/tests/test_restframework.py @@ -1,4 +1,8 @@ +from typing import Sequence + from rest_framework.decorators import permission_classes +from rest_framework.filters import FilterBackendProtocol +from rest_framework.generics import GenericAPIView from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.test import APIClient from typing_extensions import assert_type @@ -15,3 +19,26 @@ def test_test_client_types() -> None: def test_decorator_types() -> None: permission_classes([IsAuthenticated]) permission_classes([IsAuthenticated | IsAdminUser]) + + +def test_filter_backends_types() -> None: + """ + django-filter does not use typing, so we're testing if untyped code also works fine + with our types. + + https://github.com/carltongibson/django-filter/pull/1585 + """ + + class DjangoFilterBackend: + def filter_queryset(self, request, queryset, view): # type: ignore + filterset = self.get_filterset(request, queryset, view) # type: ignore + return filterset.qs + + class BookAPIView(GenericAPIView): + filter_backends = (DjangoFilterBackend,) + + # mypy and pyright works differently here: + # mypy: Expression is of type "tuple[type[DjangoFilterBackend]]", not "Sequence[type[FilterBackendProtocol]]" [assert-type] + # Disable this check for now in mypy. + # At least assigning to filter_backends works fine, that's our main concern here. + assert_type(BookAPIView.filter_backends, Sequence[type[FilterBackendProtocol]]) # type: ignore[assert-type]