mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
style: Fix linter formatting in analytics module
This commit is contained in:
parent
82187f6a71
commit
95c9863d0a
2 changed files with 9 additions and 9 deletions
|
@ -83,20 +83,20 @@ class Analytics:
|
||||||
|
|
||||||
def is_uuid_in_percentage(self, uuid_str, percent):
|
def is_uuid_in_percentage(self, uuid_str, percent):
|
||||||
"""Check if a UUID string falls within the first X percent of the UUID space.
|
"""Check if a UUID string falls within the first X percent of the UUID space.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
uuid_str: UUID string to test
|
uuid_str: UUID string to test
|
||||||
percent: Percentage threshold (0-100)
|
percent: Percentage threshold (0-100)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if UUID falls within the first X percent
|
bool: True if UUID falls within the first X percent
|
||||||
"""
|
"""
|
||||||
if not (0 <= percent <= 100):
|
if not (0 <= percent <= 100):
|
||||||
raise ValueError("Percentage must be between 0 and 100")
|
raise ValueError("Percentage must be between 0 and 100")
|
||||||
|
|
||||||
if not uuid_str:
|
if not uuid_str:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Convert percentage to hex threshold (1% = "03", 10% = "1a", etc)
|
# Convert percentage to hex threshold (1% = "03", 10% = "1a", etc)
|
||||||
threshold = format(int(256 * percent / 100), "02x")
|
threshold = format(int(256 * percent / 100), "02x")
|
||||||
return uuid_str < threshold
|
return uuid_str < threshold
|
||||||
|
|
|
@ -109,29 +109,29 @@ def test_need_to_ask(temp_data_dir):
|
||||||
|
|
||||||
def test_is_uuid_in_percentage():
|
def test_is_uuid_in_percentage():
|
||||||
analytics = Analytics()
|
analytics = Analytics()
|
||||||
|
|
||||||
# Test basic percentage thresholds
|
# Test basic percentage thresholds
|
||||||
assert analytics.is_uuid_in_percentage("00", 1) is True
|
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("02", 1) is True
|
||||||
assert analytics.is_uuid_in_percentage("03", 1) is False
|
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("ff", 1) is False
|
||||||
|
|
||||||
assert analytics.is_uuid_in_percentage("00", 10) is True
|
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("19", 10) is True
|
||||||
assert analytics.is_uuid_in_percentage("1a", 10) is False
|
assert analytics.is_uuid_in_percentage("1a", 10) is False
|
||||||
assert analytics.is_uuid_in_percentage("ff", 10) is False
|
assert analytics.is_uuid_in_percentage("ff", 10) is False
|
||||||
|
|
||||||
# Test edge cases
|
# Test edge cases
|
||||||
assert analytics.is_uuid_in_percentage("00", 0) is False
|
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("00", 100) is True
|
||||||
assert analytics.is_uuid_in_percentage("ff", 100) is True
|
assert analytics.is_uuid_in_percentage("ff", 100) is True
|
||||||
|
|
||||||
# Test invalid inputs
|
# Test invalid inputs
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
analytics.is_uuid_in_percentage("00", -1)
|
analytics.is_uuid_in_percentage("00", -1)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
analytics.is_uuid_in_percentage("00", 101)
|
analytics.is_uuid_in_percentage("00", 101)
|
||||||
|
|
||||||
# Test empty/None UUID
|
# Test empty/None UUID
|
||||||
assert analytics.is_uuid_in_percentage("", 50) is False
|
assert analytics.is_uuid_in_percentage("", 50) is False
|
||||||
assert analytics.is_uuid_in_percentage(None, 50) is False
|
assert analytics.is_uuid_in_percentage(None, 50) is False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue