diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2023-02-25 13:02:38 +0100 |
---|---|---|
committer | Martin Weinelt <mweinelt@users.noreply.github.com> | 2023-02-27 02:21:07 +0000 |
commit | 4323150c5ca643fa117d7bf25b3a5330c770086b (patch) | |
tree | 216e5cd8998386696fa6211aa79d7de63b31d46e /pkgs/development/interpreters/python | |
parent | 0d09b95ad1b156336e566a639d085a11e18f061b (diff) | |
download | nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.tar nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.tar.gz nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.tar.bz2 nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.tar.lz nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.tar.xz nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.tar.zst nixpkgs-4323150c5ca643fa117d7bf25b3a5330c770086b.zip |
update-python-libraries: Improve code quality
- Prune unused imports - Collect imports at the top - Removed unused exception assignments - Fill bare except clause with - Expand overly long check_output lines
Diffstat (limited to 'pkgs/development/interpreters/python')
-rwxr-xr-x | pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py index d19c597f669..14b3ed4f3f1 100755 --- a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py +++ b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py @@ -13,8 +13,8 @@ to update all non-pinned libraries in that folder. import argparse import json +import logging import os -import pathlib import re import requests from concurrent.futures import ThreadPoolExecutor as Pool @@ -39,7 +39,6 @@ GIT = "git" NIXPKGS_ROOT = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).decode('utf-8').strip() -import logging logging.basicConfig(level=logging.INFO) @@ -284,13 +283,21 @@ def _get_latest_version_github(package, extension, current_version, target): hash = _hash_to_sri(algorithm, document[algorithm]) else: try: - hash = subprocess.check_output(["nix-prefetch-url", "--type", "sha256", "--unpack", f"{release['tarball_url']}"], stderr=subprocess.DEVNULL)\ - .decode('utf-8').strip() - except: + hash = subprocess.check_output([ + "nix-prefetch-url", + "--type", "sha256", + "--unpack", + f"{release['tarball_url']}" + ], stderr=subprocess.DEVNULL).decode('utf-8').strip() + except (subprocess.CalledProcessError, UnicodeError): # this may fail if they have both a branch and a tag of the same name, attempt tag name tag_url = str(release['tarball_url']).replace("tarball","tarball/refs/tags") - hash = subprocess.check_output(["nix-prefetch-url", "--type", "sha256", "--unpack", tag_url], stderr=subprocess.DEVNULL)\ - .decode('utf-8').strip() + hash = subprocess.check_output([ + "nix-prefetch-url", + "--type", "sha256", + "--unpack", + tag_url + ], stderr=subprocess.DEVNULL).decode('utf-8').strip() return version, hash, prefix @@ -337,12 +344,12 @@ def _determine_extension(text, fetcher): if fetcher == 'fetchPypi': try: src_format = _get_unique_value('format', text) - except ValueError as e: + except ValueError: src_format = None # format was not given try: extension = _get_unique_value('extension', text) - except ValueError as e: + except ValueError: extension = None # extension was not given if extension is None: |