Reply content:
When
working on a project, it's often needed to create a list of the tasks for yourself or your team mates. While usually these tasks is described in a issue tracker like Youtrack
, some tasks is either too small or t Oo code-specific to describe in an issue tracker. In such a case, adding TODO comments in source code makes sense.
Specifically, when you write code, suddenly realize that your previous code has a potential small bug, but not important, the common practice is:
- Fix the bug right away, and then when you return to your current job, your train of thought is interrupted.
- Put the bug in your head, keep writing your code, and soon the bug will be forgotten.
- Make a comment in the bug, continue to write the code, and soon the bug has been forgotten by you, a long time later, when you turn to the previous code, you find there is a comment
- ......
The sensible thing to do is:
next to the bug, write a
"#todo: Computer will explode while running the program for 24+ hours"and then continue writing the code.
To prevent you from forgetting this in the future, Bug,pycharm will prompt you in 3 places:
In addition, in multi-person collaborative projects, TODO can also be used to differentiate
"Who's going to fix this bug?"。 Pycharm Official documents
Introduced as follows:
create several filters, which you'll use to show the TODO items, say, for each of the developers, and not for your Good self. For this purpose, the Filters section, click, and specify the filter names, for example, for John, for Bob, and not fo R me. Associate These filters with the patterns:
Now, under the source code, create TODO items:in the line of code, where you want to add a note, press Ctrl+slash, or Ctrl+s Hift+slash, and type TODO that matches one of the patterns, followed by some meaningful description: