Open
Description
Checklist
- I have searched the Sourcery documentation for the issue, and found nothing
- I have checked there are no open bugs referencing the same bug or problem
Description
Related to #339 (comment).
Code snippet that reproduces issue
1 - Case reported in #339
Input:
def __init__(self, toUserName, fromUserName, mediaId):
self.__dict = {}
self.__dict['ToUserName'] = toUserName
self.__dict['FromUserName'] = fromUserName
self.__dict["CreateTime"] = int(time.time())
self.__dict["MediaId"] = mediaId
Expected refactored code:
def __init__(self, toUserName, fromUserName, mediaId):
self.__dict = {
'ToUserName': toUserName,
'FromUserName': fromUserName,
"CreateTime": int(time.time()),
"MediaId": mediaId
}
Actual refactored code:
def __init__(self, toUserName, fromUserName, mediaId):
self.__dict = {
'ToUserName': toUserName,
'FromUserName': fromUserName,
"CreateTime": int(time.time()),
}
self.__dict["MediaId"] = mediaId
2 - Simplified version
The bug can more easily be reproduced with the following snippets:
Input:
def foo(mediaId):
d = {}
d["CreateTime"] = int(time.time())
d["MediaId"] = mediaId
Expected refactored code:
def foo(mediaId):
d = {"CreateTime": int(time.time()), "MediaId": mediaId}
Actual refactored code:
def foo(mediaId):
d = {"CreateTime": int(time.time())}
d["MediaId"] = mediaId
Debug Information
Sourcery Version: 1.2.0