From 0aaf83d61b9e80499d60025685c1d4b620610a13 Mon Sep 17 00:00:00 2001 From: Tommaso Barbugli Date: Thu, 25 Apr 2024 16:59:28 +0200 Subject: [PATCH] use ruff --- .github/workflows/ci.yml | 5 +- README.md | 2 +- getstream/chat/rest_client.py | 5 -- getstream/common/rest_client.py | 6 -- getstream/video/call.py | 1 - getstream/video/rest_client.py | 4 -- poetry.lock | 115 ++++++++------------------------ pyproject.toml | 5 +- tests/test_integration.py | 24 ++++--- 9 files changed, 47 insertions(+), 120 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c71dd52..5f87c3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,8 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + continue-on-error: false - name: Install poetry run: pipx install poetry - name: Set up Python ${{ matrix.python-version }} @@ -30,9 +32,6 @@ jobs: cache: 'poetry' - name: Install deps run: poetry install - - name: Black - run: poetry run black getstream/ tests/ - continue-on-error: false - name: Run tests env: STREAM_BASE_URL: ${{ vars.STREAM_BASE_URL }} diff --git a/README.md b/README.md index 7fa529d..b578292 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ poetry run pytest tests/ getstream/ Before pushing changes make sure to run the linter: ```sh -poetry run black getstream/ tests/ +poetry run ruff format getstream/ tests/ ``` ## License diff --git a/getstream/chat/rest_client.py b/getstream/chat/rest_client.py index 31920b6..3249507 100644 --- a/getstream/chat/rest_client.py +++ b/getstream/chat/rest_client.py @@ -5,7 +5,6 @@ class ChatRestClient(BaseClient): - def __init__(self, api_key: str, base_url: str, timeout: float, token: str): """ Initializes ChatClient with BaseClient instance @@ -22,7 +21,6 @@ def __init__(self, api_key: str, base_url: str, timeout: float, token: str): ) def list_block_lists(self) -> StreamResponse[ListBlockListResponse]: - return self.get("/api/v2/chat/blocklists", ListBlockListResponse) def create_block_list( @@ -524,7 +522,6 @@ def mark_unread( ) def list_channel_types(self) -> StreamResponse[ListChannelTypesResponse]: - return self.get("/api/v2/chat/channeltypes", ListChannelTypesResponse) def create_channel_type( @@ -673,7 +670,6 @@ def update_channel_type( ) def list_commands(self) -> StreamResponse[ListCommandsResponse]: - return self.get("/api/v2/chat/commands", ListCommandsResponse) def create_command( @@ -1493,7 +1489,6 @@ def update_thread_partial( ) def unread_counts(self) -> StreamResponse[WrappedUnreadCountsResponse]: - return self.get("/api/v2/chat/unread", WrappedUnreadCountsResponse) def unread_counts_batch( diff --git a/getstream/common/rest_client.py b/getstream/common/rest_client.py index a952f2c..9546332 100644 --- a/getstream/common/rest_client.py +++ b/getstream/common/rest_client.py @@ -5,7 +5,6 @@ class CommonRestClient(BaseClient): - def __init__(self, api_key: str, base_url: str, timeout: float, token: str): """ Initializes CommonClient with BaseClient instance @@ -22,7 +21,6 @@ def __init__(self, api_key: str, base_url: str, timeout: float, token: str): ) def get_app(self) -> StreamResponse[GetApplicationResponse]: - return self.get("/api/v2/app", GetApplicationResponse) def update_app( @@ -215,7 +213,6 @@ def create_import_url( return self.post("/api/v2/import_urls", CreateImportURLResponse, json=json) def list_imports(self) -> StreamResponse[ListImportsResponse]: - return self.get("/api/v2/imports", ListImportsResponse) def create_import( @@ -240,7 +237,6 @@ def get_og(self, url: str) -> StreamResponse[GetOGResponse]: return self.get("/api/v2/og", GetOGResponse, query_params=query_params) def list_permissions(self) -> StreamResponse[ListPermissionsResponse]: - return self.get("/api/v2/permissions", ListPermissionsResponse) def get_permission(self, id: str) -> StreamResponse[GetCustomPermissionResponse]: @@ -255,7 +251,6 @@ def get_permission(self, id: str) -> StreamResponse[GetCustomPermissionResponse] ) def list_push_providers(self) -> StreamResponse[ListPushProvidersResponse]: - return self.get("/api/v2/push_providers", ListPushProvidersResponse) def upsert_push_provider( @@ -298,7 +293,6 @@ def get_rate_limits( ) def list_roles(self) -> StreamResponse[ListRolesResponse]: - return self.get("/api/v2/roles", ListRolesResponse) def create_role(self, name: str) -> StreamResponse[CreateRoleResponse]: diff --git a/getstream/video/call.py b/getstream/video/call.py index 584d751..557069c 100644 --- a/getstream/video/call.py +++ b/getstream/video/call.py @@ -3,7 +3,6 @@ class Call: - def __init__( self, client, call_type: str, call_id: str = None, custom_data: Dict = None ): diff --git a/getstream/video/rest_client.py b/getstream/video/rest_client.py index 22a2aa7..e8eac3d 100644 --- a/getstream/video/rest_client.py +++ b/getstream/video/rest_client.py @@ -5,7 +5,6 @@ class VideoRestClient(BaseClient): - def __init__(self, api_key: str, base_url: str, timeout: float, token: str): """ Initializes VideoClient with BaseClient instance @@ -538,7 +537,6 @@ def query_calls( ) def list_call_types(self) -> StreamResponse[ListCallTypeResponse]: - return self.get("/api/v2/video/calltypes", ListCallTypeResponse) def create_call_type( @@ -605,11 +603,9 @@ def update_call_type( ) def get_edges(self) -> StreamResponse[GetEdgesResponse]: - return self.get("/api/v2/video/edges", GetEdgesResponse) def list_external_storage(self) -> StreamResponse[ListExternalStorageResponse]: - return self.get("/api/v2/video/external_storage", ListExternalStorageResponse) def create_external_storage( diff --git a/poetry.lock b/poetry.lock index e581db8..a06ecaf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -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.4.1" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-24.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1f7749fd0d97ff9415975a1432fac7df89bf13c3833cea079e55fa004d5f28c0"}, - {file = "black-24.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:859f3cc5d2051adadf8fd504a01e02b0fd866d7549fff54bc9202d524d2e8bd7"}, - {file = "black-24.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59271c9c29dfa97f7fda51f56c7809b3f78e72fd8d2205189bbd23022a0618b6"}, - {file = "black-24.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:5ed9c34cba223149b5a0144951a0f33d65507cf82c5449cb3c35fe4b515fea9a"}, - {file = "black-24.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9dae3ae59d6f2dc93700fd5034a3115434686e66fd6e63d4dcaa48d19880f2b0"}, - {file = "black-24.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5f8698974a81af83283eb47644f2711b5261138d6d9180c863fce673cbe04b13"}, - {file = "black-24.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f404b6e77043b23d0321fb7772522b876b6de737ad3cb97d6b156638d68ce81"}, - {file = "black-24.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:c94e52b766477bdcd010b872ba0714d5458536dc9d0734eff6583ba7266ffd89"}, - {file = "black-24.4.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:962d9e953872cdb83b97bb737ad47244ce2938054dc946685a4cad98520dab38"}, - {file = "black-24.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b1d8e3b2486b7dd522b1ab2ba1ec4907f0aa8f5e10a33c4271fb331d1d10b70c"}, - {file = "black-24.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed77e214b785148f57e43ca425b6e0850165144aa727d66ac604e56a70bb7825"}, - {file = "black-24.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:4ef4764437d7eba8386689cd06e1fb5341ee0ae2e9e22582b21178782de7ed94"}, - {file = "black-24.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:92b183f8eef5baf7b20a513abcf982ad616f544f593f6688bb2850d2982911f1"}, - {file = "black-24.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:945abd7b3572add997757c94295bb3e73c6ffaf3366b1f26cb2356a4bffd1dc3"}, - {file = "black-24.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db5154b9e5b478031371d8bc41ff37b33855fa223a6cfba456c9b73fb96f77d4"}, - {file = "black-24.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:afc84c33c1a9aaf3d73140cee776b4ddf73ff429ffe6b7c56dc1c9c10725856d"}, - {file = "black-24.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0889f4eb8b3bdf8b189e41a71cf0dbb8141a98346cd1a2695dea5995d416e940"}, - {file = "black-24.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5bb0143f175db45a55227eefd63e90849d96c266330ba31719e9667d0d5ec3b9"}, - {file = "black-24.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:713a04a78e78f28ef7e8df7a16fe075670ea164860fcef3885e4f3dffc0184b3"}, - {file = "black-24.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:171959bc879637a8cdbc53dc3fddae2a83e151937a28cf605fd175ce61e0e94a"}, - {file = "black-24.4.1-py3-none-any.whl", hash = "sha256:ecbab810604fe02c70b3a08afd39beb599f7cc9afd13e81f5336014133b4fe35"}, - {file = "black-24.4.1.tar.gz", hash = "sha256:5241612dc8cad5b6fd47432b8bd04db80e07cfbc53bb69e9ae18985063bcb8dd"}, -] - -[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 = "certifi" version = "2024.2.2" @@ -79,20 +33,6 @@ files = [ {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, ] -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - [[package]] name = "colorama" version = "0.4.6" @@ -279,33 +219,6 @@ files = [ {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, ] -[[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.2.1" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.1-py3-none-any.whl", hash = "sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1"}, - {file = "platformdirs-4.2.1.tar.gz", hash = "sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] -type = ["mypy (>=1.8)"] - [[package]] name = "pluggy" version = "1.5.0" @@ -410,6 +323,32 @@ files = [ [package.extras] cli = ["click (>=5.0)"] +[[package]] +name = "ruff" +version = "0.4.1" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.4.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:2d9ef6231e3fbdc0b8c72404a1a0c46fd0dcea84efca83beb4681c318ea6a953"}, + {file = "ruff-0.4.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9485f54a7189e6f7433e0058cf8581bee45c31a25cd69009d2a040d1bd4bfaef"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d2921ac03ce1383e360e8a95442ffb0d757a6a7ddd9a5be68561a671e0e5807e"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eec8d185fe193ad053eda3a6be23069e0c8ba8c5d20bc5ace6e3b9e37d246d3f"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:baa27d9d72a94574d250f42b7640b3bd2edc4c58ac8ac2778a8c82374bb27984"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:f1ee41580bff1a651339eb3337c20c12f4037f6110a36ae4a2d864c52e5ef954"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0926cefb57fc5fced629603fbd1a23d458b25418681d96823992ba975f050c2b"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2c6e37f2e3cd74496a74af9a4fa67b547ab3ca137688c484749189bf3a686ceb"}, + {file = "ruff-0.4.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:efd703a5975ac1998c2cc5e9494e13b28f31e66c616b0a76e206de2562e0843c"}, + {file = "ruff-0.4.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b92f03b4aa9fa23e1799b40f15f8b95cdc418782a567d6c43def65e1bbb7f1cf"}, + {file = "ruff-0.4.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1c859f294f8633889e7d77de228b203eb0e9a03071b72b5989d89a0cf98ee262"}, + {file = "ruff-0.4.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b34510141e393519a47f2d7b8216fec747ea1f2c81e85f076e9f2910588d4b64"}, + {file = "ruff-0.4.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:6e68d248ed688b9d69fd4d18737edcbb79c98b251bba5a2b031ce2470224bdf9"}, + {file = "ruff-0.4.1-py3-none-win32.whl", hash = "sha256:b90506f3d6d1f41f43f9b7b5ff845aeefabed6d2494307bc7b178360a8805252"}, + {file = "ruff-0.4.1-py3-none-win_amd64.whl", hash = "sha256:c7d391e5936af5c9e252743d767c564670dc3889aff460d35c518ee76e4b26d7"}, + {file = "ruff-0.4.1-py3-none-win_arm64.whl", hash = "sha256:a1eaf03d87e6a7cd5e661d36d8c6e874693cb9bc3049d110bc9a97b350680c43"}, + {file = "ruff-0.4.1.tar.gz", hash = "sha256:d592116cdbb65f8b1b7e2a2b48297eb865f6bdc20641879aa9d7b9c11d86db79"}, +] + [[package]] name = "six" version = "1.16.0" @@ -499,4 +438,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0.0" -content-hash = "1b14c672f226f78ffd03a471c34989fc25a60f791775cd924d7ccfaa22a5cf4a" +content-hash = "70b3a2f555bf1401b0260ebb6325bcf550146d71fb27b56e84aebd2a042e259f" diff --git a/pyproject.toml b/pyproject.toml index 9472e92..2091993 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,8 +25,11 @@ flake8 = "^6.0.0" [tool.poetry.group.dev-dependencies.dependencies] python-dotenv = "^1.0.1" -black = "^24.4.0" +ruff = "^0.4.1" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.ruff.lint] +ignore = ["F405", "F403"] diff --git a/tests/test_integration.py b/tests/test_integration.py index fc22039..1bb9b9f 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -208,20 +208,22 @@ def test_custom_recording_style_css(self, client: Stream): ) def test_custom_recording_website(self, client: Stream): - client.video.update_call_type( - CALL_TYPE_NAME, - settings=CallSettingsRequest( - recording=RecordSettingsRequest( - mode="available", - audio_only=False, - quality="1080p", - layout=LayoutSettingsRequest( - name="custom", - external_app_url="https://path/to/layout/app", + ( + client.video.update_call_type( + CALL_TYPE_NAME, + settings=CallSettingsRequest( + recording=RecordSettingsRequest( + mode="available", + audio_only=False, + quality="1080p", + layout=LayoutSettingsRequest( + name="custom", + external_app_url="https://path/to/layout/app", + ), ), ), ), - ), + ) def test_delete_call_type(self, client: Stream): try: