This code
def reportRealDiagnostics():
ranks = 0
class Rank:
def __init__(self):
global ranks
ranks += 1
rank = Rank()
reportRealDiagnostics()
produces
NameError: global name 'ranks' is not defined
I am sure that this is all what you need to answer the question.