0

enter image description here

I am using Py 3.7 and trying to use Final and final from typing_extensions, but these are not stopping reassignment or overloading or inheritance

1 Answers1

1

As stated in this response: https://stackoverflow.com/a/33316370/11096524, no type checking is performed at runtime in python. This post is regarding variable types, but I assume that the same applies to the final typing extension.

Actually, I am using typing only for clean code purposes; I never got any runtime errors due to the annotations. Only in some IDE, like PyCharm, I can just see a warning if I use a different type than the one stated by an annotation.

From the post I shared above, I assume that you can use these annotations and implement your own custom type checking, in your case to check on runtime that a final variable is not reassigned etc.

sissythem
  • 751
  • 1
  • 8
  • 25