Skip to content

Commit d1bea1b

Browse files
Avasamabravalheri
andauthored
Use actual boolean parameters and variables (#4365)
Co-authored-by: Anderson Bravalheri <[email protected]>
1 parent b4403a1 commit d1bea1b

File tree

12 files changed

+41
-32
lines changed

12 files changed

+41
-32
lines changed

newsfragments/4365.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use actual boolean parameters and variables instead of 0-1 literals. -- by :user:`Avasam`

pkg_resources/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def __iter__(self):
731731

732732
for key in self.entry_keys[item]:
733733
if key not in seen:
734-
seen[key] = 1
734+
seen[key] = True
735735
yield self.by_key[key]
736736

737737
def add(

setuptools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def ensure_string_list(self, option):
216216
"'%s' must be a list of strings (got %r)" % (option, val)
217217
)
218218

219-
def reinitialize_command(self, command, reinit_subcommands=0, **kw):
219+
def reinitialize_command(self, command, reinit_subcommands=False, **kw):
220220
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
221221
vars(cmd).update(kw)
222222
return cmd

setuptools/command/bdist_egg.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ class bdist_egg(Command):
8585
def initialize_options(self):
8686
self.bdist_dir = None
8787
self.plat_name = None
88-
self.keep_temp = 0
88+
self.keep_temp = False
8989
self.dist_dir = None
90-
self.skip_build = 0
90+
self.skip_build = False
9191
self.egg_output = None
9292
self.exclude_source_files = None
9393

@@ -136,7 +136,7 @@ def do_install_data(self):
136136

137137
try:
138138
log.info("installing package data to %s", self.bdist_dir)
139-
self.call_command('install_data', force=0, root=None)
139+
self.call_command('install_data', force=False, root=None)
140140
finally:
141141
self.distribution.data_files = old
142142

@@ -164,7 +164,7 @@ def run(self): # noqa: C901 # is too complex (14) # FIXME
164164
instcmd.root = None
165165
if self.distribution.has_c_libraries() and not self.skip_build:
166166
self.run_command('build_clib')
167-
cmd = self.call_command('install_lib', warn_dir=0)
167+
cmd = self.call_command('install_lib', warn_dir=False)
168168
instcmd.root = old_root
169169

170170
all_outputs, ext_outputs = self.get_ext_outputs()
@@ -192,7 +192,7 @@ def run(self): # noqa: C901 # is too complex (14) # FIXME
192192
if self.distribution.scripts:
193193
script_dir = os.path.join(egg_info, 'scripts')
194194
log.info("installing scripts to %s", script_dir)
195-
self.call_command('install_scripts', install_dir=script_dir, no_ep=1)
195+
self.call_command('install_scripts', install_dir=script_dir, no_ep=True)
196196

197197
self.copy_metadata_to(egg_info)
198198
native_libs = os.path.join(egg_info, "native_libs.txt")
@@ -427,7 +427,9 @@ def can_scan():
427427
INSTALL_DIRECTORY_ATTRS = ['install_lib', 'install_dir', 'install_data', 'install_base']
428428

429429

430-
def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=True, mode='w'):
430+
def make_zipfile(
431+
zip_filename, base_dir, verbose=False, dry_run=False, compress=True, mode='w'
432+
):
431433
"""Create a zip file from all the files under 'base_dir'. The output
432434
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
433435
Python module (if available) or the InfoZIP "zip" utility (if installed

setuptools/command/build_ext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def link_shared_object(
401401
library_dirs=None,
402402
runtime_library_dirs=None,
403403
export_symbols=None,
404-
debug=0,
404+
debug=False,
405405
extra_preargs=None,
406406
extra_postargs=None,
407407
build_temp=None,
@@ -436,7 +436,7 @@ def link_shared_object(
436436
library_dirs=None,
437437
runtime_library_dirs=None,
438438
export_symbols=None,
439-
debug=0,
439+
debug=False,
440440
extra_preargs=None,
441441
extra_postargs=None,
442442
build_temp=None,

setuptools/command/build_py.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ def finalize_options(self):
4646
self.__updated_files = []
4747

4848
def copy_file(
49-
self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1
49+
self,
50+
infile,
51+
outfile,
52+
preserve_mode=True,
53+
preserve_times=True,
54+
link=None,
55+
level=1,
5056
):
5157
# Overwrite base class to allow using links
5258
if link:
@@ -70,7 +76,7 @@ def run(self):
7076

7177
# Only compile actual .py files, using our base class' idea of what our
7278
# output files are.
73-
self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0))
79+
self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=False))
7480

7581
def __getattr__(self, attr):
7682
"lazily compute data files"
@@ -132,7 +138,7 @@ def find_data_files(self, package, src_dir):
132138
)
133139
return self.exclude_data_files(package, src_dir, files)
134140

135-
def get_outputs(self, include_bytecode=1) -> list[str]:
141+
def get_outputs(self, include_bytecode=True) -> list[str]:
136142
"""See :class:`setuptools.commands.build.SubCommand`"""
137143
if self.editable_mode:
138144
return list(self.get_output_mapping().keys())

setuptools/command/develop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def install_for_development(self):
109109
self.run_command('egg_info')
110110

111111
# Build extensions in-place
112-
self.reinitialize_command('build_ext', inplace=1)
112+
self.reinitialize_command('build_ext', inplace=True)
113113
self.run_command('build_ext')
114114

115115
if setuptools.bootstrap_install_from:

setuptools/command/easy_install.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def initialize_options(self):
171171

172172
# the --user option seems to be an opt-in one,
173173
# so the default should be False.
174-
self.user = 0
174+
self.user = False
175175
self.zip_ok = self.local_snapshots_ok = None
176176
self.install_dir = self.script_dir = self.exclude_scripts = None
177177
self.index_url = None
@@ -1059,10 +1059,10 @@ def process(src, dst):
10591059
dl = dst.lower()
10601060
if dl.endswith('.pyd') or dl.endswith('.dll'):
10611061
parts[-1] = bdist_egg.strip_module(parts[-1])
1062-
top_level[os.path.splitext(parts[0])[0]] = 1
1062+
top_level[os.path.splitext(parts[0])[0]] = True
10631063
native_libs.append(src)
10641064
elif dl.endswith('.py') and old != 'SCRIPTS/':
1065-
top_level[os.path.splitext(parts[0])[0]] = 1
1065+
top_level[os.path.splitext(parts[0])[0]] = True
10661066
to_compile.append(dst)
10671067
return dst
10681068
if not src.endswith('.pth'):
@@ -1318,12 +1318,12 @@ def byte_compile(self, to_compile):
13181318
# try to make the byte compile messages quieter
13191319
log.set_verbosity(self.verbose - 1)
13201320

1321-
byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
1321+
byte_compile(to_compile, optimize=0, force=True, dry_run=self.dry_run)
13221322
if self.optimize:
13231323
byte_compile(
13241324
to_compile,
13251325
optimize=self.optimize,
1326-
force=1,
1326+
force=True,
13271327
dry_run=self.dry_run,
13281328
)
13291329
finally:
@@ -1491,7 +1491,7 @@ def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME
14911491
if dirname in seen:
14921492
continue
14931493

1494-
seen[dirname] = 1
1494+
seen[dirname] = True
14951495
if not os.path.isdir(dirname):
14961496
continue
14971497

@@ -1520,7 +1520,7 @@ def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME
15201520
if line in seen:
15211521
continue
15221522

1523-
seen[line] = 1
1523+
seen[line] = True
15241524
if not os.path.isdir(line):
15251525
continue
15261526

@@ -1643,7 +1643,7 @@ def _load_raw(self):
16431643
dirty = True
16441644
paths.pop()
16451645
continue
1646-
seen[normalized_path] = 1
1646+
seen[normalized_path] = True
16471647
f.close()
16481648
# remove any trailing empty/blank line
16491649
while paths and not paths[-1].strip():

setuptools/command/egg_info.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ class manifest_maker(sdist):
534534
template = "MANIFEST.in"
535535

536536
def initialize_options(self):
537-
self.use_defaults = 1
538-
self.prune = 1
539-
self.manifest_only = 1
540-
self.force_manifest = 1
537+
self.use_defaults = True
538+
self.prune = True
539+
self.manifest_only = True
540+
self.force_manifest = True
541541
self.ignore_egg_info_dir = False
542542

543543
def finalize_options(self):
@@ -623,7 +623,7 @@ def prune_file_list(self):
623623
self.filelist.prune(base_dir)
624624
sep = re.escape(os.sep)
625625
self.filelist.exclude_pattern(
626-
r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=1
626+
r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=True
627627
)
628628

629629
def _safe_data_files(self, build_py):

setuptools/command/install_lib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def copy_tree(
8888
self,
8989
infile: StrPath,
9090
outfile: str,
91-
preserve_mode=1,
92-
preserve_times=1,
93-
preserve_symlinks=0,
91+
preserve_mode=True,
92+
preserve_times=True,
93+
preserve_symlinks=False,
9494
level=1,
9595
):
9696
assert preserve_mode and preserve_times and not preserve_symlinks

0 commit comments

Comments
 (0)