Skip to content

Commit 639bc2d

Browse files
MAINT: Apply ruff rule RUF019
RUF019 Unnecessary key check before dictionary access
1 parent 3aaa2af commit 639bc2d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

numpy/f2py/capi_maps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def routsign2map(rout):
627627
ln = k
628628
break
629629
lcb_map[ln] = un[1]
630-
elif 'externals' in rout and rout['externals']:
630+
elif rout.get('externals'):
631631
errmess('routsign2map: Confused: function %s has externals %s but no "use" statement.\n' % (
632632
ret['name'], repr(rout['externals'])))
633633
ret['callprotoargument'] = getcallprotoargument(rout, lcb_map) or ''

numpy/f2py/crackfortran.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ def postcrack(block, args=None, tab=''):
20792079
block = analyzecommon(block)
20802080
block['vars'] = analyzevars(block)
20812081
block['sortvars'] = sortvarnames(block['vars'])
2082-
if 'args' in block and block['args']:
2082+
if block.get('args'):
20832083
args = block['args']
20842084
block['body'] = analyzebody(block, args, tab=tab)
20852085

@@ -2095,7 +2095,7 @@ def postcrack(block, args=None, tab=''):
20952095
if 'name' in block:
20962096
name = block['name']
20972097
# and not userisdefined: # Build a __user__ module
2098-
if 'externals' in block and block['externals']:
2098+
if block.get('externals'):
20992099
interfaced = []
21002100
if 'interfaced' in block:
21012101
interfaced = block['interfaced']

numpy/f2py/use_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def buildusevars(m, r):
5555
r['map'][k], k, revmap[r['map'][k]]))
5656
else:
5757
revmap[r['map'][k]] = k
58-
if 'only' in r and r['only']:
58+
if r.get('only'):
5959
for v in r['map'].keys():
6060
if r['map'][v] in m['vars']:
6161

0 commit comments

Comments
 (0)