When using dictionary (dict) keys in Python, there seem to be a few general approaches:
some_dict['key_name'] # string constants everywhere
some_dict[KeyConstants.key_name] # where class KeyConstants: key_name: 'key_name'
some_dict[KEY_NAME] # with from some_module import KEY_NAME # a module level constant
'key_name' has the disadvantage that you're repeating constants throughout your code. It's not DRY. Worse, if you ever go to publish an your API (in the broadest sense) you'll have consumers of your API repeating these constants everywhere, and if you ever want to change 'key_name' to 'better_key_name' it will be a breaking change.
This is the typed language, DRY approach, with constants consolidated in one place. Its only disadvantages are that it's ugly, a bit less readable, and more verbose. Pythonic principles primarily prohibit that. It lets you easily change the constant representing the key, since everyone's coding against the variable KeyConstants.key_name. It also works well with IDEs for refactoring.
Module level constants are recommended in the PEP 8 style guide. ALL_CAPS_ARE_LOUD and harder to type. This has some of the advantages of both options 1 and 2.
What are some other best practices for dict key constants? Which of the above approaches are preferred and when?