Pycharm: How to refactor code from inside dictionaries

Viewed 1161

I have one dictionary which is in file dicts.py:

#!/usr/bin/env python3

errors = {
    'errorMessageNotSent' : 'Your message was not sent',
    'errorConnectionLost' : 'The connection to the server was lost\nTry again later.'
    'errorMessageMalformed' : 'Your message seems to have unwilling characters, Check for them and try again'
}

I use it in my code this way in the file action.py:

#!/usr/bin/env python3
from dicts import errors

def doAction():
    if error_happened_and_message_was_not_sent:
        print(errors['errorMessageNotSent'])
    else:
        print(errors['errorMessageMalformed'])

After a while I wanna do refactoring and rename errorMessageMalformed to error_MalformedMessage both in the errors dictionary in dicts.py file and in its usage in the print statement in the other file (action.py).

How can I achieve that using pycharm?

I have tried Shift + F6 but it tells me that Caret should be positioned at a symbol to be refactored.

Is this even possible?

1 Answers
Related