Skip to content

Commit 1e27306

Browse files
authored
Merge pull request #251 from DiffSK/ruff
Fix some issues reported by ruff
2 parents d85bda0 + 0799889 commit 1e27306

5 files changed

Lines changed: 13 additions & 15 deletions

File tree

setup_validate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# This software is licensed under the terms of the BSD license.
1212
# http://opensource.org/licenses/BSD-3-Clause
1313

14-
import sys
1514
from distutils.core import setup
1615
from validate import __version__ as VERSION
1716

src/configobj/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def __init__(self, section):
297297

298298
def interpolate(self, key, value):
299299
# short-cut
300-
if not self._cookie in value:
300+
if self._cookie not in value:
301301
return value
302302

303303
def recursive_interpolate(key, value, section, backtrail):
@@ -2237,7 +2237,7 @@ def validate_entry(entry, spec, val, missing, ret_true, ret_false):
22372237
if entry in ('__many__', '___many___'):
22382238
# reserved names
22392239
continue
2240-
if (not entry in section.scalars) or (entry in section.defaults):
2240+
if (entry not in section.scalars) or (entry in section.defaults):
22412241
# missing entries
22422242
# or entries from defaults
22432243
missing = True

src/configobj/validate.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163

164164
import re
165165
import sys
166-
from pprint import pprint
166+
from pprint import pprint # noqa: F401 (used in doctests)
167167

168168

169169
_list_arg = re.compile(r'''
@@ -264,7 +264,8 @@ def dottedQuadToNum(ip):
264264
"""
265265

266266
# import here to avoid it when ip_addr values are not used
267-
import socket, struct
267+
import socket
268+
import struct
268269

269270
try:
270271
return struct.unpack('!L',
@@ -314,7 +315,8 @@ def numToDottedQuad(num):
314315
"""
315316

316317
# import here to avoid it when ip_addr values are not used
317-
import socket, struct
318+
import socket
319+
import struct
318320

319321
# no need to intercept here, 4294967295L is fine
320322
if num > int(4294967295) or num < 0:
@@ -653,7 +655,7 @@ def _parse_check(self, check):
653655
keymatch = self._key_arg.match(arg)
654656
if keymatch:
655657
val = keymatch.group(2)
656-
if not val in ("'None'", '"None"'):
658+
if val not in ("'None'", '"None"'):
657659
# Special case a quoted None
658660
val = self._unquote(val)
659661
fun_kwargs[keymatch.group(1)] = val
@@ -740,7 +742,7 @@ def _is_num_param(names, values, to_float=False):
740742
elif isinstance(val, (int, float, str)):
741743
try:
742744
out_params.append(fun(val))
743-
except ValueError as e:
745+
except ValueError:
744746
raise VdtParamError(name, val)
745747
else:
746748
raise VdtParamError(name, val)
@@ -1301,7 +1303,7 @@ def is_option(value, *options):
13011303
"""
13021304
if not isinstance(value, str):
13031305
raise VdtTypeError(value)
1304-
if not value in options:
1306+
if value not in options:
13051307
raise VdtValueError(value)
13061308
return value
13071309

src/tests/configobj_doctests.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@
1515
# https://github.com/DiffSK/configobj
1616

1717
import sys
18-
19-
from io import StringIO
20-
21-
import sys
18+
from io import StringIO # noqa: F401 (used in doctests)
2219

2320
from configobj import *
24-
from configobj.validate import Validator
21+
from configobj.validate import Validator # noqa: F401 (used in doctests)
2522

2623

2724
def _test_validate():

src/tests/test_validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from configobj import ConfigObj
44
import pytest
5-
from configobj.validate import Validator, VdtValueTooSmallError
5+
from configobj.validate import VdtValueTooSmallError
66

77

88
class TestImporting(object):

0 commit comments

Comments
 (0)