Skip to content

Commit b504971

Browse files
authored
Merge pull request #191 from DimitriPapadopoulos/refurb
Apply refurb suggestions
2 parents 2fe57ea + 1713e72 commit b504971

File tree

12 files changed

+15
-20
lines changed

12 files changed

+15
-20
lines changed

distutils/_collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def bounds(self):
185185
return (sorted_keys[RangeMap.first_item], sorted_keys[RangeMap.last_item])
186186

187187
# some special values for the RangeMap
188-
undefined_value = type(str('RangeValueUndefined'), (), {})()
188+
undefined_value = type('RangeValueUndefined', (), {})()
189189

190190
class Item(int):
191191
"RangeMap Item"

distutils/_msvccompiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ def compile( # noqa: C901
413413
args = [self.cc] + compile_opts + pp_opts
414414
if add_cpp_opts:
415415
args.append('/EHsc')
416-
args.append(input_opt)
417-
args.append("/Fo" + obj)
416+
args.extend((input_opt, "/Fo" + obj))
418417
args.extend(extra_postargs)
419418

420419
try:

distutils/bcppcompiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ def link( # noqa: C901
294294
ld_args.append(libfile)
295295

296296
# some default libraries
297-
ld_args.append('import32')
298-
ld_args.append('cw32mt')
297+
ld_args.extend(('import32', 'cw32mt'))
299298

300299
# def file for export symbols
301300
ld_args.extend([',', def_file])

distutils/command/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def _expand_attrs(self, attrs):
609609
for attr in attrs:
610610
val = getattr(self, attr)
611611
if val is not None:
612-
if os.name == 'posix' or os.name == 'nt':
612+
if os.name in ('posix', 'nt'):
613613
val = os.path.expanduser(val)
614614
val = subst_vars(val, self.config_vars)
615615
setattr(self, attr, val)

distutils/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class found in 'cmdclass' is used in place of the default, which is
132132
# our Distribution (see below).
133133
klass = attrs.get('distclass')
134134
if klass:
135-
del attrs['distclass']
135+
attrs.pop('distclass')
136136
else:
137137
klass = Distribution
138138

distutils/cygwinccompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def gcc_version(self):
133133

134134
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
135135
"""Compiles the source by spawning GCC and windres if needed."""
136-
if ext == '.rc' or ext == '.res':
136+
if ext in ('.rc', '.res'):
137137
# gcc needs '.res' and '.rc' compiled to object files !!!
138138
try:
139139
self.spawn(["windres", "-i", src, "-o", obj])

distutils/dir_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def remove_tree(directory, verbose=1, dry_run=0):
227227
# remove dir from cache if it's already there
228228
abspath = os.path.abspath(cmd[1])
229229
if abspath in _path_created:
230-
del _path_created[abspath]
230+
_path_created.pop(abspath)
231231
except OSError as exc:
232232
log.warning("error removing %s: %s", directory, exc)
233233

distutils/dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def handle_display_options(self, option_order):
700700
if val and is_display_option.get(opt):
701701
opt = translate_longopt(opt)
702702
value = getattr(self.metadata, "get_" + opt)()
703-
if opt in ['keywords', 'platforms']:
703+
if opt in ('keywords', 'platforms'):
704704
print(','.join(value))
705705
elif opt in ('classifiers', 'provides', 'requires', 'obsoletes'):
706706
print('\n'.join(value))

distutils/msvc9compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def initialize(self, plat_name=None): # noqa: C901
391391
# to cross compile, you use 'x86_amd64'.
392392
# On AMD64, 'vcvars32.bat amd64' is a native build env; to cross
393393
# compile use 'x86' (ie, it runs the x86 compiler directly)
394-
if plat_name == get_platform() or plat_name == 'win32':
394+
if plat_name in (get_platform(), 'win32'):
395395
# native build or cross-compile to win32
396396
plat_spec = PLAT_TO_VCVARS[plat_name]
397397
else:

distutils/tests/test_archive_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def _breaks(*args, **kw):
289289
pass
290290
assert os.getcwd() == current_dir
291291
finally:
292-
del ARCHIVE_FORMATS['xxx']
292+
ARCHIVE_FORMATS.pop('xxx')
293293

294294
def test_make_archive_tar(self):
295295
base_dir = self._create_files()

0 commit comments

Comments
 (0)