-
|
Hi! I like to keep all my module-level constants declared at the top of a file so it's easy to see the overall structure. However, Pyright (in strict mode) reports a warning when I assign a value to an ALL_CAPS variable that was only declared but not defined. Example: # pyright: strict
A = 1.301030
B: float # only a declaration, not a definition
def calculate(x: float) -> float:
return x
def initialize() -> None:
global B
B = calculate(A)
initialize()Pyright reports:
My questions are:
Thank you very much!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Yes, this is working as expected. As far as I can remember, this behavior hasn't changed. The technique you're using is fine for variables but not for constants. An all-caps symbol is assumed to be a constant. The recommended way is to use lowercase names for variables. |
Beta Was this translation helpful? Give feedback.
Yes, this is working as expected. As far as I can remember, this behavior hasn't changed.
The technique you're using is fine for variables but not for constants. An all-caps symbol is assumed to be a constant. The recommended way is to use lowercase names for variables.