Skip to content

Commit

Permalink
Merge pull request #191 from DimitriPapadopoulos/refurb
Browse files Browse the repository at this point in the history
Apply refurb suggestions
  • Loading branch information
jaraco authored Feb 6, 2023
2 parents 2fe57ea + 1713e72 commit b504971
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion distutils/_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def bounds(self):
return (sorted_keys[RangeMap.first_item], sorted_keys[RangeMap.last_item])

# some special values for the RangeMap
undefined_value = type(str('RangeValueUndefined'), (), {})()
undefined_value = type('RangeValueUndefined', (), {})()

class Item(int):
"RangeMap Item"
Expand Down
3 changes: 1 addition & 2 deletions distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ def compile( # noqa: C901
args = [self.cc] + compile_opts + pp_opts
if add_cpp_opts:
args.append('/EHsc')
args.append(input_opt)
args.append("/Fo" + obj)
args.extend((input_opt, "/Fo" + obj))
args.extend(extra_postargs)

try:
Expand Down
3 changes: 1 addition & 2 deletions distutils/bcppcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ def link( # noqa: C901
ld_args.append(libfile)

# some default libraries
ld_args.append('import32')
ld_args.append('cw32mt')
ld_args.extend(('import32', 'cw32mt'))

# def file for export symbols
ld_args.extend([',', def_file])
Expand Down
2 changes: 1 addition & 1 deletion distutils/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def _expand_attrs(self, attrs):
for attr in attrs:
val = getattr(self, attr)
if val is not None:
if os.name == 'posix' or os.name == 'nt':
if os.name in ('posix', 'nt'):
val = os.path.expanduser(val)
val = subst_vars(val, self.config_vars)
setattr(self, attr, val)
Expand Down
2 changes: 1 addition & 1 deletion distutils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class found in 'cmdclass' is used in place of the default, which is
# our Distribution (see below).
klass = attrs.get('distclass')
if klass:
del attrs['distclass']
attrs.pop('distclass')
else:
klass = Distribution

Expand Down
2 changes: 1 addition & 1 deletion distutils/cygwinccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def gcc_version(self):

def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compiles the source by spawning GCC and windres if needed."""
if ext == '.rc' or ext == '.res':
if ext in ('.rc', '.res'):
# gcc needs '.res' and '.rc' compiled to object files !!!
try:
self.spawn(["windres", "-i", src, "-o", obj])
Expand Down
2 changes: 1 addition & 1 deletion distutils/dir_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def remove_tree(directory, verbose=1, dry_run=0):
# remove dir from cache if it's already there
abspath = os.path.abspath(cmd[1])
if abspath in _path_created:
del _path_created[abspath]
_path_created.pop(abspath)
except OSError as exc:
log.warning("error removing %s: %s", directory, exc)

Expand Down
2 changes: 1 addition & 1 deletion distutils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def handle_display_options(self, option_order):
if val and is_display_option.get(opt):
opt = translate_longopt(opt)
value = getattr(self.metadata, "get_" + opt)()
if opt in ['keywords', 'platforms']:
if opt in ('keywords', 'platforms'):
print(','.join(value))
elif opt in ('classifiers', 'provides', 'requires', 'obsoletes'):
print('\n'.join(value))
Expand Down
2 changes: 1 addition & 1 deletion distutils/msvc9compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def initialize(self, plat_name=None): # noqa: C901
# to cross compile, you use 'x86_amd64'.
# On AMD64, 'vcvars32.bat amd64' is a native build env; to cross
# compile use 'x86' (ie, it runs the x86 compiler directly)
if plat_name == get_platform() or plat_name == 'win32':
if plat_name in (get_platform(), 'win32'):
# native build or cross-compile to win32
plat_spec = PLAT_TO_VCVARS[plat_name]
else:
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _breaks(*args, **kw):
pass
assert os.getcwd() == current_dir
finally:
del ARCHIVE_FORMATS['xxx']
ARCHIVE_FORMATS.pop('xxx')

def test_make_archive_tar(self):
base_dir = self._create_files()
Expand Down
11 changes: 4 additions & 7 deletions distutils/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def test_check_restructuredtext_with_syntax_highlight(self):
pytest.importorskip('docutils')
# Don't fail if there is a `code` or `code-block` directive

example_rst_docs = []
example_rst_docs.append(
example_rst_docs = [
textwrap.dedent(
"""\
Here's some code:
Expand All @@ -163,9 +162,7 @@ def test_check_restructuredtext_with_syntax_highlight(self):
def foo():
pass
"""
)
)
example_rst_docs.append(
),
textwrap.dedent(
"""\
Here's some code:
Expand All @@ -175,8 +172,8 @@ def foo():
def foo():
pass
"""
)
)
),
]

for rest_with_code in example_rst_docs:
pkg_info, dist = self.create_dist(long_description=rest_with_code)
Expand Down
2 changes: 1 addition & 1 deletion distutils/text_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def readline(self): # noqa: C901

# blank line (whether we rstrip'ed or not)? skip to next line
# if appropriate
if (line == '' or line == '\n') and self.skip_blanks:
if line in ('', '\n') and self.skip_blanks:
continue

if self.join_lines:
Expand Down

0 comments on commit b504971

Please sign in to comment.