تخطَّ إلى المحتوى

Boolean prefix (ARCH2007)

هذا المحتوى غير متوفر بلغتك بعد.

Key python.naming.boolean-prefix · Severity info · Category naming

Boolean-typed members and accessors should carry an interrogative prefix such as is, has, can, or should. Without one, conditionals read poorly and intent becomes unclear.

class Account:
def __init__(self):
self.active = True # boolean but no interrogative prefix
self.admin = False
class Account:
def __init__(self):
self.is_active = True
self.is_admin = False

Add an is/has/can/should prefix to boolean members (e.g. active → is_active).