Reputation: 447
For the following code I am getting the below error:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['bucket']['name'],
E131 continuation line unaligned for hanging indent
['Records'][0]['s3']['object']['key']
I have tried a few options including the below - but it is not working:
config = {
'bucket': json.loads(
record['body']
)
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
I have also tried + \
at the end of the line but does not work also
Upvotes: 3
Views: 10066
Reputation: 447
To conform with PEP8, the below worked for this scenario:
config = {
'bucket': json.loads(record['body'])
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])
['Records'][0]['s3']['object']['key']
}
Upvotes: 4
Reputation: 8566
Try this, it should be either this format
config = {
'bucket': json.loads(record['body'])['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body'])['Records'][0]['s3']['object']['key']
}
or in this,
config = {
'bucket': json.loads(record['body']) \
['Records'][0]['s3']['bucket']['name'],
'key': json.loads(record['body']) \
['Records'][0]['s3']['object']['key']
}
For more information, please check What is PEP8's E128: continuation line under-indented for visual indent? question.
Upvotes: 2