0

I use PyCharm and have the following file structure:

/common
  config.py
  glob.py
  variable.py
main.py

My glob.py is simple as this:

# noinspection PyUnresolvedReferences
import common.config as cfg
# noinspection PyUnresolvedReferences
import common.variable as var

My main.py can do something like this:

import common.glob as glob

print(glob.cfg.MY_CONSTANT)
print(glob.var.my_var)

The problem (or rather minor inconvenience) is that PyCharm complains about my glob.py imports not being used. That's not really true, because main.py is using them. Thus, I suppress the inspection with the comment lines # noinspection PyUnresolvedReferences.

Is it possible to effectively ignore the inspection for the whole file with a single comment? Please avoid answers about doing this through the settings, what I'm looking for is how to make better use of these # noinspection rules

George Dimitriadis
  • 1,681
  • 1
  • 18
  • 27
  • 1
    checkout this answer: https://stackoverflow.com/a/22959267/14242111 it's a little annoying but youll need to create a scope of your own and then exclude some inspections for files – Hagai Kalinhoff Jan 30 '22 at 20:39
  • Thanks, but as I noted I am looking for a solution that can be versioned in my repository, instead of a local settings change. Anyway, I'll take it that's the only way then. – George Dimitriadis Feb 17 '22 at 09:23

0 Answers0