diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ccf73df76015b1b9983f83dc2415a1244417ce5a..cd2a22a1c326bb596042f7c5a35ced387b2e58d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,17 +2,17 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/timothycrosley/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: [--settings-path, "pyproject.toml"] - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.1.0 hooks: - id: black exclude: bob/devtools/templates/setup.py - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 6.0.0 hooks: - id: flake8 exclude: | @@ -21,7 +21,7 @@ repos: deps/bob-devel/run_test.py )$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-ast exclude: bob/devtools/templates/setup.py diff --git a/bob/devtools/bootstrap.py b/bob/devtools/bootstrap.py index 73efac7a1a1e607225cd6186f1397534a5bd046d..88e26641b50f70ff50d66d8e41bd5aef39bcf1a7 100644 --- a/bob/devtools/bootstrap.py +++ b/bob/devtools/bootstrap.py @@ -423,7 +423,6 @@ def setup_logger(logger, level): if __name__ == "__main__": - import argparse parser = argparse.ArgumentParser( @@ -547,7 +546,6 @@ if __name__ == "__main__": should_install_git = [] if args.command == "build": - # clean conda cache and packages before building run_cmdline([conda_bin, "clean", "--all"]) @@ -572,7 +570,6 @@ if __name__ == "__main__": ) elif args.command == "local": - # index the locally built packages run_cmdline( [conda_bin, "install", "--yes"] @@ -615,7 +612,6 @@ if __name__ == "__main__": ) elif args.command == "channel": - # installs from channel channels, _ = get_channels( public=True, diff --git a/bob/devtools/build.py b/bob/devtools/build.py index f664f849c16b030e942878342d2538d63faf8977..9925da7dec65a86de2a11386aa8e7ada6e4e9f71 100644 --- a/bob/devtools/build.py +++ b/bob/devtools/build.py @@ -265,7 +265,6 @@ def exists_on_channel(channel_url, basename): build_number, urls = next_build_number(channel_url, basename) def _get_build_number(name): - # remove .tar.bz2/.conda from name, then split from the end twice, on # '-' if name.endswith(".conda"): @@ -329,7 +328,6 @@ def uniq(seq, idfun=None): def parse_dependencies(recipe_dir, config): - metadata = get_rendered_metadata(recipe_dir, config) recipe = get_parsed_recipe(metadata) requirements = [] @@ -982,7 +980,6 @@ def build_deps(obj): """ recipes = load_order_file(os.path.join("deps", "order.txt")) for k, recipe in enumerate([os.path.join("deps", k) for k in recipes]): - if not os.path.exists(os.path.join(recipe, "meta.yaml")): # ignore - not a conda package continue diff --git a/bob/devtools/changelog.py b/bob/devtools/changelog.py index d5b20692e2c9e351d6b54b801fa50cc153dfd787..695e2b109f35b8e1a2cbdf6070b574532471d8be 100644 --- a/bob/devtools/changelog.py +++ b/bob/devtools/changelog.py @@ -131,7 +131,6 @@ def get_last_tag_date(package): def _get_tag_changelog(tag): - try: return tag.release["description"] except Exception: @@ -152,7 +151,6 @@ def _write_one_tag(f, pkg_name, tag): f.write(" * %s (%s)\n" % (tag.name, git_date.strftime("%b %d, %Y %H:%M"))) for line in _get_tag_changelog(tag).replace("\r\n", "\n").split("\n"): - line = line.strip() if line.startswith("* ") or line.startswith("- "): line = line[2:] @@ -294,7 +292,6 @@ def write_tags_with_commits(f, gitpkg, since, mode): # commits start_date = since for tag in tags: - # write tag name and its text _write_one_tag(f, gitpkg.attributes["path_with_namespace"], tag) end_date = parse_date(tag.commit["committed_date"]) @@ -326,7 +323,6 @@ def write_tags_with_commits(f, gitpkg, since, mode): start_date = end_date if mode != "tags": - # write the tentative patch version bump for the future tag f.write(" * patch\n") diff --git a/bob/devtools/ci.py b/bob/devtools/ci.py index 26965fd1055c5f6d9843ffbf7f58e0c6d470eda5..07700f98e531aaaf0e2851bad8d6aba66cdac8cd 100644 --- a/bob/devtools/ci.py +++ b/bob/devtools/ci.py @@ -258,7 +258,6 @@ def cleanup(dry_run, username, password, includes): from .deploy import _setup_webdav_client for public in (True, False): - server_info = WEBDAV_PATHS[False][public] davclient = _setup_webdav_client( SERVER, server_info["root"], username, password @@ -283,7 +282,6 @@ def cleanup(dry_run, username, password, includes): path = server_info["conda"] for arch in archs: - arch_path = "/".join((path, arch)) if not (davclient.check(arch_path) and davclient.is_dir(arch_path)): diff --git a/bob/devtools/data/gitlab-ci/conda-configurator.py b/bob/devtools/data/gitlab-ci/conda-configurator.py index 489649fcc5b0325d4c264aa91042a34ffb26f572..46255d39a1d21e17dd0e5140207e7db3a2cc8b30 100644 --- a/bob/devtools/data/gitlab-ci/conda-configurator.py +++ b/bob/devtools/data/gitlab-ci/conda-configurator.py @@ -86,7 +86,6 @@ def _get_channels(public, stable, server, intranet, group): if __name__ == "__main__": - if len(sys.argv) != 5: print(f"usage: {sys.argv[0]} group visibility tag condarc") sys.exit(1) diff --git a/bob/devtools/data/gitlab-ci/conda-next-build.py b/bob/devtools/data/gitlab-ci/conda-next-build.py index 9758255bea1eb5f98d3aadb9be9c405b19ebb540..85b28e6cb784e3f1c4739cdd33c9893c3921f7b8 100644 --- a/bob/devtools/data/gitlab-ci/conda-next-build.py +++ b/bob/devtools/data/gitlab-ci/conda-next-build.py @@ -94,7 +94,6 @@ def _next_build_number(channel_url, name, version, build_variant): if __name__ == "__main__": - if len(sys.argv) != 7: print(f"usage: {sys.argv[0]} group visibility tag name version variant") sys.exit(1) diff --git a/bob/devtools/data/gitlab-ci/deregister.py b/bob/devtools/data/gitlab-ci/deregister.py index 7f500b6208457792d2ca2743385166845d400cb3..da6e6593ef57ad41806071252b0af5aa5511799f 100644 --- a/bob/devtools/data/gitlab-ci/deregister.py +++ b/bob/devtools/data/gitlab-ci/deregister.py @@ -4,7 +4,6 @@ import gitlab import pkginfo if __name__ == "__main__": - if len(sys.argv) != 5: print( f"usage: {sys.argv[0]} server-url user-token project-id source-file" diff --git a/bob/devtools/dav.py b/bob/devtools/dav.py index bf8741110d8f9faed9dd2319fd369edff6b0bde1..95d8f43ab61bd680cf1aab196ccdd7ca94470f16 100644 --- a/bob/devtools/dav.py +++ b/bob/devtools/dav.py @@ -142,7 +142,6 @@ def remove_old_beta_packages(client, path, dry_run, pyver=True, includes=None): pyver_finder = re.compile("py[1-9][0-9]h.*") for f in client.list(path): - if f.startswith("."): continue diff --git a/bob/devtools/deploy.py b/bob/devtools/deploy.py index 7325a993ff2afb8ee3a9156073271015748fac87..c1850cbc0654c0bb0afcad00b375e91dc0c02404 100644 --- a/bob/devtools/deploy.py +++ b/bob/devtools/deploy.py @@ -202,7 +202,6 @@ def deploy_documentation( if __name__ == "__main__": - import argparse parser = argparse.ArgumentParser( diff --git a/bob/devtools/graph.py b/bob/devtools/graph.py index b2514df832ed7dd02fd81aeccc583e0bcac14900..8e4286c54987f2d73732aa820b8b4dd9b1240013 100644 --- a/bob/devtools/graph.py +++ b/bob/devtools/graph.py @@ -100,7 +100,6 @@ def compute_adjencence_matrix( % (use_package.attributes["path_with_namespace"], ref) ) with tempfile.TemporaryDirectory() as tmpdir: - logger.debug("Downloading archive for %s...", ref) archive = use_package.repository_archive(ref=ref) # in memory logger.debug("Archive has %d bytes", len(archive)) @@ -281,7 +280,6 @@ def generate_graph(adjacence_matrix, deptypes, whitelist): # generates nodes for all dependencies for package, values in adjacence_matrix.items(): - # ensures we only have the most complete dependence in the our list deps = {} to_consider = set() diff --git a/bob/devtools/mirror.py b/bob/devtools/mirror.py index 2756e2b751c5e46b2da8909d89cc36c9e701c3b5..ce97532b8413e40d4aea55fb6bc9df13b21e4a86 100644 --- a/bob/devtools/mirror.py +++ b/bob/devtools/mirror.py @@ -214,10 +214,8 @@ def download_packages(packages, repodata, channel_url, dest_dir, arch, dry_run): # download files into temporary directory, that is removed by the end of # the procedure, or if something bad occurs with tempfile.TemporaryDirectory() as download_dir: - total = len(packages) for k, p in enumerate(packages): - k += 1 # adjust to produce correct order on printouts # checksum to verify @@ -237,7 +235,6 @@ def download_packages(packages, repodata, channel_url, dest_dir, arch, dry_run): package_retries = 10 while package_retries: - if not dry_run: logger.debug("[checking: %d/%d] %s", k, total, url) r = requests.get(url, stream=True, allow_redirects=True) @@ -400,7 +397,6 @@ def checksum_packages(repodata, dest_dir, arch, packages): issues = set() total = len(packages) for k, p in enumerate(packages): - path_to_package = os.path.join(dest_dir, arch, p) # checksum to verify diff --git a/bob/devtools/pipelines.py b/bob/devtools/pipelines.py index 230b5c468e1dc724edd41059bd66e39d4c616348..417cc45fd7bc16922f598d62bba09c1497d4afe4 100644 --- a/bob/devtools/pipelines.py +++ b/bob/devtools/pipelines.py @@ -19,7 +19,6 @@ def process_log(log): logs = dict() dates = [] for ll in log: - # Check which package are we if len(re.findall("Building bob/[a-z]*", ll)) > 0: logs[current_package] = dates diff --git a/bob/devtools/release.py b/bob/devtools/release.py index 866060fe369b8c35b1992acf7d771b41f0e0cdc5..576ee1bb0bdf78e2276c65eaea0f65713308d263 100644 --- a/bob/devtools/release.py +++ b/bob/devtools/release.py @@ -173,7 +173,6 @@ def get_parsed_tag(gitpkg, tag): # if we bump the version, we need to find the latest released version for # this package if tag in ("major", "minor", "patch"): - # find the correct latest tag of this package (without 'v' in front), # None if there are no tags yet latest_tag_name = get_latest_tag_name(gitpkg) @@ -454,7 +453,6 @@ def wait_for_pipeline_to_finish(gitpkg, pipeline_id, dry_run=False): slept_so_far = 0 while pipeline.status == "running" or pipeline.status == "pending": - time.sleep(sleep_step) slept_so_far += sleep_step if slept_so_far > max_sleep: diff --git a/bob/devtools/scripts/alternative_nightlies.py b/bob/devtools/scripts/alternative_nightlies.py index e52e47baf6abd0af59b930a440766d5cc0252a72..31d043ea0c88da000dfc5d0dd88b49feb03612d4 100644 --- a/bob/devtools/scripts/alternative_nightlies.py +++ b/bob/devtools/scripts/alternative_nightlies.py @@ -54,7 +54,6 @@ def alt_nightlies(order, variables): packages = read_packages(order) for n, (package, branch) in enumerate(packages): - # trigger a pipeline for package and branch project = gl.projects.get(package) logger.info( diff --git a/bob/devtools/scripts/build.py b/bob/devtools/scripts/build.py index 13f91d32284c69ba94cdcd0234ea673bce9b40e2..c0d0cf0c7ad5dab6acf472091a86f826140daa1c 100644 --- a/bob/devtools/scripts/build.py +++ b/bob/devtools/scripts/build.py @@ -243,7 +243,6 @@ def build( arch = conda_arch() for d in recipe_dir: - if not os.path.exists(d): raise RuntimeError("The directory %s does not exist" % d) diff --git a/bob/devtools/scripts/changelog.py b/bob/devtools/scripts/changelog.py index 13be66daba0a32e63d90da63f2713c849b25f812..340572dace441fe09076f0f016c149089399a97e 100644 --- a/bob/devtools/scripts/changelog.py +++ b/bob/devtools/scripts/changelog.py @@ -149,7 +149,6 @@ def changelog(target, changelog, group, mode, since): # iterates over the packages and dumps required information for package in packages: - if "/" not in package: package = "/".join((group, package)) diff --git a/bob/devtools/scripts/ci.py b/bob/devtools/scripts/ci.py index 5f64674814cb067570dec3c2087392df97c8b854..829bde43dcee12ef61742980460a169c0341a006 100644 --- a/bob/devtools/scripts/ci.py +++ b/bob/devtools/scripts/ci.py @@ -102,7 +102,6 @@ def base_deploy(dry_run): deploy_packages = glob.glob(conda_paths) + glob.glob(tarbz2_paths) for k in deploy_packages: - if os.path.basename(k).startswith(name): logger.debug("Skipping deploying of %s - not a base package", k) continue @@ -247,7 +246,6 @@ def readme(package): """ for k in package: - logger.info("Checking python package %s", k) # twine check dist/*.zip @@ -328,7 +326,6 @@ def pypi(package, dry_run): from twine.commands.upload import upload for k in package: - logger.info("Deploying python package %s to PyPI", k) upload(settings, [k]) logger.info("%s: Deployed to PyPI - OK", k) @@ -677,7 +674,6 @@ def nightlies(ctx, order, dry_run): # loaded all recipes, now cycle through them implementing what is described # in the documentation of this function for n, (package, branch) in enumerate(packages): - echo_normal("\n" + (80 * "=")) echo_normal( "Building %s@%s (%d/%d)" % (package, branch, n + 1, len(packages)) @@ -841,7 +837,6 @@ def docs(ctx, requirement, dry_run): doc_path = os.path.join(os.environ["CI_PROJECT_DIR"], "doc") for n, (package, branch) in enumerate(packages): - group, name = package.split("/", 1) clone_to = os.path.join(doc_path, group, name) @@ -919,7 +914,6 @@ def docs(ctx, requirement, dry_run): # Making unique lists and removing all bob/beat references if not dry_run: - # extra requirements for sphinx group = os.environ["CI_PROJECT_NAMESPACE"] extra_intersphinx = set( diff --git a/bob/devtools/scripts/common_options.py b/bob/devtools/scripts/common_options.py index df211a09622cfbedb3f50a38091125748c0e68f2..397d2741f0ac2f8df828854083cb3e4dc7de7e8f 100644 --- a/bob/devtools/scripts/common_options.py +++ b/bob/devtools/scripts/common_options.py @@ -5,7 +5,6 @@ def ref_option(**kwargs): """An option for getting branch name.""" def custom_ref_option(func): - return click.option( "-r", "--ref", diff --git a/bob/devtools/scripts/dav.py b/bob/devtools/scripts/dav.py index a7f005056f87ed10b6f408fcd231a04ca210adfe..2aed581cb9368cf3de97750affece518c4ea5da3 100644 --- a/bob/devtools/scripts/dav.py +++ b/bob/devtools/scripts/dav.py @@ -277,7 +277,6 @@ def upload(private, execute, checksum, local, remote): return 1 for k in local: - if not os.path.isdir(k): path_with_hash = k if checksum: @@ -405,7 +404,6 @@ def clean_betas(private, execute, path): ] for arch in archs: - arch_path = "/".join((path, arch)) if not (cl.check(arch_path) and cl.is_dir(arch_path)): diff --git a/bob/devtools/scripts/development.py b/bob/devtools/scripts/development.py index 01012a97e774acc21438b8a768b6deb6e31a808e..b5f540a0997cac1195816031b4c48eecb836a206 100644 --- a/bob/devtools/scripts/development.py +++ b/bob/devtools/scripts/development.py @@ -25,7 +25,6 @@ def install(env_name, folders): import subprocess for folder in folders: - # call pip cmd = [ "conda", @@ -65,7 +64,6 @@ def checkout(ctx, names, use_https, subfolder): os.makedirs(subfolder, exist_ok=True) for name in names: - # call git # skip if the directory already exists dest = name @@ -73,7 +71,6 @@ def checkout(ctx, names, use_https, subfolder): dest = os.path.join(subfolder, name) if not os.path.isdir(dest): - url = f"git@gitlab.idiap.ch:bob/{name}.git" if use_https: url = f"https://gitlab.idiap.ch/bob/{name}.git" diff --git a/bob/devtools/scripts/mirror.py b/bob/devtools/scripts/mirror.py index 90236bc838ad6fda81f66059356d87a41e9c375b..7fcfed627e6c5abc45cb2b556d02f4b2888b5f94 100644 --- a/bob/devtools/scripts/mirror.py +++ b/bob/devtools/scripts/mirror.py @@ -192,7 +192,6 @@ def mirror( start_date = start_date.date() # only interested on the day itself for arch in DEFAULT_SUBDIRS: - try: remote_repodata = get_json( channel_url, arch, "repodata_from_packages.json.bz2" diff --git a/bob/devtools/scripts/rebuild.py b/bob/devtools/scripts/rebuild.py index 17987f9696807e15f0fcd46dee08da5a081f8ff6..4a201452576068640d1aef596364bbf3100c2554 100644 --- a/bob/devtools/scripts/rebuild.py +++ b/bob/devtools/scripts/rebuild.py @@ -235,7 +235,6 @@ def rebuild( arch = conda_arch() for d in recipe_dir: - if not os.path.exists(d): raise RuntimeError("The directory %s does not exist" % recipe_dir) @@ -268,7 +267,6 @@ def rebuild( if ( existing ): # other builds exist, get the latest and see if it still works - destpath = os.path.join( condarc_options["croot"], arch, os.path.basename(existing[0]) ) @@ -300,7 +298,6 @@ def rebuild( logger.info("Test for %s: SUCCESS (package is up-to-date)", src) if should_build: # something wrong happened, run a full build - logger.info( "Re-building %s-%s-py%s (build: %d) for %s", rendered_recipe["package"]["name"], diff --git a/bob/devtools/scripts/release.py b/bob/devtools/scripts/release.py index a6c5348011f9547203e2167fa3048b97096903c8..879bd1ff07a181afa22dafe147b3ce9a835c82f6 100644 --- a/bob/devtools/scripts/release.py +++ b/bob/devtools/scripts/release.py @@ -176,7 +176,6 @@ def release(changelog, group, package, resume, dry_run): # go through the list of packages and release them starting from the # start_idx for i in range(start_idx, len(pkgs) - 1): - cur_package_name = changelogs[pkgs[i]][1:].strip() if "/" not in cur_package_name: diff --git a/bob/devtools/scripts/runners.py b/bob/devtools/scripts/runners.py index f39e9509d48a54fcab9f00e96d6d4c86d9814103..872727cfb8fd08d2895ba44492634a5026c46c7f 100644 --- a/bob/devtools/scripts/runners.py +++ b/bob/devtools/scripts/runners.py @@ -12,7 +12,6 @@ logger = get_logger(__name__) def _get_runner_from_description(gl, descr): - # search for the runner to affect the_runner = [ k @@ -32,7 +31,6 @@ def _get_runner_from_description(gl, descr): def _get_project(gl, name): - retval = gl.projects.get(name) logger.debug( "Found gitlab project %s (id=%d)", @@ -43,7 +41,6 @@ def _get_project(gl, name): def _get_projects_from_group(gl, name): - group = gl.groups.get(name) logger.debug( "Found gitlab group %s (id=%d)", @@ -66,7 +63,6 @@ def _get_projects_from_group(gl, name): def _get_projects_from_runner(gl, runner): - the_runner = gl.runners.get(runner.id) logger.info( "Retrieving details for %d projects using runner %s (id=%d). " @@ -85,7 +81,6 @@ def _get_projects_from_runner(gl, runner): def _get_projects_from_file(gl, filename): - packages = [] with open(filename, "rt") as f: lines = [k.strip() for k in f.readlines()] @@ -150,7 +145,6 @@ def enable(name, targets, group, dry_run): packages = [] for target in targets: - if os.path.exists(target): # it is a file with project names packages += _get_projects_from_file(gl, target) @@ -161,9 +155,7 @@ def enable(name, targets, group, dry_run): packages += _get_projects_from_group(gl, target) for k in packages: - try: - logger.info( "Processing project %s (id=%d)", k.attributes["path_with_namespace"], @@ -274,7 +266,6 @@ def disable(name, targets, dry_run): for k in packages: try: - logger.info( "Processing project %s (id=%d)", k.attributes["path_with_namespace"], diff --git a/bob/devtools/scripts/settings.py b/bob/devtools/scripts/settings.py index e85174510a916868a729f304847344f15ffa06c0..d3d0f5106e1dfe80fddc061779bd7be44e048ae3 100644 --- a/bob/devtools/scripts/settings.py +++ b/bob/devtools/scripts/settings.py @@ -110,7 +110,6 @@ def settings(projects, avatar, description, group, archive, dry_run): gl_projects = [] for target in projects: - if os.path.exists(target): # it is a file with project names gl_projects += _get_projects_from_file(gl, target) @@ -121,9 +120,7 @@ def settings(projects, avatar, description, group, archive, dry_run): gl_projects += _get_projects_from_group(gl, target) for k in gl_projects: - try: - logger.info( "Processing project %s (id=%d)", k.attributes["path_with_namespace"], diff --git a/bob/devtools/scripts/update_bob.py b/bob/devtools/scripts/update_bob.py index 7902a815a49d93ab7dd1653dd1e5281ec186e3a0..177376a0cd93ecc1179c06b233ba193ba9aa0b9b 100644 --- a/bob/devtools/scripts/update_bob.py +++ b/bob/devtools/scripts/update_bob.py @@ -45,7 +45,6 @@ def update_bob(stable): # find the list of public packages public_packages, private_packages = [], [] for n, (package, branch) in enumerate(packages): - if package == "bob/bob": continue diff --git a/bob/devtools/scripts/visibility.py b/bob/devtools/scripts/visibility.py index 54edfc446e28826c9b6c33e5091c895585a5150c..1062b23ed752165ec72ca4ff8a8cb7b36a519b8a 100644 --- a/bob/devtools/scripts/visibility.py +++ b/bob/devtools/scripts/visibility.py @@ -68,7 +68,6 @@ def visibility(target, group): # iterates over the packages and dumps required information for package in packages: - if "/" not in package: package = "/".join((group, package)) diff --git a/bob/devtools/test_ci.py b/bob/devtools/test_ci.py index cc0ff5bb70fdceaf86b0a2d5d890a3c2920f434f..ec8e2a7ab6638618e084d1fa33105a0a8c207ffa 100644 --- a/bob/devtools/test_ci.py +++ b/bob/devtools/test_ci.py @@ -7,13 +7,11 @@ from .constants import BOBRC_PATH def test_is_private(): - base_url = "https://gitlab.idiap.ch" assert not is_private(base_url, "bob/bob.extension") assert is_private(base_url, "bob/private") def test_bobrc_json_validity(): - with open(BOBRC_PATH) as f: json.load(f) diff --git a/deps/bob-devel/run_test.py b/deps/bob-devel/run_test.py index 1f0098f7488339391b68417d35744d83725aa5dc..c45f081a5b8438d36f39f15dddf621b5ff551820 100644 --- a/deps/bob-devel/run_test.py +++ b/deps/bob-devel/run_test.py @@ -25,7 +25,6 @@ def _check_package(name, pyname=None): def test_setuptools_integrity(): - _check_package("pytorch", "torch") _check_package("torchvision")