Python todo в коде

TODO comments

Sometimes, you need to mark parts of your code for future reference: areas of optimization and improvement, possible changes, questions to be discussed, and so on. PyCharm lets you add special types of comments that are highlighted in the editor, indexed, and listed in the TODO tool window. This way you and your teammates can keep track of issues that require attention.

TODO comments example

By default, there are two patterns recognized by PyCharm: TODO and FIXME in both lower and upper case. These patterns can be used inside line and block comments of any supported file type. You can modify the default patterns or add your own patterns if necessary.

Create a multiline TODO item

  • Indent the text in comment lines that follow the initial comment line. You can use spaces and tabs, or a mix of both for indenting multiline TODO items.

Disable multiline TODO items

TODO comments example

  1. Press Control+Alt+S to open the IDE settings and then select Editor | TODO .
  2. Clear the Treat indented text on the following lines as part of the same TODO checkbox.

View TODO items

Use tabs to change the source of TODO items you want to view: from all files in your current project, only those in the current file, based on a certain scope of files, or from files in the active changelist (if you have version control integration configured).

To jump to a TODO comment in the source code, click the corresponding TODO item in the TODO tool window. To disable this behavior, use the Navigate with Single Click button on the toolbar (in this case, you will need to double-click the TODO item to jump to the relevant comment).

Читайте также:  Java bean initialization method

The TODO tool window

Add custom patterns and filter TODO items

You can add your own patterns and filter the list to show only TODO items that match certain patterns. For example, you can choose to mark places of possible optimization in your code with the OPTIMIZE pattern and ignore all other types of TODO items when viewing them in the TODO tool window.

  1. In the Settings dialog ( Control+Alt+S ), select Editor | TODO .
  2. Use a regular expression to specify a custom pattern. For example, to add a pattern for the word OPTIMIZE in a comment, click in the Patterns section of the TODO dialog, and type the following regular expression:

The icon that you select for a pattern is displayed in the TODO tool window to better distinguish various TODO items. By enabling the Case Sensitive checkbox for a pattern, you can force the pattern to match only with the specified case.

Источник

Оцените статью