Skip to content

Commit 4f36476

Browse files
committed
Simplify BaseSettings.__get__(), .getpriority()
1 parent 44f6ada commit 4f36476

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

scrapy/settings/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ def __init__(self, values=None, priority='project'):
9090
self.update(values, priority)
9191

9292
def __getitem__(self, opt_name):
93-
value = None
94-
if opt_name in self:
95-
value = self.attributes[opt_name].value
96-
return value
93+
if opt_name not in self:
94+
return None
95+
return self.attributes[opt_name].value
9796

9897
def __contains__(self, name):
9998
return name in self.attributes
@@ -212,10 +211,9 @@ def getpriority(self, name):
212211
:param name: the setting name
213212
:type name: string
214213
"""
215-
prio = None
216-
if name in self:
217-
prio = self.attributes[name].priority
218-
return prio
214+
if name not in self:
215+
return None
216+
return self.attributes[name].priority
219217

220218
def maxpriority(self):
221219
"""

0 commit comments

Comments
 (0)