Description
Caveat: This is a corner case
PYL-W1503 suggests constants are beyond failure. While it is expected that in all cases the implementation will find assert True
to be true
without exception, however if instead the goal is to test the assert condition itself the corner case becomes apparent. It is an Anti-pattern (W.E.T. vs D.R.Y.) to unilaterally avoid the simpler constant in favor of a condition:
simpler is better:
# Simplest logical identity proof test:
assert True
# ... is same as:
TRUTH = True
assert TRUTH
# ... is same as:
TRUTH = True
assert (TRUTH==True)
for the novice it is fine to choose a style that always enforces assert (TRUTH==True)
as does PYL-W1503. Consistency and complexity are the general trade-off even in the corner case discussed previously.
Initially this project will thus had a slightly different style here
assert <condition>
is preferred unless the assertion is of a boolean keyword (i.e.True
orFalse
) which deviates from PYL-W1503.
😮💨
Caveat: Reality over theory
To resolve this difference the consideration that one would need to actually write:
# Simplest logical identity proof test (passing style linter):
assert True # skipcq: PYL-W1503
# becomes no simpler than:
TRUTH = True
assert (TRUTH == True)
Summary
🤦🏻 So the simplest test becomes more complex anyway.