I have read conflicting accounts on whether explicit imports were required for read only usage. On all accounts the imports are required for any mutations to globals.
Specifically I am annoyed by needing to put global ...
inside every method within a single script for such things as Enums
that are always invariant. I'd like a program-level setting to just allow read-only usage of _globals.
What are the options here?
Update I see what is happening: the Pycharm
is actually only flagging these when there is a mutation happening. It was hard to discover because often enough the first usages of the global variable were read-only : but only further down in a given method were the mutations happening. In the case shown in the screenshot it is the lastBadgeId
:
If the mutations in subsequent code in that same method are commented out then the red goes away.