@Override
  public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) {
    final RunManager runManager = RunManager.getInstance(project);
    for (RunnerAndConfigurationSettings configuration : runManager.getAllSettings()) {
      if (configuration.getConfiguration() instanceof AbstractPythonRunConfiguration) {
        final Module configModule = ((AbstractPythonRunConfiguration<?>)configuration.getConfiguration()).getModule();
        if (configModule == module) {
          runManager.removeConfiguration(configuration);
        }
      }
    }
  }
@Override
  public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module)