Skip to content

Commit 33b5afa

Browse files
Avasamjaraco
authored andcommitted
Use actual boolean parameters and variables
1 parent 8980c8c commit 33b5afa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+302
-268
lines changed

distutils/_msvccompiler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class MSVCCompiler(CCompiler):
218218
static_lib_format = shared_lib_format = '%s%s'
219219
exe_extension = '.exe'
220220

221-
def __init__(self, verbose=0, dry_run=0, force=0):
221+
def __init__(self, verbose=False, dry_run=False, force=False):
222222
super().__init__(verbose, dry_run, force)
223223
# target platform (.plat_name is consistent with 'bdist')
224224
self.plat_name = None
@@ -334,7 +334,7 @@ def compile( # noqa: C901
334334
output_dir=None,
335335
macros=None,
336336
include_dirs=None,
337-
debug=0,
337+
debug=False,
338338
extra_preargs=None,
339339
extra_postargs=None,
340340
depends=None,
@@ -423,7 +423,7 @@ def compile( # noqa: C901
423423
return objects
424424

425425
def create_static_lib(
426-
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
426+
self, objects, output_libname, output_dir=None, debug=False, target_lang=None
427427
):
428428
if not self.initialized:
429429
self.initialize()
@@ -452,7 +452,7 @@ def link(
452452
library_dirs=None,
453453
runtime_library_dirs=None,
454454
export_symbols=None,
455-
debug=0,
455+
debug=False,
456456
extra_preargs=None,
457457
extra_postargs=None,
458458
build_temp=None,
@@ -551,7 +551,7 @@ def runtime_library_dir_option(self, dir):
551551
def library_option(self, lib):
552552
return self.library_filename(lib)
553553

554-
def find_library_file(self, dirs, lib, debug=0):
554+
def find_library_file(self, dirs, lib, debug=False):
555555
# Prefer a debugging library if found (and requested), but deal
556556
# with it if we don't have one.
557557
if debug:

distutils/archive_util.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ def _get_uid(name):
5656

5757

5858
def make_tarball(
59-
base_name, base_dir, compress="gzip", verbose=0, dry_run=0, owner=None, group=None
59+
base_name,
60+
base_dir,
61+
compress="gzip",
62+
verbose=False,
63+
dry_run=False,
64+
owner=None,
65+
group=None,
6066
):
6167
"""Create a (possibly compressed) tar file from all the files under
6268
'base_dir'.
@@ -134,7 +140,7 @@ def _set_uid_gid(tarinfo):
134140
return archive_name
135141

136142

137-
def make_zipfile(base_name, base_dir, verbose=0, dry_run=0): # noqa: C901
143+
def make_zipfile(base_name, base_dir, verbose=False, dry_run=False): # noqa: C901
138144
"""Create a zip file from all the files under 'base_dir'.
139145
140146
The output zip file will be named 'base_name' + ".zip". Uses either the
@@ -224,8 +230,8 @@ def make_archive(
224230
format,
225231
root_dir=None,
226232
base_dir=None,
227-
verbose=0,
228-
dry_run=0,
233+
verbose=False,
234+
dry_run=False,
229235
owner=None,
230236
group=None,
231237
):

distutils/bcppcompiler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class BCPPCompiler(CCompiler):
6161
static_lib_format = shared_lib_format = '%s%s'
6262
exe_extension = '.exe'
6363

64-
def __init__(self, verbose=0, dry_run=0, force=0):
64+
def __init__(self, verbose=False, dry_run=False, force=False):
6565
super().__init__(verbose, dry_run, force)
6666

6767
# These executables are assumed to all be in the path.
@@ -90,7 +90,7 @@ def compile( # noqa: C901
9090
output_dir=None,
9191
macros=None,
9292
include_dirs=None,
93-
debug=0,
93+
debug=False,
9494
extra_preargs=None,
9595
extra_postargs=None,
9696
depends=None,
@@ -161,7 +161,7 @@ def compile( # noqa: C901
161161
# compile ()
162162

163163
def create_static_lib(
164-
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
164+
self, objects, output_libname, output_dir=None, debug=False, target_lang=None
165165
):
166166
(objects, output_dir) = self._fix_object_args(objects, output_dir)
167167
output_filename = self.library_filename(output_libname, output_dir=output_dir)
@@ -189,7 +189,7 @@ def link( # noqa: C901
189189
library_dirs=None,
190190
runtime_library_dirs=None,
191191
export_symbols=None,
192-
debug=0,
192+
debug=False,
193193
extra_preargs=None,
194194
extra_postargs=None,
195195
build_temp=None,
@@ -313,7 +313,7 @@ def link( # noqa: C901
313313

314314
# -- Miscellaneous methods -----------------------------------------
315315

316-
def find_library_file(self, dirs, lib, debug=0):
316+
def find_library_file(self, dirs, lib, debug=False):
317317
# List of effective library names to try, in order of preference:
318318
# xxx_bcpp.lib is better than xxx.lib
319319
# and xxx_d.lib is better than xxx.lib if debug is set
@@ -339,7 +339,7 @@ def find_library_file(self, dirs, lib, debug=0):
339339
return None
340340

341341
# overwrite the one from CCompiler to support rc and res-files
342-
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
342+
def object_filenames(self, source_filenames, strip_dir=False, output_dir=''):
343343
if output_dir is None:
344344
output_dir = ''
345345
obj_names = []

distutils/ccompiler.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class CCompiler:
104104
library dirs specific to this compiler class
105105
"""
106106

107-
def __init__(self, verbose=0, dry_run=0, force=0):
107+
def __init__(self, verbose=False, dry_run=False, force=False):
108108
self.dry_run = dry_run
109109
self.force = force
110110
self.verbose = verbose
@@ -342,7 +342,7 @@ def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra):
342342
extra = []
343343

344344
# Get the list of expected output (object) files
345-
objects = self.object_filenames(sources, strip_dir=0, output_dir=outdir)
345+
objects = self.object_filenames(sources, strip_dir=False, output_dir=outdir)
346346
assert len(objects) == len(sources)
347347

348348
pp_opts = gen_preprocess_options(macros, incdirs)
@@ -532,7 +532,7 @@ def compile(
532532
output_dir=None,
533533
macros=None,
534534
include_dirs=None,
535-
debug=0,
535+
debug=False,
536536
extra_preargs=None,
537537
extra_postargs=None,
538538
depends=None,
@@ -609,7 +609,7 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
609609
pass
610610

611611
def create_static_lib(
612-
self, objects, output_libname, output_dir=None, debug=0, target_lang=None
612+
self, objects, output_libname, output_dir=None, debug=False, target_lang=None
613613
):
614614
"""Link a bunch of stuff together to create a static library file.
615615
The "bunch of stuff" consists of the list of object files supplied
@@ -650,7 +650,7 @@ def link(
650650
library_dirs=None,
651651
runtime_library_dirs=None,
652652
export_symbols=None,
653-
debug=0,
653+
debug=False,
654654
extra_preargs=None,
655655
extra_postargs=None,
656656
build_temp=None,
@@ -712,7 +712,7 @@ def link_shared_lib(
712712
library_dirs=None,
713713
runtime_library_dirs=None,
714714
export_symbols=None,
715-
debug=0,
715+
debug=False,
716716
extra_preargs=None,
717717
extra_postargs=None,
718718
build_temp=None,
@@ -743,7 +743,7 @@ def link_shared_object(
743743
library_dirs=None,
744744
runtime_library_dirs=None,
745745
export_symbols=None,
746-
debug=0,
746+
debug=False,
747747
extra_preargs=None,
748748
extra_postargs=None,
749749
build_temp=None,
@@ -773,7 +773,7 @@ def link_executable(
773773
libraries=None,
774774
library_dirs=None,
775775
runtime_library_dirs=None,
776-
debug=0,
776+
debug=False,
777777
extra_preargs=None,
778778
extra_postargs=None,
779779
target_lang=None,
@@ -909,7 +909,7 @@ def has_function( # noqa: C901
909909
os.remove(fn)
910910
return True
911911

912-
def find_library_file(self, dirs, lib, debug=0):
912+
def find_library_file(self, dirs, lib, debug=False):
913913
"""Search the specified list of directories for a static or shared
914914
library file 'lib' and return the full path to that file. If
915915
'debug' true, look for a debugging version (if that makes sense on
@@ -952,7 +952,7 @@ def find_library_file(self, dirs, lib, debug=0):
952952
# * exe_extension -
953953
# extension for executable files, eg. '' or '.exe'
954954

955-
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
955+
def object_filenames(self, source_filenames, strip_dir=False, output_dir=''):
956956
if output_dir is None:
957957
output_dir = ''
958958
return list(
@@ -987,13 +987,13 @@ def _make_relative(base):
987987
# If abs, chop off leading /
988988
return no_drive[os.path.isabs(no_drive) :]
989989

990-
def shared_object_filename(self, basename, strip_dir=0, output_dir=''):
990+
def shared_object_filename(self, basename, strip_dir=False, output_dir=''):
991991
assert output_dir is not None
992992
if strip_dir:
993993
basename = os.path.basename(basename)
994994
return os.path.join(output_dir, basename + self.shared_lib_extension)
995995

996-
def executable_filename(self, basename, strip_dir=0, output_dir=''):
996+
def executable_filename(self, basename, strip_dir=False, output_dir=''):
997997
assert output_dir is not None
998998
if strip_dir:
999999
basename = os.path.basename(basename)
@@ -1003,7 +1003,7 @@ def library_filename(
10031003
self,
10041004
libname,
10051005
lib_type='static',
1006-
strip_dir=0,
1006+
strip_dir=False,
10071007
output_dir='', # or 'shared'
10081008
):
10091009
assert output_dir is not None
@@ -1125,7 +1125,7 @@ def show_compilers():
11251125
pretty_printer.print_help("List of available compilers:")
11261126

11271127

1128-
def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
1128+
def new_compiler(plat=None, compiler=None, verbose=False, dry_run=False, force=False):
11291129
"""Generate an instance of some CCompiler subclass for the supplied
11301130
platform/compiler combination. 'plat' defaults to 'os.name'
11311131
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler

distutils/cmd.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ def __init__(self, dist):
8787

8888
# The 'help' flag is just used for command-line parsing, so
8989
# none of that complicated bureaucracy is needed.
90-
self.help = 0
90+
self.help = False
9191

9292
# 'finalized' records whether or not 'finalize_options()' has been
9393
# called. 'finalize_options()' itself should not pay attention to
9494
# this flag: it is the business of 'ensure_finalized()', which
9595
# always calls 'finalize_options()', to respect/update it.
96-
self.finalized = 0
96+
self.finalized = False
9797

9898
# XXX A more explicit way to customize dry_run would be better.
9999
def __getattr__(self, attr):
@@ -109,7 +109,7 @@ def __getattr__(self, attr):
109109
def ensure_finalized(self):
110110
if not self.finalized:
111111
self.finalize_options()
112-
self.finalized = 1
112+
self.finalized = True
113113

114114
# Subclasses must define:
115115
# initialize_options()
@@ -293,7 +293,7 @@ def set_undefined_options(self, src_cmd, *option_pairs):
293293
if getattr(self, dst_option) is None:
294294
setattr(self, dst_option, getattr(src_cmd_obj, src_option))
295295

296-
def get_finalized_command(self, command, create=1):
296+
def get_finalized_command(self, command, create=True):
297297
"""Wrapper around Distribution's 'get_command_obj()' method: find
298298
(create if necessary and 'create' is true) the command object for
299299
'command', call its 'ensure_finalized()' method, and return the
@@ -305,7 +305,7 @@ def get_finalized_command(self, command, create=1):
305305

306306
# XXX rename to 'get_reinitialized_command()'? (should do the
307307
# same in dist.py, if so)
308-
def reinitialize_command(self, command, reinit_subcommands=0):
308+
def reinitialize_command(self, command, reinit_subcommands=False):
309309
return self.distribution.reinitialize_command(command, reinit_subcommands)
310310

311311
def run_command(self, command):
@@ -340,7 +340,13 @@ def mkpath(self, name, mode=0o777):
340340
dir_util.mkpath(name, mode, dry_run=self.dry_run)
341341

342342
def copy_file(
343-
self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1
343+
self,
344+
infile,
345+
outfile,
346+
preserve_mode=True,
347+
preserve_times=True,
348+
link=None,
349+
level=1,
344350
):
345351
"""Copy a file respecting verbose, dry-run and force flags. (The
346352
former two default to whatever is in the Distribution object, and
@@ -359,9 +365,9 @@ def copy_tree(
359365
self,
360366
infile,
361367
outfile,
362-
preserve_mode=1,
363-
preserve_times=1,
364-
preserve_symlinks=0,
368+
preserve_mode=True,
369+
preserve_times=True,
370+
preserve_symlinks=False,
365371
level=1,
366372
):
367373
"""Copy an entire directory tree respecting verbose, dry-run,
@@ -381,7 +387,7 @@ def move_file(self, src, dst, level=1):
381387
"""Move a file respecting dry-run flag."""
382388
return file_util.move_file(src, dst, dry_run=self.dry_run)
383389

384-
def spawn(self, cmd, search_path=1, level=1):
390+
def spawn(self, cmd, search_path=True, level=1):
385391
"""Spawn an external command respecting dry-run flag."""
386392
from distutils.spawn import spawn
387393

distutils/command/bdist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def initialize_options(self):
9494
self.plat_name = None
9595
self.formats = None
9696
self.dist_dir = None
97-
self.skip_build = 0
97+
self.skip_build = False
9898
self.group = None
9999
self.owner = None
100100

@@ -150,5 +150,5 @@ def run(self):
150150
# If we're going to need to run this command again, tell it to
151151
# keep its temporary files around so subsequent runs go faster.
152152
if cmd_name in commands[i + 1 :]:
153-
sub_cmd.keep_temp = 1
153+
sub_cmd.keep_temp = True
154154
self.run_command(cmd_name)

distutils/command/bdist_dumb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def initialize_options(self):
6363
self.bdist_dir = None
6464
self.plat_name = None
6565
self.format = None
66-
self.keep_temp = 0
66+
self.keep_temp = False
6767
self.dist_dir = None
6868
self.skip_build = None
69-
self.relative = 0
69+
self.relative = False
7070
self.owner = None
7171
self.group = None
7272

@@ -95,10 +95,10 @@ def run(self):
9595
if not self.skip_build:
9696
self.run_command('build')
9797

98-
install = self.reinitialize_command('install', reinit_subcommands=1)
98+
install = self.reinitialize_command('install', reinit_subcommands=True)
9999
install.root = self.bdist_dir
100100
install.skip_build = self.skip_build
101-
install.warn_dir = 0
101+
install.warn_dir = False
102102

103103
log.info("installing to %s", self.bdist_dir)
104104
self.run_command('install')

0 commit comments

Comments
 (0)