diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2023-02-06 12:15:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-06 12:15:32 -0500 |
| commit | b504971d65113b0fa603bf55199e2e032f041f8e (patch) | |
| tree | afbf4504ee4b74e05cc60c8ef07b703314de5180 | |
| parent | 2fe57ea40e9474964fd2bc45bfaabb7cebbdc949 (diff) | |
| parent | 1713e720352fc6797d07dd7b61e9bafaed7b8e20 (diff) | |
| download | python-setuptools-git-b504971d65113b0fa603bf55199e2e032f041f8e.tar.gz | |
Merge pull request #191 from DimitriPapadopoulos/refurb
Apply refurb suggestions
| -rw-r--r-- | distutils/_collections.py | 2 | ||||
| -rw-r--r-- | distutils/_msvccompiler.py | 3 | ||||
| -rw-r--r-- | distutils/bcppcompiler.py | 3 | ||||
| -rw-r--r-- | distutils/command/install.py | 2 | ||||
| -rw-r--r-- | distutils/core.py | 2 | ||||
| -rw-r--r-- | distutils/cygwinccompiler.py | 2 | ||||
| -rw-r--r-- | distutils/dir_util.py | 2 | ||||
| -rw-r--r-- | distutils/dist.py | 2 | ||||
| -rw-r--r-- | distutils/msvc9compiler.py | 2 | ||||
| -rw-r--r-- | distutils/tests/test_archive_util.py | 2 | ||||
| -rw-r--r-- | distutils/tests/test_check.py | 11 | ||||
| -rw-r--r-- | distutils/text_file.py | 2 |
12 files changed, 15 insertions, 20 deletions
diff --git a/distutils/_collections.py b/distutils/_collections.py index 02556614..5ad21cc7 100644 --- a/distutils/_collections.py +++ b/distutils/_collections.py @@ -185,7 +185,7 @@ class RangeMap(dict): 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" diff --git a/distutils/_msvccompiler.py b/distutils/_msvccompiler.py index 8b4023c4..ff2fb0cf 100644 --- a/distutils/_msvccompiler.py +++ b/distutils/_msvccompiler.py @@ -413,8 +413,7 @@ class MSVCCompiler(CCompiler): 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: diff --git a/distutils/bcppcompiler.py b/distutils/bcppcompiler.py index 5d6b8653..c38d57c6 100644 --- a/distutils/bcppcompiler.py +++ b/distutils/bcppcompiler.py @@ -294,8 +294,7 @@ class BCPPCompiler(CCompiler): 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]) diff --git a/distutils/command/install.py b/distutils/command/install.py index 08d2f881..a1f8209a 100644 --- a/distutils/command/install.py +++ b/distutils/command/install.py @@ -609,7 +609,7 @@ class install(Command): 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) diff --git a/distutils/core.py b/distutils/core.py index 34cafbce..05d29719 100644 --- a/distutils/core.py +++ b/distutils/core.py @@ -132,7 +132,7 @@ def setup(**attrs): # noqa: C901 # our Distribution (see below). klass = attrs.get('distclass') if klass: - del attrs['distclass'] + attrs.pop('distclass') else: klass = Distribution diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index f15b8eee..4c5c6a36 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -133,7 +133,7 @@ class CygwinCCompiler(UnixCCompiler): 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]) diff --git a/distutils/dir_util.py b/distutils/dir_util.py index 80f77649..23dc3392 100644 --- a/distutils/dir_util.py +++ b/distutils/dir_util.py @@ -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) diff --git a/distutils/dist.py b/distutils/dist.py index d7458a05..970abda0 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -700,7 +700,7 @@ Common commands: (see '--help-commands' for more) 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)) diff --git a/distutils/msvc9compiler.py b/distutils/msvc9compiler.py index a4714a55..49d83b50 100644 --- a/distutils/msvc9compiler.py +++ b/distutils/msvc9compiler.py @@ -391,7 +391,7 @@ class MSVCCompiler(CCompiler): # 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: diff --git a/distutils/tests/test_archive_util.py b/distutils/tests/test_archive_util.py index 7778c3ad..89c415d7 100644 --- a/distutils/tests/test_archive_util.py +++ b/distutils/tests/test_archive_util.py @@ -289,7 +289,7 @@ class ArchiveUtilTestCase(support.TempdirManager): 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() diff --git a/distutils/tests/test_check.py b/distutils/tests/test_check.py index 54654067..6d240b8b 100644 --- a/distutils/tests/test_check.py +++ b/distutils/tests/test_check.py @@ -152,8 +152,7 @@ class TestCheck(support.TempdirManager): 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: @@ -163,9 +162,7 @@ class TestCheck(support.TempdirManager): def foo(): pass """ - ) - ) - example_rst_docs.append( + ), textwrap.dedent( """\ Here's some code: @@ -175,8 +172,8 @@ class TestCheck(support.TempdirManager): def foo(): pass """ - ) - ) + ), + ] for rest_with_code in example_rst_docs: pkg_info, dist = self.create_dist(long_description=rest_with_code) diff --git a/distutils/text_file.py b/distutils/text_file.py index 7274d4b1..164c0ea2 100644 --- a/distutils/text_file.py +++ b/distutils/text_file.py @@ -255,7 +255,7 @@ class TextFile: # 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: |
