PyCharm 2023.3 Help

Change inspection severity

Inspection severity levels indicate how seriously the detected code problems affect your project. In PyCharm, there is a set of predefined severity levels:

Error icon Error

Syntax errors

Warning icon Warning

Code fragments that might produce bugs or require enhancement

Weak Warning icon Weak Warning

Code fragments that can be improved or optimized (redundant code, duplicated code fragments, and so on)

Server Problem icon Server Problem

Problems that come from an external build server, for example, from TeamCity

the Typo icon Grammar Error

Grammar mistakes. This severity comes from the bundled Grazie Lite plugin. For more information, refer to Grammar.

the Typo icon Typo

Spelling mistakes and typos. For more information, refer to Spellchecking.

Consideration

Code fragments that can be improved. This severity level is not marked on the error stripe and does not have a default highlighting style, but you can select one from the list of existing styles or configure your own.

No highlighting (fix available)

No code highlighting, but you can invoke fixes by pressing Alt+Enter.

For every severity, you can configure its own highlighting style in the editor.

Severity levels are designed to indicate problems, they don't have any impact on the code execution: if you change the severity for spelling mistakes from Typo to Error, this won't affect the execution of your application.

Change inspection severity in all scopes

  1. Press Ctrl+Alt+S to open the IDE settings and then select Editor | Inspections.

  2. Select the profile that you want to modify and then choose an inspection from the list. Make sure that it is enabled.

  3. From the Severity list, select a new severity level. You can also right-click the inspection and select the severity level from the context menu.

    If the necessary severity is not on the list, click Edit Severities to create a new one.

  4. From the Highlighting in editor list, select the style that you want to use to highlight code fragments in the editor.

    Select Edit Highlighting to modify the existing styles.

    Selecting severity level for an inspection
  5. Apply the changes and close the dialog.

    The modified inspection will now have the new severity level in the selected profile.

Change inspection severity in specific scopes

  1. Press Ctrl+Alt+S to open the IDE settings and then select Editor | Inspections.

  2. Select the profile that you want to modify and then choose an inspection from the list. Make sure that it is enabled.

  3. From the Scope list, select the scope for which you want to change the severity.

    PyCharm shows severities for two scopes: the selected one and Everywhere else.

    To add one more scope, click the Add button. If you want to create a new scope, select Edit Scopes Order from the list of scopes and click the Edit icon.

  4. Select the necessary severity level from the Severity list.

    If the necessary severity is not on the list, click Edit Severities to create a new one.

    Changing inspection severity by scope
  5. Additionally, from the Highlighting in editor list, select the style that you want to use to highlight code fragments in the editor.

    Select Edit Highlighting to modify the existing styles.

If you enable an inspection in multiple scopes, and files in these scopes match, the IDE will process these scopes according to their order in the list. For more information, refer to Change the order of scopes.

Configure error highlighting

  1. Press Ctrl+Alt+S to open the IDE settings and select Editor | Color Scheme | General.

    You can also configure highlighting from inspection settings: go to Editor | Inspections, click any enabled inspection, and from the Highlighting in editor list, select Edit Highlighting.

  2. From the Errors and Warnings list, select the style that you want to modify.

  3. Configure the new highlighting rules using the options on the right. To preview the changes before applying them, use the preview section at the bottom of the dialog.

    Changing error highlighting

Create a new severity level

  1. Press Ctrl+Alt+S to open the IDE settings and then select Editor | Inspections.

  2. Select the profile in which you want to create a new severity level.

  3. Click any inspection and select Edit severities from the list of severity levels.

  4. In the Severities Editor dialog, click the Add button and name the new severity level.

  5. Configure the formatting and set a priority using the Up and Down buttons — the higher you put the severity on the list, the higher its priority.

  6. Click OK when finished.

    Creating a new severity

Use scopes to manage Python version compatibility

You can use compatibility inspections to manage required Python versions for different projects that are opened in the same window.

  1. Press Ctrl+Alt+S to open the IDE settings and then select Appearance & Behavior | Scopes.

  2. Click the Add button and create a new scope for one of the projects. Then create yet another scope for another project opened in the same window.

    Creating project-specific scopes

    Click Apply to utilize newly created scopes.

  3. Switch to the Editor | Inspections settings and start typing "incompatible" in the inspection search list. Select the Python compatibility inspection.

    Use project-based scopes for Python compatibility inspections
  4. Select a newly created project-based scope from the list of scopes in the Severity settings. Check the required versions of Python for the selected scope. Click OK to save the changes.

Last modified: 12 March 2024