Skip to content

Use actual boolean parameters and variables #4365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4365.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use actual boolean parameters and variables instead of 0-1 literals. -- by :user:`Avasam`
2 changes: 1 addition & 1 deletion pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def __iter__(self):

for key in self.entry_keys[item]:
if key not in seen:
seen[key] = 1
seen[key] = True
yield self.by_key[key]

def add(self, dist, entry=None, insert=True, replace=False):
Expand Down
2 changes: 1 addition & 1 deletion setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def ensure_string_list(self, option):
"'%s' must be a list of strings (got %r)" % (option, val)
)

def reinitialize_command(self, command, reinit_subcommands=0, **kw):
def reinitialize_command(self, command, reinit_subcommands=False, **kw):
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
vars(cmd).update(kw)
return cmd
Expand Down
14 changes: 8 additions & 6 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class bdist_egg(Command):
def initialize_options(self):
self.bdist_dir = None
self.plat_name = None
self.keep_temp = 0
self.keep_temp = False
self.dist_dir = None
self.skip_build = 0
self.skip_build = False
self.egg_output = None
self.exclude_source_files = None

Expand Down Expand Up @@ -136,7 +136,7 @@ def do_install_data(self):

try:
log.info("installing package data to %s", self.bdist_dir)
self.call_command('install_data', force=0, root=None)
self.call_command('install_data', force=False, root=None)
finally:
self.distribution.data_files = old

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

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

self.copy_metadata_to(egg_info)
native_libs = os.path.join(egg_info, "native_libs.txt")
Expand Down Expand Up @@ -426,7 +426,9 @@ def can_scan():
INSTALL_DIRECTORY_ATTRS = ['install_lib', 'install_dir', 'install_data', 'install_base']


def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=True, mode='w'):
def make_zipfile(
zip_filename, base_dir, verbose=False, dry_run=False, compress=True, mode='w'
):
"""Create a zip file from all the files under 'base_dir'. The output
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
Python module (if available) or the InfoZIP "zip" utility (if installed
Expand Down
4 changes: 2 additions & 2 deletions setuptools/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def link_shared_object(
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
debug=False,
extra_preargs=None,
extra_postargs=None,
build_temp=None,
Expand Down Expand Up @@ -434,7 +434,7 @@ def link_shared_object(
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
debug=False,
extra_preargs=None,
extra_postargs=None,
build_temp=None,
Expand Down
12 changes: 9 additions & 3 deletions setuptools/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ def finalize_options(self):
self.__updated_files = []

def copy_file(
self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1
self,
infile,
outfile,
preserve_mode=True,
preserve_times=True,
link=None,
level=1,
):
# Overwrite base class to allow using links
if link:
Expand All @@ -68,7 +74,7 @@ def run(self):

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

def __getattr__(self, attr):
"lazily compute data files"
Expand Down Expand Up @@ -130,7 +136,7 @@ def find_data_files(self, package, src_dir):
)
return self.exclude_data_files(package, src_dir, files)

def get_outputs(self, include_bytecode=1) -> List[str]:
def get_outputs(self, include_bytecode=True) -> List[str]:
"""See :class:`setuptools.commands.build.SubCommand`"""
if self.editable_mode:
return list(self.get_output_mapping().keys())
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def install_for_development(self):
self.run_command('egg_info')

# Build extensions in-place
self.reinitialize_command('build_ext', inplace=1)
self.reinitialize_command('build_ext', inplace=True)
self.run_command('build_ext')

if setuptools.bootstrap_install_from:
Expand Down
16 changes: 8 additions & 8 deletions setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def initialize_options(self):

# the --user option seems to be an opt-in one,
# so the default should be False.
self.user = 0
self.user = False
self.zip_ok = self.local_snapshots_ok = None
self.install_dir = self.script_dir = self.exclude_scripts = None
self.index_url = None
Expand Down Expand Up @@ -1058,10 +1058,10 @@ def process(src, dst):
dl = dst.lower()
if dl.endswith('.pyd') or dl.endswith('.dll'):
parts[-1] = bdist_egg.strip_module(parts[-1])
top_level[os.path.splitext(parts[0])[0]] = 1
top_level[os.path.splitext(parts[0])[0]] = True
native_libs.append(src)
elif dl.endswith('.py') and old != 'SCRIPTS/':
top_level[os.path.splitext(parts[0])[0]] = 1
top_level[os.path.splitext(parts[0])[0]] = True
to_compile.append(dst)
return dst
if not src.endswith('.pth'):
Expand Down Expand Up @@ -1317,12 +1317,12 @@ def byte_compile(self, to_compile):
# try to make the byte compile messages quieter
log.set_verbosity(self.verbose - 1)

byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
byte_compile(to_compile, optimize=0, force=True, dry_run=self.dry_run)
if self.optimize:
byte_compile(
to_compile,
optimize=self.optimize,
force=1,
force=True,
dry_run=self.dry_run,
)
finally:
Expand Down Expand Up @@ -1490,7 +1490,7 @@ def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME
if dirname in seen:
continue

seen[dirname] = 1
seen[dirname] = True
if not os.path.isdir(dirname):
continue

Expand Down Expand Up @@ -1519,7 +1519,7 @@ def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME
if line in seen:
continue

seen[line] = 1
seen[line] = True
if not os.path.isdir(line):
continue

Expand Down Expand Up @@ -1642,7 +1642,7 @@ def _load_raw(self):
dirty = True
paths.pop()
continue
seen[normalized_path] = 1
seen[normalized_path] = True
f.close()
# remove any trailing empty/blank line
while paths and not paths[-1].strip():
Expand Down
10 changes: 5 additions & 5 deletions setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ class manifest_maker(sdist):
template = "MANIFEST.in"

def initialize_options(self):
self.use_defaults = 1
self.prune = 1
self.manifest_only = 1
self.force_manifest = 1
self.use_defaults = True
self.prune = True
self.manifest_only = True
self.force_manifest = True
self.ignore_egg_info_dir = False

def finalize_options(self):
Expand Down Expand Up @@ -623,7 +623,7 @@ def prune_file_list(self):
self.filelist.prune(base_dir)
sep = re.escape(os.sep)
self.filelist.exclude_pattern(
r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=1
r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=True
)

def _safe_data_files(self, build_py):
Expand Down
6 changes: 3 additions & 3 deletions setuptools/command/install_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def copy_tree(
self,
infile,
outfile,
preserve_mode=1,
preserve_times=1,
preserve_symlinks=0,
preserve_mode=True,
preserve_times=True,
preserve_symlinks=False,
level=1,
):
assert preserve_mode and preserve_times and not preserve_symlinks
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def project_on_sys_path(self, include_dists=()):
self.run_command('egg_info')

# Build extensions in-place
self.reinitialize_command('build_ext', inplace=1)
self.reinitialize_command('build_ext', inplace=True)
self.run_command('build_ext')

ei_cmd = self.get_finalized_command("egg_info")
Expand Down
2 changes: 1 addition & 1 deletion setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def find(req, env=None):
"Skipping development or system egg: %s",
dist,
)
skipped[dist] = 1
skipped[dist] = True
continue

test = dist in req and (dist.precedence <= SOURCE_DIST or not source)
Expand Down