From e305c4e76bfb10c59f7bb018326df1ccb4143102 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 22 Nov 2024 17:19:40 -0800 Subject: [PATCH] update lint check --- .../ensure_async_clients_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/code_coverage_tests/ensure_async_clients_test.py b/tests/code_coverage_tests/ensure_async_clients_test.py index a509e5509..a4203d881 100644 --- a/tests/code_coverage_tests/ensure_async_clients_test.py +++ b/tests/code_coverage_tests/ensure_async_clients_test.py @@ -43,6 +43,19 @@ def check_for_async_http_handler(file_path): raise ValueError( f"found violation in file {file_path} line: {node.lineno}. Please use `get_async_httpx_client` instead. {warning_msg}" ) + # Check for attribute calls like httpx.AsyncClient() + elif isinstance(node.func, ast.Attribute): + full_name = "" + current = node.func + while isinstance(current, ast.Attribute): + full_name = "." + current.attr + full_name + current = current.value + if isinstance(current, ast.Name): + full_name = current.id + full_name + if full_name.lower() in [name.lower() for name in target_names]: + raise ValueError( + f"found violation in file {file_path} line: {node.lineno}. Please use `get_async_httpx_client` instead. {warning_msg}" + ) return violations