From 94db1e1107b062f8851be28faa0884e22c9487e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 22 Oct 2022 11:03:53 +0200 Subject: [PATCH] Check whether up to date after figuring latest version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, on a standard Python update: ``` $ time bin/dry-run.rb pip LeeeeT/valtypes --cache files To use retry middleware with Faraday v2.0+, install `faraday-retry` gem => reading dependency files from cache manifest: ./dry-run/LeeeeT/valtypes/cache-manifest-pip.json => parsing dependency files => updating 11 dependencies: pre-commit, isort, sort-all, black, pyproject-flake8, mypy, pyright, pytest, pytest-cov, mkdocs-material, jinja2 === pre-commit () => checking for updates 1/11 🌍 https://pypi.org/simple/pre-commit/ => latest available version is 2.20.0 => latest allowed version is 2.20.0 (no update needed as it's already up-to-date) (...) === jinja2 (3.1.0) => checking for updates 11/11 🌍 https://pypi.org/simple/jinja2/ => latest available version is 3.1.2 🌍 https://pypi.org/simple/jinja2/ => latest allowed version is 3.1.2 => requirements to unlock: own => requirements update strategy: bump_versions => updating jinja2 from 3.1.0 to 3.1.2 ± docs/requirements.txt ~~~ 2c2 < Jinja2==3.1.0 --- > Jinja2==3.1.2 ~~~ 🌍 Total requests made: '24' real 1m0.863s user 0m35.599s sys 0m7.230s ``` After this change: ``` $ time bin/dry-run.rb pip LeeeeT/valtypes --cache files To use retry middleware with Faraday v2.0+, install `faraday-retry` gem => reading dependency files from cache manifest: ./dry-run/LeeeeT/valtypes/cache-manifest-pip.json => parsing dependency files => updating 11 dependencies: pre-commit, isort, sort-all, black, pyproject-flake8, mypy, pyright, pytest, pytest-cov, mkdocs-material, jinja2 === pre-commit () => checking for updates 1/11 🌍 https://pypi.org/simple/pre-commit/ => latest available version is 2.20.0 (no update needed as it's already up-to-date) (...) === jinja2 (3.1.0) => checking for updates 11/11 🌍 https://pypi.org/simple/jinja2/ => latest available version is 3.1.2 🌍 https://pypi.org/simple/jinja2/ => latest allowed version is 3.1.2 => requirements to unlock: own => requirements update strategy: bump_versions => updating jinja2 from 3.1.0 to 3.1.2 ± docs/requirements.txt ~~~ 2c2 < Jinja2==3.1.0 --- > Jinja2==3.1.2 ~~~ 🌍 Total requests made: '24' real 0m27.956s user 0m9.490s sys 0m3.146s ``` So, more than 50% speed up. And I think this also matches more closely what the real updater does. Co-authored-by: Jeroen Bobbeldijk --- bin/dry-run.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/dry-run.rb b/bin/dry-run.rb index 811b5ed9087..76075daec3b 100755 --- a/bin/dry-run.rb +++ b/bin/dry-run.rb @@ -679,6 +679,11 @@ def security_fix?(dependency) next end + if checker.up_to_date? + puts " (no update needed as it's already up-to-date)" + next + end + if checker.vulnerable? if checker.lowest_security_fix_version puts " => earliest available non-vulnerable version is " \ @@ -695,11 +700,6 @@ def security_fix?(dependency) end puts " => latest allowed version is #{latest_allowed_version || dep.version}" - if checker.up_to_date? - puts " (no update needed as it's already up-to-date)" - next - end - requirements_to_unlock = if $options[:lockfile_only] || !checker.requirements_unlocked_or_can_be? if checker.can_update?(requirements_to_unlock: :none) then :none