Question: I have a small program which calls multiple functions from the `main()` function and in each of the functions there is a small probability, that an error occurs. In order to be compatible with the existing monitoring system, I need to make a file to `/var/tmp/error_triggered/` directory if there was at least one error or remove the file from this directory if there were no errors. One way to do this is to use variable with global scope:

```
#!/usr/bin/env python3

import os
import random
from pathlib import Path

def f1():
  global error
  for i in range(1, 5):
    if random.randint(0, 9) == 0:
      error = 1

def f2():
  global error
  for i in range(1, 5):
    if random.randint(0, 9) == 0:
      error = 1

def main():
  f1()
  f2()

if __name__ == '__main__':
  error = 0
  main()
  if error == 1:
    Path('/var/tmp/error_triggered/' + os.path.splitext(os.path.basename(__file__))[0]).touch()
  else:
    Path('/var/tmp/error_triggered/' + os.path.splitext(os.path.basename(__file__))[0]).unlink(missing_ok=True)

```

It is usually a bad practice to modify a global variable from inside functions. Is it justified here? Or is there a better approach to solve this problem?

Answer: 
The location of the classes generated from the `.proto` files is not known by Intellij out of the box.
The 'com.google.protobuf' gradle plugin registers the source directories with the generated code for Intellij to see when the `idea`' gradle plugin is applied in the build.gradle file of moduleA.

See [IntelliJ IDEA tips for com.google.protobuf gradle plugin](https://github.com/google/protobuf-gradle-plugin#intellij-idea) for protobuf gradle plugin documentation.

This setup works for me with Intellij IDEA 2021.1.

Short answer: Apply the `idea` gradle plugin to moduleA.
This is same as using proto generated code in the same module, it needs to be there first before it can be picked up by IDE.

Such dependencies cannot be resolved statically. Proto generated classes are available only after `moduleA` is *built*. You would need to build `moduleA` at least once (and refresh the IDE imports if necessary) to make its generated code reachable to `moduleB`.