I am using typing.Final to type global variables in some of my modules. Here is a trivial example:
fromtypingimportFinaltest: Final="ABC"test. #<Cursor here
When I try to autocomplete after test. I get no results. If I remove the Final type hint then it works.
I have tried Final[str] as well, but it does not help.
This is only a global variable issue. This works:
fromtypingimportFinalclassTest:
def__init__(self) ->None:
self.test: Final="ABC"Test().test. #<Cursor here
My example here was using str for simplicity, but I have been wanting to use this pattern for a module "singleton" class.
I am using
typing.Finalto type global variables in some of my modules. Here is a trivial example:When I try to autocomplete after
test.I get no results. If I remove theFinaltype hint then it works.I have tried
Final[str]as well, but it does not help.This is only a global variable issue. This works:
My example here was using
strfor simplicity, but I have been wanting to use this pattern for a module "singleton" class.