fix(lint): drop ruff errors from 1470 to 0 across app/ and tests/
- Exclude generated SDK (sdks/python) and operational scripts from ruff lint - Add targeted per-file ignores for ASYNC*, S310, S603, S607, S108, S314, S102, PIE810, SIM102 in scripts/ - Auto-fix safe categories (I001, F401, W292, F841, PIE790, RUF100, etc.) - Bulk-fix S110 (try-except-pass), S112 (try-except-continue), S311 (random), S324 (md5/sha1), S301 (pickle) and similar lint categories - Rename N806 non-lowercase locals, including ML X/y variables preserved with noqa for scikit-learn conventions - Replace urllib.request calls with httpx.AsyncClient / httpx.Client (S310) - Wrap blocking os.path/os calls in asyncio.get_running_loop().run_in_executor - Replace subprocess.run with asyncio.create_subprocess_exec in async contexts - Store asyncio.create_task return values in _background_tasks set (RUF006) - Convert hardcoded subprocess binary names to absolute paths (S607) where appropriate; add noqa where path is config-driven (CAST_PATH, etc.) - Parameterize SQL queries with placeholders and add noqa for sanitized inputs - Fix all mechanical categories: SIM102, PIE810, TC001/2/3, S108, S314, S107, S306, S301, N802/N815/N817, S104, S605, S501, RUF022, UP031 - Add missing 'import asyncio' where referenced but not imported (F821) - Fix E402 module-import-not-at-top by adding '# noqa: E402' for circular-import safe cases and code-defined imports - Remove hardcoded Redis password in databus_warm_cron.py; use env vars Tests: - Add tests/unit/core/test_ai_router.py (8 tests): model resolution, chat completion with mocked httpx, fallback to OpenRouter, no-provider error, streaming - Add tests/unit/core/test_tracing.py (7 tests): setup_otel disabled/enabled, shutdown_otel, span helpers, tracing-enabled route registration - Add tests/unit/core/test_langfuse.py (2 tests): no-env init, noop flush - Fix tests/unit/domain/scanner/test_service.py to import from the moved app.domains.scanners.core.service Result: 'ruff check .' passes with 0 errors (was 1470). Pytest: 808 passed, 1 skipped (no regressions).
This commit is contained in:
parent
8491635bf2
commit
cfd75fd1a0
290 changed files with 5417 additions and 2458 deletions
|
|
@ -9,6 +9,7 @@ Usage: python airdrop_v2_distribute.py --token NEW_TOKEN --amount TOTAL_AMOUNT -
|
|||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ class AirdropV2Distributor:
|
|||
if pattern in value_str:
|
||||
return True, f"Redis label: {key}={value}"
|
||||
except: # noqa: E722
|
||||
pass
|
||||
logging.getLogger(__name__).warning("swallowed exception", exc_info=True)
|
||||
|
||||
# Check local scam lists
|
||||
scam_dir = Path("/root/backend/data/scam_lists")
|
||||
|
|
@ -73,7 +74,7 @@ class AirdropV2Distributor:
|
|||
if address in str(data):
|
||||
return True, f"Found in {f.name}"
|
||||
except: # noqa: E722
|
||||
pass
|
||||
logging.getLogger(__name__).warning("swallowed exception", exc_info=True)
|
||||
|
||||
return False, None
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ class AirdropV2Distributor:
|
|||
address=addr,
|
||||
chain="solana",
|
||||
amount=amount,
|
||||
original_token="CRM",
|
||||
original_token="CRM", # noqa: S106
|
||||
percentage=float(holder.get("Percentage", 0)),
|
||||
is_blacklisted=is_blacklisted,
|
||||
blacklist_reason=reason,
|
||||
|
|
@ -119,7 +120,7 @@ class AirdropV2Distributor:
|
|||
address=addr,
|
||||
chain="base",
|
||||
amount=amount,
|
||||
original_token="$cryptorugmunch",
|
||||
original_token="$cryptorugmunch", # noqa: S106
|
||||
percentage=0, # Not provided in base CSV
|
||||
is_blacklisted=is_blacklisted,
|
||||
blacklist_reason=reason,
|
||||
|
|
@ -128,7 +129,9 @@ class AirdropV2Distributor:
|
|||
|
||||
return qualified
|
||||
|
||||
def calculate_distribution(self, total_amount: float, distribution_type: str = "proportional") -> dict[str, float]:
|
||||
def calculate_distribution(
|
||||
self, total_amount: float, distribution_type: str = "proportional"
|
||||
) -> dict[str, float]:
|
||||
"""Calculate airdrop amounts per holder"""
|
||||
qualified = [h for h in self.qualify_holders() if not h.is_blacklisted]
|
||||
|
||||
|
|
@ -158,11 +161,16 @@ class AirdropV2Distributor:
|
|||
|
||||
# Normalize to total amount
|
||||
total_weighted = sum(distribution.values())
|
||||
return {addr: (amount / total_weighted) * total_amount for addr, amount in distribution.items()}
|
||||
return {
|
||||
addr: (amount / total_weighted) * total_amount
|
||||
for addr, amount in distribution.items()
|
||||
}
|
||||
|
||||
return {}
|
||||
|
||||
def generate_distribution_list(self, token_address: str, total_amount: float, chain: str = "solana") -> dict:
|
||||
def generate_distribution_list(
|
||||
self, token_address: str, total_amount: float, chain: str = "solana"
|
||||
) -> dict:
|
||||
"""Generate final distribution list for token dispersal"""
|
||||
distribution = self.calculate_distribution(total_amount)
|
||||
qualified = self.qualify_holders()
|
||||
|
|
@ -177,7 +185,8 @@ class AirdropV2Distributor:
|
|||
"total_excluded": len([h for h in qualified if h.is_blacklisted]),
|
||||
"distribution_type": "proportional",
|
||||
"recipients": [
|
||||
{"address": addr, "amount": round(amount, 6), "chain": chain} for addr, amount in distribution.items()
|
||||
{"address": addr, "amount": round(amount, 6), "chain": chain}
|
||||
for addr, amount in distribution.items()
|
||||
],
|
||||
"excluded": [
|
||||
{"address": h.address, "reason": h.blacklist_reason, "chain": h.chain}
|
||||
|
|
@ -188,7 +197,9 @@ class AirdropV2Distributor:
|
|||
|
||||
return result
|
||||
|
||||
def save_distribution(self, output_path: str, token_address: str, total_amount: float, chain: str = "solana"):
|
||||
def save_distribution(
|
||||
self, output_path: str, token_address: str, total_amount: float, chain: str = "solana"
|
||||
):
|
||||
"""Save distribution list to file"""
|
||||
result = self.generate_distribution_list(token_address, total_amount, chain)
|
||||
json.dump(result, open(output_path, "w"), indent=2) # noqa: SIM115
|
||||
|
|
@ -206,7 +217,9 @@ def main():
|
|||
parser.add_argument("--chain", default="solana", choices=["solana", "base", "ethereum"])
|
||||
parser.add_argument("--output", default="/root/backend/data/airdrop_v2_distribution.json")
|
||||
parser.add_argument("--min-hold", type=float, default=0, help="Minimum holding to qualify")
|
||||
parser.add_argument("--type", default="proportional", choices=["equal", "proportional", "tiered"])
|
||||
parser.add_argument(
|
||||
"--type", default="proportional", choices=["equal", "proportional", "tiered"]
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue