Type Hints for Globals #1091
Answered
by
srittau
dineshbvadhia
asked this question in
Q&A
-
The module this.py loads data from a function in module other.py. The data objects are loaded from a database and made global (I'm sure there is a better way to do this but hey ho). Placing a type hint inside the function or in the global statement cause the errors shown below. How are globals annotated? this.py
other.py
|
Beta Was this translation helpful? Give feedback.
Answered by
srittau
Feb 23, 2022
Replies: 1 comment 2 replies
-
You can just define X: int
def read_data():
global X
X = db_read() |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
dineshbvadhia
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can just define
X: int
in the global scope without an assignment: