diff --git a/conda_build/api.py b/conda_build/api.py index 2d5fa7ee7d..076a15beff 100644 --- a/conda_build/api.py +++ b/conda_build/api.py @@ -655,17 +655,18 @@ def debug( ] if len(matched_outputs) > 1: raise ValueError( - "Specified --output-id matches more than one output ({}). Please refine your output id so that only " - "a single output is found.".format(matched_outputs) + f"Specified --output-id matches more than one output ({matched_outputs}). " + "Please refine your output id so that only a single output is found." ) elif not matched_outputs: raise ValueError( - f"Specified --output-id did not match any outputs. Available outputs are: {outputs} Please check it and try again" + f"Specified --output-id did not match any outputs. Available outputs are: {outputs} " + "Please check it and try again" ) if len(matched_outputs) > 1 and not path_is_build_dir: raise ValueError( - "More than one output found for this recipe ({}). Please use the --output-id argument to filter down " - "to a single output.".format(outputs) + f"More than one output found for this recipe ({outputs}). " + "Please use the --output-id argument to filter down to a single output." ) else: matched_outputs = outputs diff --git a/conda_build/build.py b/conda_build/build.py index 1d66cf114f..6c8e2f474f 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -501,7 +501,12 @@ def regex_files_py( match_records[file] = {"type": type, "submatches": []} # else: # if match_records[file]['absolute_offset'] != absolute_offset: - # print("Dropping match.pos() of {}, neq {}".format(absolute_offset, match_records[file]['absolute_offset'])) + # print( + # "Dropping match.pos() of {}, neq {}".format( + # absolute_offset, + # match_records[file]['absolute_offset'], + # ) + # ) g_index = len(match.groups()) if g_index == 0: # Complete match. @@ -639,8 +644,9 @@ def have_regex_files( return match_records import copy - match_records_rg, match_records_re = copy.deepcopy(match_records), copy.deepcopy( - match_records + match_records_rg, match_records_re = ( + copy.deepcopy(match_records), + copy.deepcopy(match_records), ) if not isinstance(regex_re, (bytes, bytearray)): regex_re = regex_re.encode("utf-8") @@ -2257,7 +2263,9 @@ def _write_sh_activation_text(file_handle, m): if value: if not done_necessary_env: # file_handle.write( - # 'export CCACHE_SLOPPINESS="pch_defines,time_macros${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}"\n') + # 'export CCACHE_SLOPPINESS="pch_defines,time_macros' + # '${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}"\n' + # ) # file_handle.write('export CCACHE_CPP2=true\n') done_necessary_env = True if method == "symlinks": @@ -2266,16 +2274,12 @@ def _write_sh_activation_text(file_handle, m): file_handle.write(f"pushd {dirname_ccache_ln_bin}\n") file_handle.write('if [ -n "$CC" ]; then\n') file_handle.write( - " [ -f {ccache} ] && [ ! -f $(basename $CC) ] && ln -s {ccache} $(basename $CC) || true\n".format( - ccache=ccache - ) + f" [ -f {ccache} ] && [ ! -f $(basename $CC) ] && ln -s {ccache} $(basename $CC) || true\n" ) file_handle.write("fi\n") file_handle.write('if [ -n "$CXX" ]; then\n') file_handle.write( - " [ -f {ccache} ] && [ ! -f $(basename $CXX) ] && ln -s {ccache} $(basename $CXX) || true\n".format( - ccache=ccache - ) + f" [ -f {ccache} ] && [ ! -f $(basename $CXX) ] && ln -s {ccache} $(basename $CXX) || true\n" ) file_handle.write("fi\n") file_handle.write("popd\n") diff --git a/conda_build/cli/main_develop.py b/conda_build/cli/main_develop.py index a7a202e5ff..46c8384826 100644 --- a/conda_build/cli/main_develop.py +++ b/conda_build/cli/main_develop.py @@ -19,7 +19,7 @@ def parse_args(args): Install a Python package in 'development mode'. -This works by creating a conda.pth file in site-packages.""" +This works by creating a conda.pth file in site-packages.""", # TODO: Use setup.py to determine any entry-points to install. ) diff --git a/conda_build/exceptions.py b/conda_build/exceptions.py index d8ed36ff06..857141fb4f 100644 --- a/conda_build/exceptions.py +++ b/conda_build/exceptions.py @@ -88,8 +88,7 @@ def __init__( self.packages.append(pkg) if not self.packages: raise RuntimeError( - "failed to parse packages from exception:" - " {}".format(str(conda_exception)) + f"failed to parse packages from exception: {conda_exception}" ) def __str__(self): diff --git a/conda_build/index.py b/conda_build/index.py index 690673f0c9..b1a72dfde1 100644 --- a/conda_build/index.py +++ b/conda_build/index.py @@ -360,7 +360,8 @@ def update_index( if dirname in utils.DEFAULT_SUBDIRS: if warn: log.warn( - "The update_index function has changed to index all subdirs at once. You're pointing it at a single subdir. " + "The update_index function has changed to index all subdirs at once. " + "You're pointing it at a single subdir. " "Please update your code to point it at the channel root, rather than a subdir." ) return update_index( diff --git a/conda_build/jinja_context.py b/conda_build/jinja_context.py index 9d507e43a6..eaadc3a100 100644 --- a/conda_build/jinja_context.py +++ b/conda_build/jinja_context.py @@ -97,18 +97,8 @@ def __init__( __call__ ) = ( __getitem__ - ) = ( - __lt__ - ) = ( - __le__ - ) = ( - __gt__ - ) = ( - __ge__ - ) = ( - __complex__ - ) = __pow__ = __rpow__ = lambda self, *args, **kwargs: self._return_undefined( - self._undefined_name + ) = __lt__ = __le__ = __gt__ = __ge__ = __complex__ = __pow__ = __rpow__ = ( + lambda self, *args, **kwargs: self._return_undefined(self._undefined_name) ) # Accessing an attribute of an Undefined variable diff --git a/conda_build/metadata.py b/conda_build/metadata.py index d2d87912bf..5ca91b2e81 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -1475,7 +1475,8 @@ def get_depends_top_and_out(self, typ): meta_requirements = ensure_list(self.get_value("requirements/" + typ, []))[:] req_names = {req.split()[0] for req in meta_requirements if req} extra_reqs = [] - # this is for the edge case of requirements for top-level being also partially defined in a similarly named output + # this is for the edge case of requirements for top-level being + # partially defined in a similarly named output if not self.is_output: matching_output = [ out diff --git a/conda_build/noarch_python.py b/conda_build/noarch_python.py index 380367d43d..30efb3d45d 100644 --- a/conda_build/noarch_python.py +++ b/conda_build/noarch_python.py @@ -142,11 +142,7 @@ def transform(m, files, prefix): """\ @echo off "%PREFIX%\\python.exe" "%SOURCE_DIR%\\link.py" - """.replace( - "\n", "\r\n" - ).encode( - "utf-8" - ) + """.replace("\n", "\r\n").encode("utf-8") ) d = populate_files(m, files, prefix) diff --git a/conda_build/os_utils/liefldd.py b/conda_build/os_utils/liefldd.py index 26a768a4f6..9e5c9836bb 100644 --- a/conda_build/os_utils/liefldd.py +++ b/conda_build/os_utils/liefldd.py @@ -588,8 +588,14 @@ def inspect_linkages_lief( """ if binary.format == lief.EXE_FORMATS.PE: import random - path_fixed = os.path.dirname(path_fixed) + os.sep + \ - ''.join(random.choice((str.upper, str.lower))(c) for c in os.path.basename(path_fixed)) + path_fixed = ( + os.path.dirname(path_fixed) + + os.sep + + ''.join( + random.choice((str.upper, str.lower))(c) + for c in os.path.basename(path_fixed) + ) + ) if random.getrandbits(1): path_fixed = path_fixed.replace(os.sep + 'lib' + os.sep, os.sep + 'Lib' + os.sep) else: @@ -650,16 +656,11 @@ def get_linkages( ) if debug and result_pyldd and set(result_lief) != set(result_pyldd): print( - "WARNING: Disagreement in get_linkages(filename={}, resolve_filenames={}, recurse={}, sysroot={}, envroot={}, arch={}):\n lief: {}\npyldd: {}\n (using lief)".format( - filename, - resolve_filenames, - recurse, - sysroot, - envroot, - arch, - result_lief, - result_pyldd, - ) + f"WARNING: Disagreement in get_linkages({filename=}, " + f"{resolve_filenames=}, {recurse=}, {sysroot=}, {envroot=}, {arch=}):\n" + f" lief: {result_lief}\n" + f"pyldd: {result_pyldd}\n" + " (using lief)" ) return result_lief @@ -689,7 +690,7 @@ def is_archive(file): def get_static_lib_exports(file): - # file = '/Users/rdonnelly/conda/main-augmented-tmp/osx-64_14354bd0cd1882bc620336d9a69ae5b9/lib/python2.7/config/libpython2.7.a' + # file = '/Users/rdonnelly/conda/main-augmented-tmp/osx-64_14354bd0cd1882bc620336d9a69ae5b9/lib/python2.7/config/libpython2.7.a' # noqa: E501 # References: # https://github.com/bminor/binutils-gdb/tree/master/bfd/archive.c # https://en.wikipedia.org/wiki/Ar_(Unix) @@ -737,7 +738,8 @@ def _parse_ar_hdr(content, index): typ = "NORMAL" if b"/" in name: name = name[: name.find(b"/")] - # if debug_static_archives: print("index={}, name={}, ending={}, size={}, type={}".format(index, name, ending, size, typ)) + # if debug_static_archives: + # print(f"index={index}, name={name}, ending={ending}, size={size}, type={typ}") index += header_sz + name_len return index, name, name_len, size, typ @@ -813,9 +815,7 @@ def _parse_ar_hdr(content, index): (size_string_table,) = struct.unpack( "<" + toc_integers_fmt, content[ - index - + toc_integers_sz - + (nsymbols * ranlib_struct_sz) : index + index + toc_integers_sz + (nsymbols * ranlib_struct_sz) : index + 4 + 4 + (nsymbols * ranlib_struct_sz) @@ -827,8 +827,7 @@ def _parse_ar_hdr(content, index): ran_off, ran_strx = struct.unpack( "<" + ranlib_struct_field_fmt + ranlib_struct_field_fmt, content[ - ranlib_index - + (i * ranlib_struct_sz) : ranlib_index + ranlib_index + (i * ranlib_struct_sz) : ranlib_index + ((i + 1) * ranlib_struct_sz) ], ) @@ -845,8 +844,7 @@ def _parse_ar_hdr(content, index): ) ) string_table = content[ - ranlib_index - + (nsymbols * ranlib_struct_sz) : ranlib_index + ranlib_index + (nsymbols * ranlib_struct_sz) : ranlib_index + (nsymbols * ranlib_struct_sz) + size_string_table ] @@ -958,7 +956,7 @@ def get_static_lib_exports_dumpbin(filename): > 020 00000000 UNDEF notype () External | malloc > vs > 004 00000010 SECT1 notype () External | _ZN3gnu11autosprintfC1EPKcz - """ + """ # noqa: E501 dumpbin_exe = find_executable("dumpbin") if not dumpbin_exe: """ @@ -1077,19 +1075,15 @@ def get_exports(filename, arch="native", enable_static=False): print(f"errors: {error_count} (-{len(diff1)}, +{len(diff2)})") if debug_static_archives: print( - "WARNING :: Disagreement regarding static lib exports in {} between nm (nsyms={}) and lielfldd (nsyms={}):".format( - filename, len(exports), len(exports2) - ) + "WARNING :: Disagreement regarding static lib exports in " + f"{filename} between nm (nsyms={len(exports)}) and " + "lielfldd (nsyms={len(exports2)}):" ) print( - "** nm.diff(liefldd) [MISSING SYMBOLS] **\n{}".format( - "\n".join(diff1) - ) + "\n".join(("** nm.diff(liefldd) [MISSING SYMBOLS] **", *diff1)) ) print( - "** liefldd.diff(nm) [ EXTRA SYMBOLS] **\n{}".format( - "\n".join(diff2) - ) + "\n".join(("** liefldd.diff(nm) [ EXTRA SYMBOLS] **", *diff2)) ) if not result: diff --git a/conda_build/os_utils/pyldd.py b/conda_build/os_utils/pyldd.py index 42b89711ae..f3a980319c 100644 --- a/conda_build/os_utils/pyldd.py +++ b/conda_build/os_utils/pyldd.py @@ -708,13 +708,9 @@ def __init__(self, file): get_logger(__name__).warning(f"file.tell()={loc} != ehsize={self.ehsize}") def __str__(self): - return "bitness {}, endian {}, version {}, type {}, machine {}, entry {}".format( # noqa - self.bitness, - self.endian, - self.version, - self.type, - hex(self.machine), - hex(self.entry), + return ( + f"bitness {self.bitness}, endian {self.endian}, version {self.version}, " + f"type {self.type}, machine {hex(self.machine)}, entry {hex(self.entry)}" ) diff --git a/conda_build/plugin.py b/conda_build/plugin.py index eddb85fe66..6ca5c34cc1 100644 --- a/conda_build/plugin.py +++ b/conda_build/plugin.py @@ -78,12 +78,18 @@ def conda_subcommands(): ) yield conda.plugins.CondaSubcommand( name="develop", - summary="Install a Python package in 'development mode'. Similar to `pip install --editable`.", + summary=( + "Install a Python package in 'development mode'. " + "Similar to `pip install --editable`." + ), action=develop, ) yield conda.plugins.CondaSubcommand( name="index", - summary="Update package index metadata files. Pending deprecation, use https://github.com/conda/conda-index instead.", + summary=( + "Update package index metadata files. Pending deprecation, " + "use https://github.com/conda/conda-index instead." + ), action=index, ) yield conda.plugins.CondaSubcommand( diff --git a/conda_build/post.py b/conda_build/post.py index 05af50b24f..0194bfda28 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -517,7 +517,14 @@ def check_binary(binary, expected=None): print("trying {}".format(binary)) # import pdb; pdb.set_trace() try: - txt = check_output([sys.executable, '-c', 'from ctypes import cdll; cdll.LoadLibrary("' + binary + '")'], timeout=2) + txt = check_output( + [ + sys.executable, + '-c', + 'from ctypes import cdll; cdll.LoadLibrary("' + binary + '")' + ], + timeout=2, + ) # mydll = cdll.LoadLibrary(binary) except Exception as e: print(e) diff --git a/conda_build/skeletons/cran.py b/conda_build/skeletons/cran.py index e3b22ef7d2..6a4dbe65f6 100755 --- a/conda_build/skeletons/cran.py +++ b/conda_build/skeletons/cran.py @@ -3,8 +3,6 @@ """ Tools for converting Cran packages to conda recipes. """ - - import argparse import copy import hashlib @@ -198,7 +196,7 @@ popd fi fi -""" +""" # noqa: E501 CRAN_BUILD_SH_BINARY = """\ #!/bin/bash @@ -1299,10 +1297,8 @@ def skeletonize( ) if not is_github_url: available_details["archive_keys"] = ( - "{url_key}{sel}" - " {cranurl}\n" - " {hash_entry}{sel}".format(**available_details) - ) + "{url_key}{sel} {cranurl}\n {hash_entry}{sel}" + ).format(**available_details) # Extract the DESCRIPTION data from the source if cran_package is None: diff --git a/conda_build/skeletons/rpm.py b/conda_build/skeletons/rpm.py index 409e3aad4b..76f2e5ea86 100644 --- a/conda_build/skeletons/rpm.py +++ b/conda_build/skeletons/rpm.py @@ -473,8 +473,9 @@ def remap_license(rpm_license): } l_rpm_license = rpm_license.lower() if l_rpm_license in mapping: - license, family = mapping[l_rpm_license], guess_license_family( - mapping[l_rpm_license] + license, family = ( + mapping[l_rpm_license], + guess_license_family(mapping[l_rpm_license]), ) else: license, family = rpm_license, guess_license_family(rpm_license) diff --git a/conda_build/tarcheck.py b/conda_build/tarcheck.py index 7884066014..3fc363986e 100644 --- a/conda_build/tarcheck.py +++ b/conda_build/tarcheck.py @@ -90,9 +90,8 @@ def correct_subdir(self): self.config.host_subdir, "noarch", self.config.target_subdir, - ], ( - "Inconsistent subdir in package - index.json expecting {}," - " got {}".format(self.config.host_subdir, info["subdir"]) + ], "Inconsistent subdir in package - index.json expecting {}, got {}".format( + self.config.host_subdir, info["subdir"] ) diff --git a/conda_build/variants.py b/conda_build/variants.py index d7c6841238..1237154c89 100644 --- a/conda_build/variants.py +++ b/conda_build/variants.py @@ -164,7 +164,8 @@ def validate_spec(src, spec): " zip_key entry {} in group {} is a duplicate, keys can only occur " "in one group".format(k, zg) # include error if key has already been seen, otherwise add to unique keys - if k in unique else unique.add(k) + if k in unique + else unique.add(k) for zg in zip_keys for k in zg ) diff --git a/tests/conftest.py b/tests/conftest.py index 3aca5b4bc7..5de4fa4b78 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -72,7 +72,8 @@ def testing_homedir() -> Iterator[Path]: os.chdir(saved) except OSError: pytest.xfail( - f"failed to create temporary directory () in {'%HOME%' if on_win else '${HOME}'} (tmpfs inappropriate for xattrs)" + f"failed to create temporary directory () in {'%HOME%' if on_win else '${HOME}'} " + "(tmpfs inappropriate for xattrs)" ) diff --git a/tests/test_api_build.py b/tests/test_api_build.py index e0c786dcc8..e0a5b4df7b 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -398,9 +398,7 @@ def dummy_executable(folder, exename): echo ******* conda that makes it not add the _build/bin directory onto the echo ******* PATH before running the source checkout tool exit -1 - """.format( - exename - ) + """.format(exename) ) if sys.platform != "win32": import stat @@ -754,57 +752,30 @@ def test_relative_git_url_submodule_clone(testing_workdir, testing_config, monke if not os.path.exists(recipe_dir): os.makedirs(recipe_dir) filename = os.path.join(testing_workdir, "recipe", "meta.yaml") - data = OrderedDict( - [ - ( - "package", - OrderedDict( - [ - ("name", "relative_submodules"), - ("version", "{{ GIT_DESCRIBE_TAG }}"), - ] - ), - ), - ("source", OrderedDict([("git_url", toplevel), ("git_tag", str(tag))])), - requirements, - ( - "build", - OrderedDict( - [ - ( - "script", - [ - "git --no-pager submodule --quiet foreach git log -n 1 --pretty=format:%%s > " - "%PREFIX%\\summaries.txt # [win]", - "git --no-pager submodule --quiet foreach git log -n 1 --pretty=format:%s > " - "$PREFIX/summaries.txt # [not win]", - ], - ) - ] - ), - ), - ( - "test", - OrderedDict( - [ - ( - "commands", - [ - "echo absolute{}relative{} > %PREFIX%\\expected_summaries.txt # [win]".format( - tag, tag - ), - "fc.exe /W %PREFIX%\\expected_summaries.txt %PREFIX%\\summaries.txt # [win]", - "echo absolute{}relative{} > $PREFIX/expected_summaries.txt # [not win]".format( - tag, tag - ), - "diff -wuN ${PREFIX}/expected_summaries.txt ${PREFIX}/summaries.txt # [not win]", - ], - ) - ] - ), - ), - ] - ) + data = { + "package": { + "name": "relative_submodules", + "version": "{{ GIT_DESCRIBE_TAG }}", + }, + "source": {"git_url": toplevel, "git_tag": str(tag)}, + **requirements, + "build": { + "script": [ + "git --no-pager submodule --quiet foreach git log -n 1 --pretty=format:%%s > " + "%PREFIX%\\summaries.txt # [win]", + "git --no-pager submodule --quiet foreach git log -n 1 --pretty=format:%s > " + "$PREFIX/summaries.txt # [not win]", + ], + }, + "test": { + "commands": [ + f"echo absolute{tag}relative{tag} > %PREFIX%\\expected_summaries.txt # [win]", + "fc.exe /W %PREFIX%\\expected_summaries.txt %PREFIX%\\summaries.txt # [win]", + f"echo absolute{tag}relative{tag} > $PREFIX/expected_summaries.txt # [not win]", + "diff -wuN ${PREFIX}/expected_summaries.txt ${PREFIX}/summaries.txt # [not win]", + ], + }, + } with open(filename, "w") as outfile: outfile.write(yaml.dump(data, default_flow_style=False, width=999999999)) @@ -1614,9 +1585,10 @@ def test_copy_test_source_files(testing_config): found = True break if found: - assert ( - copy - ), "'info/test/test_files_folder/text.txt' found in tar.bz2 but not copying test source files" + assert copy, ( + "'info/test/test_files_folder/text.txt' found in tar.bz2 " + "but not copying test source files" + ) if copy: api.test(outputs[0]) else: @@ -1624,8 +1596,8 @@ def test_copy_test_source_files(testing_config): api.test(outputs[0]) else: assert not copy, ( - "'info/test/test_files_folder/text.txt' not found in tar.bz2 but copying test source files. File list: %r" - % files + "'info/test/test_files_folder/text.txt' not found in tar.bz2 " + f"but copying test source files. File list: {files!r}" ) diff --git a/tests/test_api_render.py b/tests/test_api_render.py index a68f69135e..1451fbbbe0 100644 --- a/tests/test_api_render.py +++ b/tests/test_api_render.py @@ -99,8 +99,9 @@ def test_get_output_file_path_jinja2(testing_config): assert build_path == os.path.join( testing_config.croot, testing_config.host_subdir, - "conda-build-test-source-git-jinja2-1.20.2-" - "py{}{}_0_g262d444.tar.bz2".format(python, _hash), + "conda-build-test-source-git-jinja2-1.20.2-py{}{}_0_g262d444.tar.bz2".format( + python, _hash + ), ) diff --git a/tests/test_utils.py b/tests/test_utils.py index b5536cdf6d..baa5bf5a34 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -293,9 +293,7 @@ def test_logger_config_from_file(testing_workdir, capfd, mocker): root: level: DEBUG handlers: [console] -""".format( - __name__ - ) +""".format(__name__) ) cc_conda_build = mocker.patch.object(utils, "cc_conda_build") cc_conda_build.get.return_value = test_file