Details
-
Type:
Story
-
Status: Done
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: Developer Infrastructure
-
Labels:
-
Story Points:0.5
-
Epic Link:
-
Sprint:Alert Production S17 - 1
-
Team:Alert Production
Description
This is the implementation ticket for RFC-205.
The suggested additional text is given below, which probably best fits as a subsection of section 10 of the python style guide:
Code must not be placed inside `if False:` or `if True:` blocks, nor left commented out. If one has debugging code or if one is undecided about which particular implementation to use, such code must be placed inside a "named" `if` statement. Such blocks may have a comment describing the conditions under which said code can be removed (e.g. completion of a ticket, a particular date). For example, for code that will likely be removed in the future, once testing is completed:
# Delete old_thing() and this "if" once we have all the unittests in place (DM-123456).
|
use_old_method = False
|
if use_old_method:
|
old_thing()
|
else:
|
new_thing()
|
Such debugging flags should usually be lifted up into the method's keyword arguments to allow users to decide which branch to run. For example:
def foo(x, debug_plots=False):
|
do_thing()
|
if debug_plots:
|
plot_thing()
|
or, using lsstDebug, which can be controlled as part of a commandline task:
import lsstDebug
|
def foo(x):
|
do_thing()
|
if lsstDebug.Info(__name__).debug_plots:
|
plot_thing()
|
Attachments
Issue Links
- relates to
-
RFC-205 Disallow "if False:" for "block comments" in python
- Implemented
Activity
Sprint | Alert Production S17 - 1 [ 355 ] | |
Team | Alert Production [ 10300 ] |
Assignee | John Parejko [ parejkoj ] |
Status | To Do [ 10001 ] | In Progress [ 3 ] |
Reviewers | Colin Slater, Jonathan Sick [ ctslater, jsick ] | |
Status | In Progress [ 3 ] | In Review [ 10004 ] |
Reviewers | Colin Slater, Jonathan Sick [ ctslater, jsick ] | Jonathan Sick [ jsick ] |
Status | In Review [ 10004 ] | Reviewed [ 10101 ] |
Resolution | Done [ 10000 ] | |
Status | Reviewed [ 10101 ] | Done [ 10002 ] |
Epic Link |
|