diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py index 3d7585739..aa4d99570 100644 --- a/conda_smithy/cli.py +++ b/conda_smithy/cli.py @@ -40,7 +40,9 @@ def generate_feedstock_content(target_directory, source_recipe_dir): # If there is a source recipe, copy it now to the right dir if source_recipe_dir: try: - configure_feedstock.copytree(source_recipe_dir, str(target_recipe_dir)) + configure_feedstock.copytree( + source_recipe_dir, str(target_recipe_dir) + ) except Exception as e: import sys @@ -57,9 +59,7 @@ def generate_feedstock_content(target_directory, source_recipe_dir): forge_yml_recipe = Path(source_recipe_dir, "conda-forge.yml") yaml = YAML() if forge_yml_recipe.exists(): - feedstock_io.remove_file( - target_recipe_dir.joinpath("conda-forge.yml") - ) + feedstock_io.remove_file(target_recipe_dir.joinpath("conda-forge.yml")) try: with open(forge_yml_recipe, "r") as fp: _cfg = yaml.load(fp.read()) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index f59465947..7246363b5 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1175,16 +1175,19 @@ def _render_ci_provider( # If the recipe has its own conda_forge_ci_setup package, then # install that - if Path( - forge_dir, - forge_config["recipe_dir"], - "conda_forge_ci_setup", - "__init__.py", - ).exists() and Path( - forge_dir, - forge_config["recipe_dir"], - "setup.py", - ).exists(): + if ( + Path( + forge_dir, + forge_config["recipe_dir"], + "conda_forge_ci_setup", + "__init__.py", + ).exists() + and Path( + forge_dir, + forge_config["recipe_dir"], + "setup.py", + ).exists() + ): forge_config["local_ci_setup"] = True else: forge_config["local_ci_setup"] = False @@ -1324,9 +1327,7 @@ def _circle_specific_setup(jinja_env, forge_config, forge_dir, platform): ) # Fix permission of other shell files. - target_fnames = [ - Path(forge_dir, ".circleci", "checkout_merge_commit.sh") - ] + target_fnames = [Path(forge_dir, ".circleci", "checkout_merge_commit.sh")] for target_fname in target_fnames: set_exe_file(target_fname, True) @@ -1483,14 +1484,13 @@ def _render_template_exe_files( forge_config, jinja_env, template_files, forge_dir ): for template_file in template_files: - template = jinja_env.get_template( - Path(template_file).name + ".tmpl" - ) + template = jinja_env.get_template(Path(template_file).name + ".tmpl") target_fname = str(Path(forge_dir, template_file)) new_file_contents = template.render(**forge_config) - if target_fname in get_common_scripts(forge_dir) and Path( - target_fname - ).exists(): + if ( + target_fname in get_common_scripts(forge_dir) + and Path(target_fname).exists() + ): with open(target_fname, "r") as fh: old_file_contents = fh.read() if old_file_contents != new_file_contents: @@ -1723,9 +1723,7 @@ def _github_actions_specific_setup( def render_github_actions( jinja_env, forge_config, forge_dir, return_metadata=False ): - target_path = Path( - forge_dir, ".github", "workflows", "conda-build.yml" - ) + target_path = Path(forge_dir, ".github", "workflows", "conda-build.yml") template_filename = "github-actions.yml.tmpl" fast_finish_text = "" @@ -2152,6 +2150,7 @@ def _update_dict_within_dict(items, config): config[key] = value return config + def _read_forge_config(forge_dir, forge_yml=None): # Load default values from the conda-forge.yml file with open(CONDA_FORGE_YAML_DEFAULTS_FILE, "r") as fh: @@ -2191,9 +2190,12 @@ def _read_forge_config(forge_dir, forge_yml=None): # check for conda-smithy 2.x matrix which we can't auto-migrate # to conda_build_config - if file_config.get("matrix") and not Path( - forge_dir, config["recipe_dir"], "conda_build_config.yaml" - ).exists(): + if ( + file_config.get("matrix") + and not Path( + forge_dir, config["recipe_dir"], "conda_build_config.yaml" + ).exists() + ): raise ValueError( "Cannot rerender with matrix in conda-forge.yml." " Please migrate matrix to conda_build_config.yaml and try again." @@ -2480,9 +2482,7 @@ def get_cfp_file_path(temporary_directory): logger.debug(list(Path(temporary_directory).iterdir())) - cf_pinning_file = Path( - temporary_directory, "conda_build_config.yaml" - ) + cf_pinning_file = Path(temporary_directory, "conda_build_config.yaml") cf_pinning_ver = pkg.version assert cf_pinning_file.exists() @@ -2581,9 +2581,7 @@ def make_jinja_env(feedstock_directory): # Load templates from the feedstock in preference to the smithy's templates. env = SandboxedEnvironment( extensions=["jinja2.ext.do"], - loader=FileSystemLoader( - [Path(forge_dir, "templates"), tmplt_dir] - ), + loader=FileSystemLoader([Path(forge_dir, "templates"), tmplt_dir]), ) return env @@ -2800,4 +2798,4 @@ def main( ) args = parser.parse_args() - main(args.forge_file_directory) \ No newline at end of file + main(args.forge_file_directory) diff --git a/conda_smithy/feedstock_content/build-locally.py b/conda_smithy/feedstock_content/build-locally.py index e8b6a225e..a1c87cdff 100755 --- a/conda_smithy/feedstock_content/build-locally.py +++ b/conda_smithy/feedstock_content/build-locally.py @@ -35,9 +35,7 @@ def run_osx_build(ns): def verify_config(ns): - valid_configs = { - f.stem for f in Path(".ci_support").glob("*.yaml") - } + valid_configs = {f.stem for f in Path(".ci_support").glob("*.yaml")} print(f"valid configs are {valid_configs}") if ns.config in valid_configs: print("Using " + ns.config + " configuration") diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py index 98d12c7e0..6b942a36f 100644 --- a/conda_smithy/lint_recipe.py +++ b/conda_smithy/lint_recipe.py @@ -224,8 +224,7 @@ def lintify_meta_yaml( # 4: The recipe should have some tests. if not any(key in TEST_KEYS for key in test_section): a_test_file_exists = recipe_dir is not None and any( - (Path(recipe_dir, test_file)).exists() - for test_file in TEST_FILES + (Path(recipe_dir, test_file)).exists() for test_file in TEST_FILES ) if not a_test_file_exists: has_outputs_test = False @@ -858,7 +857,7 @@ def check_pins_build_and_requirements(top_level): with open(Path(file_dir, "licenses.txt"), "r") as f: expected_licenses = f.readlines() expected_licenses = set([l.strip() for l in expected_licenses]) - with open(Path(file_dir,"license_exceptions.txt"), "r") as f: + with open(Path(file_dir, "license_exceptions.txt"), "r") as f: expected_exceptions = f.readlines() expected_exceptions = set([l.strip() for l in expected_exceptions]) if set(filtered_licenses) - expected_licenses: diff --git a/conda_smithy/utils.py b/conda_smithy/utils.py index f30b16155..a24f41250 100644 --- a/conda_smithy/utils.py +++ b/conda_smithy/utils.py @@ -30,7 +30,9 @@ def get_feedstock_about_from_meta(meta) -> dict: # - if a subpackage has about, it's used as is # therefore we need to parse the yaml again just to get the about section... if "parent_recipe" in meta.meta["extra"]: - recipe_meta = Path(meta.meta["extra"]["parent_recipe"]["path"], "meta.yaml") + recipe_meta = Path( + meta.meta["extra"]["parent_recipe"]["path"], "meta.yaml" + ) with io.open(recipe_meta, "rt") as fh: content = render_meta_yaml("".join(fh)) diff --git a/tests/conftest.py b/tests/conftest.py index 4c28c0fc8..38717624b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -112,9 +112,7 @@ def config_yaml(testing_workdir, recipe_dirname): @pytest.fixture(scope="function") def noarch_recipe(config_yaml, recipe_dirname, request): - with open( - Path(config_yaml, recipe_dirname, "meta.yaml"), "w" - ) as fh: + with open(Path(config_yaml, recipe_dirname, "meta.yaml"), "w") as fh: fh.write( """ package: @@ -216,9 +214,7 @@ def stdlib_recipe(config_yaml, request): home: home """ ) - with open( - Path(config_yaml, "recipe", "stdlib_config.yaml"), "w" - ) as f: + with open(Path(config_yaml, "recipe", "stdlib_config.yaml"), "w") as f: f.write( """\ c_stdlib: @@ -246,9 +242,7 @@ def stdlib_recipe(config_yaml, request): @pytest.fixture(scope="function") def stdlib_deployment_target_recipe(config_yaml, stdlib_recipe): # append to existing stdlib_config.yaml from stdlib_recipe - with open( - Path(config_yaml, "recipe", "stdlib_config.yaml"), "a" - ) as f: + with open(Path(config_yaml, "recipe", "stdlib_config.yaml"), "a") as f: f.write( """\ MACOSX_DEPLOYMENT_TARGET: # [osx] @@ -318,7 +312,9 @@ def recipe_migration_cfep9(config_yaml, request): """ ) - Path(config_yaml, ".ci_support", "migrations").mkdir(parents=True, exist_ok=True) + Path(config_yaml, ".ci_support", "migrations").mkdir( + parents=True, exist_ok=True + ) with open( Path(config_yaml, ".ci_support", "migrations", "zlib.yaml"), "w", @@ -346,7 +342,9 @@ def recipe_migration_cfep9(config_yaml, request): def recipe_migration_cfep9_downgrade(config_yaml, recipe_migration_cfep9): # write a downgrade migrator that lives next to the current migrator. # Only this, more recent migrator should apply. - Path(config_yaml, ".ci_support", "migrations").mkdir(parents=True, exist_ok=True) + Path(config_yaml, ".ci_support", "migrations").mkdir( + parents=True, exist_ok=True + ) with open( Path(config_yaml, ".ci_support", "migrations", "zlib-downgrade.yaml"), "w", @@ -372,7 +370,9 @@ def recipe_migration_cfep9_downgrade(config_yaml, recipe_migration_cfep9): @pytest.fixture(scope="function") def recipe_migration_win_compiled(config_yaml, py_recipe): - Path(config_yaml, ".ci_support", "migrations").mkdir(parents=True, exist_ok=True) + Path(config_yaml, ".ci_support", "migrations").mkdir( + parents=True, exist_ok=True + ) with open( Path(config_yaml, ".ci_support", "migrations", "vc-migrate.yaml"), "w", diff --git a/tests/test_cli.py b/tests/test_cli.py index 02ade8d4d..334dfbcea 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -306,9 +306,7 @@ def test_regenerate(py_recipe, testing_workdir): feedstock_config=None, commit=False, no_check_uptodate=True, - exclusive_config_file=str( - Path(recipe, "recipe", "short_config.yaml") - ), + exclusive_config_file=str(Path(recipe, "recipe", "short_config.yaml")), check=False, temporary_directory=str(dest_dir.joinpath("temp")), ) diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index 1c751f257..b18fb41e2 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -193,7 +193,9 @@ def test_py_matrix_on_github(py_recipe, jinja_env): assert matrix_dir.is_dir() # single matrix entry - readme is generated later in main function assert len(list(matrix_dir.iterdir())) == 2 - assert Path(py_recipe.recipe, ".github", "workflows", "conda-build.yml").exists() + assert Path( + py_recipe.recipe, ".github", "workflows", "conda-build.yml" + ).exists() def test_py_matrix_on_azure(py_recipe, jinja_env): @@ -256,9 +258,7 @@ def test_stdlib_deployment_target( ) # this configuration should be run assert stdlib_deployment_target_recipe.config["azure"]["enabled"] - matrix_dir = Path( - stdlib_deployment_target_recipe.recipe, ".ci_support" - ) + matrix_dir = Path(stdlib_deployment_target_recipe.recipe, ".ci_support") assert matrix_dir.is_dir() with open(matrix_dir.joinpath("osx_64_.yaml")) as f: lines = f.readlines() @@ -354,9 +354,7 @@ def test_upload_on_branch_appveyor(upload_on_branch_recipe, jinja_env): assert upload_on_branch_recipe.config["upload_on_branch"] == "foo-branch" # Check that the parameter is in the generated file. - with open( - Path(upload_on_branch_recipe.recipe, ".appveyor.yml") - ) as fp: + with open(Path(upload_on_branch_recipe.recipe, ".appveyor.yml")) as fp: content = yaml.safe_load(fp) assert "%APPVEYOR_REPO_BRANCH%" in content["deploy_script"][0] assert "UPLOAD_ON_BRANCH=foo-branch" in content["deploy_script"][-2] @@ -498,9 +496,9 @@ def test_render_with_all_skipped_generates_readme(skipped_recipe, jinja_env): def test_render_windows_with_skipped_python(python_skipped_recipe, jinja_env): config = python_skipped_recipe.config config["provider"]["win"] = "appveyor" - config["exclusive_config_file"] = str(Path( - python_skipped_recipe.recipe, "recipe", "long_config.yaml" - )) + config["exclusive_config_file"] = str( + Path(python_skipped_recipe.recipe, "recipe", "long_config.yaml") + ) configure_feedstock.render_appveyor( jinja_env=jinja_env, forge_config=config, @@ -625,8 +623,12 @@ def test_migrator_cfp_override(recipe_migration_cfep9, jinja_env): def test_migrator_delete_old(recipe_migration_cfep9, jinja_env): cfp_file = recipe_migration_cfep9.config["exclusive_config_file"] - cfp_migration_dir = Path(cfp_file).parent.joinpath("share", "conda-forge", "migrations") - recipe_path = Path(recipe_migration_cfep9.recipe, ".ci_support", "migrations", "zlib.yaml") + cfp_migration_dir = Path(cfp_file).parent.joinpath( + "share", "conda-forge", "migrations" + ) + recipe_path = Path( + recipe_migration_cfep9.recipe, ".ci_support", "migrations", "zlib.yaml" + ) assert recipe_path.exists() cfp_migration_dir.mkdir(parents=True, exist_ok=True) configure_feedstock.render_azure( @@ -653,7 +655,7 @@ def test_migrator_downgrade_recipe( ".ci_support", "migrations", ) - assert (len(list(migrations_dir.iterdir())) == 2) + assert len(list(migrations_dir.iterdir())) == 2 with open( Path( @@ -678,8 +680,10 @@ def test_migrator_compiler_version_recipe( forge_dir=recipe_migration_win_compiled.recipe, ) - migrations_dir = Path(recipe_migration_win_compiled.recipe, ".ci_support", "migrations") - assert (len(list(migrations_dir.iterdir())) == 1) + migrations_dir = Path( + recipe_migration_win_compiled.recipe, ".ci_support", "migrations" + ) + assert len(list(migrations_dir.iterdir())) == 1 dir = Path(recipe_migration_win_compiled.recipe, ".ci_support") rendered_variants = [item.name for item in dir.iterdir()] @@ -784,9 +788,9 @@ def test_conda_forge_yaml_empty(config_yaml): def test_noarch_platforms_bad_yaml(config_yaml, caplog): load_forge_config = lambda: configure_feedstock._load_forge_config( # noqa config_yaml, - exclusive_config_file=str(Path( - config_yaml, "recipe", "default_config.yaml" - )), + exclusive_config_file=str( + Path(config_yaml, "recipe", "default_config.yaml") + ), ) with open(Path(config_yaml, "conda-forge.yml"), "a+") as fp: @@ -811,7 +815,9 @@ def test_forge_yml_alt_path(config_yaml): ) forge_yml = config_yaml_path.joinpath("conda-forge.yml") - forge_yml_alt = config_yaml_path.joinpath(".config", "feedstock-config.yml") + forge_yml_alt = config_yaml_path.joinpath( + ".config", "feedstock-config.yml" + ) forge_yml_alt.parent.mkdir() forge_yml.rename(forge_yml_alt) diff --git a/tests/test_feedstock_io.py b/tests/test_feedstock_io.py index 402bf6a97..30cd2b5fe 100644 --- a/tests/test_feedstock_io.py +++ b/tests/test_feedstock_io.py @@ -99,7 +99,9 @@ def test_set_exe_file(self): file_mode = filepath.stat().st_mode self.assertEqual(file_mode & set_mode, int(set_exe) * set_mode) if repo is not None: - blob = next(repo.index.iter_blobs(BlobFilter(str(filepath))))[1] + blob = next( + repo.index.iter_blobs(BlobFilter(str(filepath))) + )[1] self.assertEqual( blob.mode & set_mode, int(set_exe) * set_mode ) @@ -123,7 +125,9 @@ def test_write_file(self): self.assertEqual(write_text, read_text) if repo is not None: - blob = next(repo.index.iter_blobs(BlobFilter(str(filename))))[1] + blob = next( + repo.index.iter_blobs(BlobFilter(str(filename))) + )[1] read_text = blob.data_stream[3].read().decode("utf-8") self.assertEqual(write_text, read_text) @@ -142,7 +146,9 @@ def test_touch_file(self): self.assertEqual("", read_text) if repo is not None: - blob = next(repo.index.iter_blobs(BlobFilter(str(filename))))[1] + blob = next( + repo.index.iter_blobs(BlobFilter(str(filename))) + )[1] read_text = blob.data_stream[3].read().decode("utf-8") self.assertEqual("", read_text) @@ -217,7 +223,9 @@ def test_copy_file(self): self.assertEqual(write_text, read_text) if repo is not None: - blob = next(repo.index.iter_blobs(BlobFilter(str(filename2))))[1] + blob = next(repo.index.iter_blobs(BlobFilter(str(filename2))))[ + 1 + ] read_text = blob.data_stream[3].read().decode("utf-8") self.assertEqual(write_text, read_text) diff --git a/tests/test_feedstock_tokens.py b/tests/test_feedstock_tokens.py index a39909be0..f3dacc57c 100644 --- a/tests/test_feedstock_tokens.py +++ b/tests/test_feedstock_tokens.py @@ -327,9 +327,7 @@ def test_feedstock_token_exists( user = "foo" Path(tmpdir, "tokens").mkdir(parents=True, exist_ok=True) if file_exists: - with open( - Path(tmpdir, "tokens", f"{project}.json"), "w" - ) as fp: + with open(Path(tmpdir, "tokens", f"{project}.json"), "w") as fp: data = {"tokens": [{}]} if provider is not None: data["tokens"][0]["provider"] = provider diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index 3e217f3b4..6339e925d 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -1507,9 +1507,7 @@ def test_examples(self): self.assertNotIn(msg, lints) def test_multiple_sources(self): - lints = linter.main( - Path(_thisdir, "recipes", "multiple_sources") - ) + lints = linter.main(Path(_thisdir, "recipes", "multiple_sources")) assert not lints def test_noarch_platforms(self):