From 95c9863d0aa707937a9bfb5883e5cefd3ac1d042 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 20 Nov 2024 17:54:22 -0800 Subject: [PATCH] style: Fix linter formatting in analytics module --- aider/analytics.py | 8 ++++---- tests/basic/test_analytics.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aider/analytics.py b/aider/analytics.py index 02f6b1f92..737cae701 100644 --- a/aider/analytics.py +++ b/aider/analytics.py @@ -83,20 +83,20 @@ class Analytics: def is_uuid_in_percentage(self, uuid_str, percent): """Check if a UUID string falls within the first X percent of the UUID space. - + Args: uuid_str: UUID string to test percent: Percentage threshold (0-100) - + Returns: bool: True if UUID falls within the first X percent """ if not (0 <= percent <= 100): raise ValueError("Percentage must be between 0 and 100") - + if not uuid_str: return False - + # Convert percentage to hex threshold (1% = "03", 10% = "1a", etc) threshold = format(int(256 * percent / 100), "02x") return uuid_str < threshold diff --git a/tests/basic/test_analytics.py b/tests/basic/test_analytics.py index 9d7df7167..ef2ba884a 100644 --- a/tests/basic/test_analytics.py +++ b/tests/basic/test_analytics.py @@ -109,29 +109,29 @@ def test_need_to_ask(temp_data_dir): def test_is_uuid_in_percentage(): analytics = Analytics() - + # Test basic percentage thresholds assert analytics.is_uuid_in_percentage("00", 1) is True assert analytics.is_uuid_in_percentage("02", 1) is True assert analytics.is_uuid_in_percentage("03", 1) is False assert analytics.is_uuid_in_percentage("ff", 1) is False - + assert analytics.is_uuid_in_percentage("00", 10) is True assert analytics.is_uuid_in_percentage("19", 10) is True assert analytics.is_uuid_in_percentage("1a", 10) is False assert analytics.is_uuid_in_percentage("ff", 10) is False - + # Test edge cases assert analytics.is_uuid_in_percentage("00", 0) is False assert analytics.is_uuid_in_percentage("00", 100) is True assert analytics.is_uuid_in_percentage("ff", 100) is True - + # Test invalid inputs with pytest.raises(ValueError): analytics.is_uuid_in_percentage("00", -1) with pytest.raises(ValueError): analytics.is_uuid_in_percentage("00", 101) - + # Test empty/None UUID assert analytics.is_uuid_in_percentage("", 50) is False assert analytics.is_uuid_in_percentage(None, 50) is False