From a10fcc84fdf23b16cf57105021062342938584c9 Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Tue, 1 Oct 2024 10:27:24 +0200 Subject: [PATCH] Use ruff for imports and formatting (#317) --- .github/workflows/lint.yml | 22 ++-- .pre-commit-config.yaml | 12 +- Makefile | 10 +- README.md | 2 +- astrapy/collection.py | 3 +- astrapy/core/utils.py | 8 +- astrapy/cursors.py | 1 - astrapy/info.py | 6 +- astrapy/transform_payload.py | 8 +- astrapy/user_agents.py | 2 +- poetry.lock | 112 ++++-------------- pyproject.toml | 7 +- scripts/astrapy_latest_interface.py | 3 +- tests/conftest.py | 3 +- tests/core/test_async_db_dml.py | 6 +- .../integration/test_exceptions_async.py | 1 - tests/preprocess_env.py | 2 - tests/vectorize_idiomatic/vectorize_models.py | 1 - 18 files changed, 61 insertions(+), 148 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9c32d4a7..ee9e8edd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: ruff, isort, black and mypy checks +name: ruff and mypy checks on: push: @@ -27,27 +27,19 @@ jobs: - name: Ruff Linting AstraPy run: | - poetry run ruff astrapy + poetry run ruff check astrapy - name: Ruff Linting Tests run: | - poetry run ruff tests + poetry run ruff check tests - - name: Isort Linting AstraPy + - name: Ruff formatting astrapy run: | - poetry run isort --check astrapy --profile black - - - name: Isort Linting Tests - run: | - poetry run isort --check tests --profile black - - - name: Black linting astrapy - run: | - poetry run black --check astrapy + poetry run ruff format --check astrapy - - name: Black linting tests + - name: Ruff formatting tests run: | - poetry run black --check tests + poetry run ruff format --check tests - name: Run MyPy AstraPy run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4507cfc8..ec254cff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: -- repo: https://github.com/psf/black - rev: 24.2.0 # Replace with your desired version or use 'stable' - hooks: - - id: black - args: ['--quiet'] - +- repo: local + hooks: + - id: check + name: check + language: system + entry: make format-fix diff --git a/Makefile b/Makefile index 147ee7f5..e1c67b17 100644 --- a/Makefile +++ b/Makefile @@ -9,15 +9,13 @@ FMT_FLAGS ?= --check format: format-src format-tests format-tests: - poetry run ruff tests - poetry run isort tests $(FMT_FLAGS) --profile black - poetry run black tests $(FMT_FLAGS) + poetry run ruff check tests + poetry run ruff format tests $(FMT_FLAGS) poetry run mypy tests format-src: - poetry run ruff astrapy - poetry run isort astrapy $(FMT_FLAGS) --profile black - poetry run black astrapy $(FMT_FLAGS) + poetry run ruff check astrapy + poetry run ruff format astrapy $(FMT_FLAGS) poetry run mypy astrapy format-fix: format-fix-src format-fix-tests diff --git a/README.md b/README.md index 0b6d93f4..8bcb520f 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ Linter, style and typecheck should all pass for a PR: make format ``` -With `make format-fix` the style and imports are autofixed (by `black` and `isort` resp.) +With `make format-fix` the style and imports are autofixed (by `ruff`) Features must be thoroughly covered in tests (see `tests/idiomatic/*` for naming convention and module structure). diff --git a/astrapy/collection.py b/astrapy/collection.py index 5120f9e0..028120ca 100644 --- a/astrapy/collection.py +++ b/astrapy/collection.py @@ -937,7 +937,7 @@ def insert_many( with ThreadPoolExecutor(max_workers=_concurrency) as executor: def _chunk_insertor( - document_chunk: List[Dict[str, Any]] + document_chunk: List[Dict[str, Any]], ) -> Dict[str, Any]: im_payload = { "insertMany": { @@ -5397,7 +5397,6 @@ async def bulk_write( logger.info(f"finished a bulk write on '{self.name}'") return full_bw_result else: - sem = asyncio.Semaphore(_concurrency) async def _concurrent_execute_as_either( diff --git a/astrapy/core/utils.py b/astrapy/core/utils.py index dad44019..7afc1d01 100644 --- a/astrapy/core/utils.py +++ b/astrapy/core/utils.py @@ -341,7 +341,7 @@ def is_list_of_floats(vector: Iterable[Any]) -> bool: def convert_to_ejson_date_object( - date_value: Union[datetime.date, datetime.datetime] + date_value: Union[datetime.date, datetime.datetime], ) -> Dict[str, int]: return {"$date": int(time.mktime(date_value.timetuple()) * 1000)} @@ -355,7 +355,7 @@ def convert_to_ejson_objectid_object(objectid_value: ObjectId) -> Dict[str, str] def convert_ejson_date_object_to_datetime( - date_object: Dict[str, int] + date_object: Dict[str, int], ) -> datetime.datetime: return datetime.datetime.fromtimestamp(date_object["$date"] / 1000.0) @@ -365,7 +365,7 @@ def convert_ejson_uuid_object_to_uuid(uuid_object: Dict[str, str]) -> UUID: def convert_ejson_objectid_object_to_objectid( - objectid_object: Dict[str, str] + objectid_object: Dict[str, str], ) -> ObjectId: return ObjectId(objectid_object["$objectId"]) @@ -402,7 +402,7 @@ def _normalize_payload_value(path: List[str], value: Any) -> Any: def normalize_for_api( - payload: Union[Dict[str, Any], None] + payload: Union[Dict[str, Any], None], ) -> Union[Dict[str, Any], None]: """ Normalize a payload for API calls. diff --git a/astrapy/cursors.py b/astrapy/cursors.py index fab0b314..ce355cdf 100644 --- a/astrapy/cursors.py +++ b/astrapy/cursors.py @@ -73,7 +73,6 @@ def _maybe_valid_list_index(key_block: str) -> Optional[int]: def _create_document_key_extractor( key: str, ) -> Callable[[Dict[str, Any]], Iterable[Any]]: - key_blocks0: List[IndexPairType] = [ (kb_str, _maybe_valid_list_index(kb_str)) for kb_str in key.split(".") ] diff --git a/astrapy/info.py b/astrapy/info.py index 7b9222b6..9e59b3db 100644 --- a/astrapy/info.py +++ b/astrapy/info.py @@ -152,7 +152,7 @@ def as_dict(self) -> Dict[str, Any]: @staticmethod def from_dict( - raw_dict: Optional[Dict[str, Any]] + raw_dict: Optional[Dict[str, Any]], ) -> Optional[CollectionDefaultIDOptions]: """ Create an instance of CollectionDefaultIDOptions from a dictionary @@ -201,7 +201,7 @@ def as_dict(self) -> Dict[str, Any]: @staticmethod def from_dict( - raw_dict: Optional[Dict[str, Any]] + raw_dict: Optional[Dict[str, Any]], ) -> Optional[CollectionVectorServiceOptions]: """ Create an instance of CollectionVectorServiceOptions from a dictionary @@ -252,7 +252,7 @@ def as_dict(self) -> Dict[str, Any]: @staticmethod def from_dict( - raw_dict: Optional[Dict[str, Any]] + raw_dict: Optional[Dict[str, Any]], ) -> Optional[CollectionVectorOptions]: """ Create an instance of CollectionVectorOptions from a dictionary diff --git a/astrapy/transform_payload.py b/astrapy/transform_payload.py index 9c2f78a1..fef937d3 100644 --- a/astrapy/transform_payload.py +++ b/astrapy/transform_payload.py @@ -46,7 +46,7 @@ def is_list_of_floats(vector: Iterable[Any]) -> bool: def convert_to_ejson_date_object( - date_value: Union[datetime.date, datetime.datetime] + date_value: Union[datetime.date, datetime.datetime], ) -> Dict[str, int]: return {"$date": int(time.mktime(date_value.timetuple()) * 1000)} @@ -60,7 +60,7 @@ def convert_to_ejson_objectid_object(objectid_value: ObjectId) -> Dict[str, str] def convert_ejson_date_object_to_datetime( - date_object: Dict[str, int] + date_object: Dict[str, int], ) -> datetime.datetime: return datetime.datetime.fromtimestamp(date_object["$date"] / 1000.0) @@ -70,7 +70,7 @@ def convert_ejson_uuid_object_to_uuid(uuid_object: Dict[str, str]) -> UUID: def convert_ejson_objectid_object_to_objectid( - objectid_object: Dict[str, str] + objectid_object: Dict[str, str], ) -> ObjectId: return ObjectId(objectid_object["$objectId"]) @@ -105,7 +105,7 @@ def normalize_payload_value(path: List[str], value: Any) -> Any: def normalize_for_api( - payload: Union[Dict[str, Any], None] + payload: Union[Dict[str, Any], None], ) -> Union[Dict[str, Any], None]: """ Normalize a payload for API calls. diff --git a/astrapy/user_agents.py b/astrapy/user_agents.py index b17aee60..fc2982f0 100644 --- a/astrapy/user_agents.py +++ b/astrapy/user_agents.py @@ -50,7 +50,7 @@ def compose_user_agent_string( def compose_full_user_agent( - callers: List[Tuple[Optional[str], Optional[str]]] + callers: List[Tuple[Optional[str], Optional[str]]], ) -> Optional[str]: user_agent_strings = [ ua_string diff --git a/poetry.lock b/poetry.lock index ce8a12cc..28beb841 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.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 = "anyio" @@ -22,52 +22,6 @@ doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphin test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] trio = ["trio (>=0.23)"] -[[package]] -name = "black" -version = "24.3.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"}, - {file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"}, - {file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"}, - {file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"}, - {file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"}, - {file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"}, - {file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"}, - {file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"}, - {file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"}, - {file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"}, - {file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"}, - {file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"}, - {file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"}, - {file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"}, - {file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"}, - {file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"}, - {file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"}, - {file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"}, - {file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"}, - {file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"}, - {file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"}, - {file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "cassandra-driver" version = "3.29.2" @@ -625,20 +579,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "markupsafe" version = "2.1.5" @@ -825,17 +765,6 @@ files = [ {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - [[package]] name = "platformdirs" version = "4.3.3" @@ -1179,28 +1108,29 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.2.2" +version = "0.6.8" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0a9efb032855ffb3c21f6405751d5e147b0c6b631e3ca3f6b20f917572b97eb6"}, - {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:d450b7fbff85913f866a5384d8912710936e2b96da74541c82c1b458472ddb39"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ecd46e3106850a5c26aee114e562c329f9a1fbe9e4821b008c4404f64ff9ce73"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e22676a5b875bd72acd3d11d5fa9075d3a5f53b877fe7b4793e4673499318ba"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1695700d1e25a99d28f7a1636d85bafcc5030bba9d0578c0781ba1790dbcf51c"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b0c232af3d0bd8f521806223723456ffebf8e323bd1e4e82b0befb20ba18388e"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f63d96494eeec2fc70d909393bcd76c69f35334cdbd9e20d089fb3f0640216ca"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6a61ea0ff048e06de273b2e45bd72629f470f5da8f71daf09fe481278b175001"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e1439c8f407e4f356470e54cdecdca1bd5439a0673792dbe34a2b0a551a2fe3"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:940de32dc8853eba0f67f7198b3e79bc6ba95c2edbfdfac2144c8235114d6726"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c126da55c38dd917621552ab430213bdb3273bb10ddb67bc4b761989210eb6e"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3b65494f7e4bed2e74110dac1f0d17dc8e1f42faaa784e7c58a98e335ec83d7e"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1ec49be4fe6ddac0503833f3ed8930528e26d1e60ad35c2446da372d16651ce9"}, - {file = "ruff-0.2.2-py3-none-win32.whl", hash = "sha256:d920499b576f6c68295bc04e7b17b6544d9d05f196bb3aac4358792ef6f34325"}, - {file = "ruff-0.2.2-py3-none-win_amd64.whl", hash = "sha256:cc9a91ae137d687f43a44c900e5d95e9617cb37d4c989e462980ba27039d239d"}, - {file = "ruff-0.2.2-py3-none-win_arm64.whl", hash = "sha256:c9d15fc41e6054bfc7200478720570078f0b41c9ae4f010bcc16bd6f4d1aacdd"}, - {file = "ruff-0.2.2.tar.gz", hash = "sha256:e62ed7f36b3068a30ba39193a14274cd706bc486fad521276458022f7bccb31d"}, + {file = "ruff-0.6.8-py3-none-linux_armv6l.whl", hash = "sha256:77944bca110ff0a43b768f05a529fecd0706aac7bcce36d7f1eeb4cbfca5f0f2"}, + {file = "ruff-0.6.8-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:27b87e1801e786cd6ede4ada3faa5e254ce774de835e6723fd94551464c56b8c"}, + {file = "ruff-0.6.8-py3-none-macosx_11_0_arm64.whl", hash = "sha256:cd48f945da2a6334f1793d7f701725a76ba93bf3d73c36f6b21fb04d5338dcf5"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:677e03c00f37c66cea033274295a983c7c546edea5043d0c798833adf4cf4c6f"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9f1476236b3eacfacfc0f66aa9e6cd39f2a624cb73ea99189556015f27c0bdeb"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6f5a2f17c7d32991169195d52a04c95b256378bbf0de8cb98478351eb70d526f"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5fd0d4b7b1457c49e435ee1e437900ced9b35cb8dc5178921dfb7d98d65a08d0"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f8034b19b993e9601f2ddf2c517451e17a6ab5cdb1c13fdff50c1442a7171d87"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6cfb227b932ba8ef6e56c9f875d987973cd5e35bc5d05f5abf045af78ad8e098"}, + {file = "ruff-0.6.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ef0411eccfc3909269fed47c61ffebdcb84a04504bafa6b6df9b85c27e813b0"}, + {file = "ruff-0.6.8-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:007dee844738c3d2e6c24ab5bc7d43c99ba3e1943bd2d95d598582e9c1b27750"}, + {file = "ruff-0.6.8-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ce60058d3cdd8490e5e5471ef086b3f1e90ab872b548814e35930e21d848c9ce"}, + {file = "ruff-0.6.8-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1085c455d1b3fdb8021ad534379c60353b81ba079712bce7a900e834859182fa"}, + {file = "ruff-0.6.8-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:70edf6a93b19481affd287d696d9e311388d808671bc209fb8907b46a8c3af44"}, + {file = "ruff-0.6.8-py3-none-win32.whl", hash = "sha256:792213f7be25316f9b46b854df80a77e0da87ec66691e8f012f887b4a671ab5a"}, + {file = "ruff-0.6.8-py3-none-win_amd64.whl", hash = "sha256:ec0517dc0f37cad14a5319ba7bba6e7e339d03fbf967a6d69b0907d61be7a263"}, + {file = "ruff-0.6.8-py3-none-win_arm64.whl", hash = "sha256:8d3bb2e3fbb9875172119021a13eed38849e762499e3cfde9588e4b4d70968dc"}, + {file = "ruff-0.6.8.tar.gz", hash = "sha256:a5bf44b1aa0adaf6d9d20f86162b34f7c593bfedabc51239953e446aefc8ce18"}, ] [[package]] @@ -1449,4 +1379,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.8.0" -content-hash = "464b343515c7a7c6124025a4bf206ff43839d474abf655e0e36a13e8b3ef5ed8" +content-hash = "d0d2f63979d3bd7f470305617e8d5e9912c04dd2f5673fcf1470c7d439699b12" diff --git a/pyproject.toml b/pyproject.toml index f9902821..1003a8cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,6 @@ pymongo = ">=3" httpx = { version=">=0.25.2,<1", extras=["http2"] } [tool.poetry.group.dev.dependencies] -black = "~24.3.0" faker = "~23.1.0" mypy = "~1.9.0" pre-commit = "~3.5.0" @@ -47,14 +46,16 @@ pytest = "~8.0.0" python-dotenv = "~1.0.1" pytest-httpserver = "~1.0.8" testcontainers = "~3.7.1" -ruff = "~0.2.1" +ruff = "^0.6.8" types-toml = "^0.10.8.7" -isort = "^5.13.2" [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F", "FA", "I"] + [tool.mypy] disallow_any_generics = true disallow_incomplete_defs = true diff --git a/scripts/astrapy_latest_interface.py b/scripts/astrapy_latest_interface.py index 136d402e..2aecc6be 100644 --- a/scripts/astrapy_latest_interface.py +++ b/scripts/astrapy_latest_interface.py @@ -1,10 +1,9 @@ import os import sys -import astrapy - from dotenv import load_dotenv +import astrapy sys.path.append("../") diff --git a/tests/conftest.py b/tests/conftest.py index e2bf1312..a9edfaf7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -84,7 +84,7 @@ def env_region_from_endpoint(api_endpoint: str) -> Tuple[str, str]: def async_fail_if_not_removed( - method: Callable[..., Awaitable[Any]] + method: Callable[..., Awaitable[Any]], ) -> Callable[..., Awaitable[Any]]: """ Decorate a test async method to track removal of deprecated code. @@ -143,7 +143,6 @@ def test_inner(*args: Any, **kwargs: Any) -> Any: def clean_nulls_from_dict(in_dict: Dict[str, Any]) -> dict[str, Any]: - def _cleand(_in: Any) -> Any: if isinstance(_in, list): return [_cleand(itm) for itm in _in] diff --git a/tests/core/test_async_db_dml.py b/tests/core/test_async_db_dml.py index 83148909..cf75d895 100644 --- a/tests/core/test_async_db_dml.py +++ b/tests/core/test_async_db_dml.py @@ -387,9 +387,9 @@ async def test_chunked_insert_many( for doc_idx, _id in enumerate(_ids0) ] - responses0: List[Union[Dict[str, Any], Exception]] = ( - await async_writable_v_collection.chunked_insert_many(documents0, chunk_size=3) - ) + responses0: List[ + Union[Dict[str, Any], Exception] + ] = await async_writable_v_collection.chunked_insert_many(documents0, chunk_size=3) assert responses0 is not None inserted_ids0 = [ ins_id diff --git a/tests/idiomatic/integration/test_exceptions_async.py b/tests/idiomatic/integration/test_exceptions_async.py index 7eb851b4..7c8cf2a3 100644 --- a/tests/idiomatic/integration/test_exceptions_async.py +++ b/tests/idiomatic/integration/test_exceptions_async.py @@ -62,7 +62,6 @@ async def test_collection_insert_many_insert_failures_async( self, async_empty_collection: AsyncCollection, ) -> None: - async def _alist(acursor: AsyncCursor) -> List[DocumentType]: return [doc async for doc in acursor] diff --git a/tests/preprocess_env.py b/tests/preprocess_env.py index 876e9945..9bacee93 100644 --- a/tests/preprocess_env.py +++ b/tests/preprocess_env.py @@ -114,7 +114,6 @@ is_docker_compose_started = False if DOCKER_COMPOSE_LOCAL_DATA_API: if not is_docker_compose_started: - """ Note: this is a trick to invoke `docker compose` as opposed to `docker-compose` while using testcontainers < 4. @@ -133,7 +132,6 @@ """ class RedefineCommandDockerCompose(DockerCompose): - def docker_compose_command(self) -> List[str]: docker_compose_cmd = ["docker", "compose"] for file in self.compose_file_names: diff --git a/tests/vectorize_idiomatic/vectorize_models.py b/tests/vectorize_idiomatic/vectorize_models.py index ab366c08..08911dcc 100644 --- a/tests/vectorize_idiomatic/vectorize_models.py +++ b/tests/vectorize_idiomatic/vectorize_models.py @@ -173,7 +173,6 @@ def live_test_models() -> Iterable[Dict[str, Any]]: - def _from_validation(pspec: EmbeddingProviderParameter) -> int: assert pspec.parameter_type == "number" if "numericRange" in pspec.validation: