Choose clear, meaningful names for variables, parameters, and constants that convey their purpose without requiring additional documentation or context.
Key practices:
# Instead of this:
assert prewarm_info[0] > 0 and prewarm_info[1] > 0
# Do this:
total, prewarmed, skipped = prewarm_info
assert total > 0 and prewarmed > 0
# Instead of this:
disable_kick_secondary_downloads: bool = False
# Do this:
storcon_kick_secondary_downloads: bool = True
# Instead of this:
prewarm_label = "compute_ctl_lfc_prewarm_requests_total"
# Do this:
PREWARM_LABEL = "compute_ctl_lfc_prewarm_requests_total"
# Instead of this:
def test_lfc_prewarm(neon_simple_env: NeonEnv, with_compute_ctl: bool):
"""with_compute_ctl: Test compute ctl's methods instead of querying Postgres directly"""
# Do this:
class LfcQueryMethod(Enum):
COMPUTE_CTL = "compute_ctl"
POSTGRES = "postgres"
def test_lfc_prewarm(neon_simple_env: NeonEnv, query: LfcQueryMethod):
Clear naming reduces cognitive load, minimizes the need for comments, and makes code more maintainable and easier to understand at first glance.
Enter the URL of a public GitHub repository