Open lowton5 opened 1 week ago
I don't think it's possible, because ast
module does not execute py code, so it can't get Enum values from enums.
As you can see on screenshot - ast
only sees code definition, not what's inside Enum.value. I think there should be a way to:
If choosing second option - it requires to recognize enums in the code and be sure this enum is "special".
I will be glad to hear possible ways (or even code) to solve this.
from enum import Enum
class FTLFiles(Enum):
MAIN = "MAIN_FIELD"
from enum import Enum
from en import FTLFiles
class I18nContext:
def get(self, key: str | Enum, **kwargs) -> str: ...
def test(i18n: I18nContext) -> None:
i18n.get("some-key", _path=FTLFiles.MAIN)
Desc
I suppose that enums are not interpreted in keys, so they require manually entering paths, which is not very productive. It would be ideal to have a template that can be easily accessed using a class