Skip to content

Commit ff3040b

Browse files
alessio-locatelliJWCook
authored andcommitted
refactor: remove redundant assignment
The code adds a name that does not improve the reader's understanding. That is usually a poor tradeoff: it adds a statement, a local variable, and a name that the reader must mentally associate with statement. Do not introduce a local variable solely to satisfy a line-length limit.
1 parent 930764b commit ff3040b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎aiohttp_client_cache/backends/mongodb.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ async def bulk_delete(self, keys: set):
7272
await self.collection.delete_many(spec)
7373

7474
async def delete(self, key: str):
75-
spec = {'_id': key}
76-
await self.collection.delete_one(spec)
75+
await self.collection.delete_one({'_id': key})
7776

7877
async def keys(self) -> AsyncIterable[str]:
7978
async for doc in self.collection.find({}, {'_id': True}):
@@ -96,8 +95,7 @@ async def values(self) -> AsyncIterable[ResponseOrKey]:
9695
yield doc['data']
9796

9897
async def write(self, key: str, item: ResponseOrKey):
99-
update = {'$set': {'data': item}}
100-
await self.collection.update_one({'_id': key}, update, upsert=True)
98+
await self.collection.update_one({'_id': key}, {'$set': {'data': item}}, upsert=True)
10199

102100

103101
class MongoDBPickleCache(MongoDBCache):

0 commit comments

Comments
 (0)