Ruff E712와 SQLAlchemy Boolean 조건식 처리하기
·
Language/Python
문제 상황SQLAlchemy를 사용해 상품 목록을 조회하는 조건식을 작성하던 중, Ruff에서 다음과 같은 경고가 발생했습니다.services\product-service\app\routes\products.py:94:27: E712 Avoid equality comparisons to `True`; use `if Product.is_active:` for truth checks문제가 된 코드는 다음과 같습니다.conditions.append(Product.is_active == True)Ruff의 E712 규칙은 Python 코드에서 True, False와 직접 비교하는 패턴을 피하라는 경고입니다.일반적인 Python 코드에서는 다음과 같은 비교를 권장하지 않습니다.if value == True: ..