From feb6a23bfb98cc311853e87f98f1e9bde05e0285 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Mon, 19 Jan 2026 15:02:44 -0800 Subject: [PATCH 1/6] Tests --- azure-pipelines.yml | 4 +-- .../run_integration_tests.py | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9fb3e0d6e3..20ed8863fb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,7 +14,7 @@ resources: - repository: templates type: github name: shotgunsoftware/tk-ci-tools - ref: refs/heads/master + ref: refs/heads/ticket/SG-38126-review-and-fixup-code-coverage endpoint: shotgunsoftware # We want builds to trigger for 3 reasons: @@ -24,7 +24,7 @@ resources: trigger: branches: include: - - master + - "*" tags: include: - v* diff --git a/tests/integration_tests/run_integration_tests.py b/tests/integration_tests/run_integration_tests.py index 966b2283b4..7394eab059 100755 --- a/tests/integration_tests/run_integration_tests.py +++ b/tests/integration_tests/run_integration_tests.py @@ -20,6 +20,7 @@ import subprocess import sys import time +import uuid def main(): @@ -60,21 +61,30 @@ def main(): if filename.endswith(current_file): continue + uid = uuid.uuid4() + print("=" * 79) print("Running %s" % os.path.basename(filename)) print("=" * 79) + args = [ + sys.executable, + "-m", + ] + if "SHOTGUN_TEST_COVERAGE" in os.environ: - args = [ - sys.executable, - "-m", + args.extend([ "coverage", "run", - "--parallel-mode", - filename, - ] - else: - args = [sys.executable, filename] + f"--data-file=.coverage.{uid}", + ]) + + args.extend([ + "pytest", + filename, + f"--nunit-xml=test-results-{uid}.xml", + "--verbose", + ]) subprocess.check_call(args, env=environ) From caf640acda834a70a9f1540169acee8104319ea7 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Mon, 19 Jan 2026 16:48:52 -0800 Subject: [PATCH 2/6] fixup! Tests --- tests/integration_tests/run_integration_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration_tests/run_integration_tests.py b/tests/integration_tests/run_integration_tests.py index 7394eab059..aadde2a23a 100755 --- a/tests/integration_tests/run_integration_tests.py +++ b/tests/integration_tests/run_integration_tests.py @@ -77,6 +77,7 @@ def main(): "coverage", "run", f"--data-file=.coverage.{uid}", + "-m", ]) args.extend([ From 5cfc34c797df04d298a121a970851d2d33e60054 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Mon, 19 Jan 2026 17:21:40 -0800 Subject: [PATCH 3/6] tests --- .../run_integration_tests.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/integration_tests/run_integration_tests.py b/tests/integration_tests/run_integration_tests.py index aadde2a23a..d1ea787ba0 100755 --- a/tests/integration_tests/run_integration_tests.py +++ b/tests/integration_tests/run_integration_tests.py @@ -37,9 +37,9 @@ def main(): os.path.join(current_folder, "..", "..", "python"), ] ) - environ["SHOTGUN_SCRIPT_NAME"] = os.environ.get("SHOTGUN_SCRIPT_NAME") - environ["SHOTGUN_SCRIPT_KEY"] = os.environ.get("SHOTGUN_SCRIPT_KEY") - environ["SHOTGUN_HOST"] = os.environ.get("SHOTGUN_HOST") + # environ["SHOTGUN_SCRIPT_NAME"] = os.environ.get("SHOTGUN_SCRIPT_NAME") ### USELESS........ + # environ["SHOTGUN_SCRIPT_KEY"] = os.environ.get("SHOTGUN_SCRIPT_KEY") + # environ["SHOTGUN_HOST"] = os.environ.get("SHOTGUN_HOST") current_folder, current_file = os.path.split(__file__) @@ -70,22 +70,15 @@ def main(): args = [ sys.executable, "-m", - ] - - if "SHOTGUN_TEST_COVERAGE" in os.environ: - args.extend([ - "coverage", - "run", - f"--data-file=.coverage.{uid}", - "-m", - ]) - - args.extend([ "pytest", filename, f"--nunit-xml=test-results-{uid}.xml", "--verbose", - ]) + ] + + if "SHOTGUN_TEST_COVERAGE" in os.environ: + args.append("--cov") + environ["COVERAGE_FILE"] = f".coverage.{uid}" subprocess.check_call(args, env=environ) From 6810aba6b1bc65ec97b3af5e9c784b6f3c49e66f Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Mon, 19 Jan 2026 17:22:39 -0800 Subject: [PATCH 4/6] Black --- .pre-commit-config.yaml | 4 ++-- developer/bake_config.py | 6 ++---- developer/build_plugin.py | 8 +++----- developer/populate_bundle_cache.py | 6 ++---- developer/utils/authentication.py | 1 - hooks/context_additional_entities.py | 1 + hooks/default_storage_root.py | 1 + scripts/tank_cmd.py | 6 +++--- setup/tank_api_proxy/sgtk/__init__.py | 1 - setup/tank_api_proxy/tank/__init__.py | 1 - 10 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21e91f93cb..a72355e584 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ exclude: "tank_vendor|third_party|ui\/.*py$|\/.*png|\/.*pickle|test_post_update_ # List of super useful formatters. repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: # Ensures the code is syntaxically correct - id: check-ast @@ -54,7 +54,7 @@ repos: exclude: "scripts\/tank_cmd.bat|setup\/root_binaries\/tank.bat" # Leave black at the bottom so all touchups are done before it is run. - repo: https://github.com/psf/black - rev: 25.1.0 + rev: 26.1.0 hooks: - id: black exclude: "tests|python\/tank" diff --git a/developer/bake_config.py b/developer/bake_config.py index 93183bae55..a2a7c4613b 100644 --- a/developer/bake_config.py +++ b/developer/bake_config.py @@ -217,9 +217,7 @@ def main(): http://developer.shotgridsoftware.com/tk-core/descriptor -""".format( - automated_setup_documentation=automated_setup_documentation - ).format( +""".format(automated_setup_documentation=automated_setup_documentation).format( script_name="bake_config.py" ) parser = OptionParserLineBreakingEpilog( @@ -246,7 +244,7 @@ def main(): add_authentication_options(parser) # parse cmd line - (options, remaining_args) = parser.parse_args() + options, remaining_args = parser.parse_args() logger.info("Welcome to the Toolkit config baker.") logger.info("") diff --git a/developer/build_plugin.py b/developer/build_plugin.py index d9d8e4498d..d821339946 100644 --- a/developer/build_plugin.py +++ b/developer/build_plugin.py @@ -559,7 +559,7 @@ def build_plugin( # uri to use at runtime - in the case of baked descriptors, the config_uri_str # contains a manual descriptor uri and install_path is set with the baked # folder. - (cfg_descriptor, config_uri_str, install_path) = _process_configuration( + cfg_descriptor, config_uri_str, install_path = _process_configuration( sg_connection, source_path, target_path, @@ -728,9 +728,7 @@ def main(): http://developer.shotgridsoftware.com/tk-core/descriptor -""".format( - automated_setup_documentation=automated_setup_documentation - ).format( +""".format(automated_setup_documentation=automated_setup_documentation).format( script_name="build_plugin.py" ) parser = OptionParserLineBreakingEpilog( @@ -769,7 +767,7 @@ def main(): add_authentication_options(parser) # parse cmd line - (options, remaining_args) = parser.parse_args() + options, remaining_args = parser.parse_args() logger.info("Welcome to the Toolkit plugin builder.") logger.info("") diff --git a/developer/populate_bundle_cache.py b/developer/populate_bundle_cache.py index 8cbe3320e1..80f6adef65 100644 --- a/developer/populate_bundle_cache.py +++ b/developer/populate_bundle_cache.py @@ -147,9 +147,7 @@ def main(): http://developer.shotgridsoftware.com/tk-core/descriptor -""".format( - automated_setup_documentation=automated_setup_documentation - ).format( +""".format(automated_setup_documentation=automated_setup_documentation).format( script_name="populate_bundle_cache.py" ) parser = OptionParserLineBreakingEpilog( @@ -163,7 +161,7 @@ def main(): add_authentication_options(parser) # parse cmd line - (options, remaining_args) = parser.parse_args() + options, remaining_args = parser.parse_args() logger.info("Welcome to the Toolkit bundle cache builder.") logger.info("") diff --git a/developer/utils/authentication.py b/developer/utils/authentication.py index 82da569c16..60743fc158 100644 --- a/developer/utils/authentication.py +++ b/developer/utils/authentication.py @@ -14,7 +14,6 @@ from tank import LogManager from tank.authentication import ShotgunAuthenticator - logger = LogManager.get_logger("utils.authentication") automated_setup_documentation = """For automated build setups, you can provide a specific shotgun API script name and diff --git a/hooks/context_additional_entities.py b/hooks/context_additional_entities.py index fd32997232..912015b2d4 100644 --- a/hooks/context_additional_entities.py +++ b/hooks/context_additional_entities.py @@ -18,6 +18,7 @@ Contact support if you have any questions about how to migrate away from this hook. """ + from tank import Hook diff --git a/hooks/default_storage_root.py b/hooks/default_storage_root.py index 842cdc60f5..580c886bde 100644 --- a/hooks/default_storage_root.py +++ b/hooks/default_storage_root.py @@ -12,6 +12,7 @@ Hook that gets executed during Toolkit initialization. This hook makes it possible to modify the default storage root. """ + import sgtk from tank import Hook diff --git a/scripts/tank_cmd.py b/scripts/tank_cmd.py index bd6fc68f77..e686eea46c 100644 --- a/scripts/tank_cmd.py +++ b/scripts/tank_cmd.py @@ -840,7 +840,7 @@ def _shotgun_run_action( elif status == TankCoreUpdater.UPDATE_POSSIBLE: - (summary, url) = installer.get_release_notes() + summary, url = installer.get_release_notes() logger.info( "A new version of the Toolkit API (%s) is available!" % lv @@ -941,7 +941,7 @@ def _list_commands(tk, ctx): Outputs a list of commands to the logger given the current context. """ # get all the action objets (commands) suitable for the current context - (aa, engine) = get_actions(logger, tk, ctx) + aa, engine = get_actions(logger, tk, ctx) logger.info("") logger.info("The following commands are available:") @@ -1398,7 +1398,7 @@ def run_engine_cmd(pipeline_config_root, context_items, command, using_cwd, args entity_search_token = ":".join(entity_search_token.split(":")[1:]) # now try to resolve this project - (project_id, project_name) = _resolve_shotgun_pattern( + project_id, project_name = _resolve_shotgun_pattern( "Project", proj_token ) logger.info("- Searching in project '%s' only" % project_name) diff --git a/setup/tank_api_proxy/sgtk/__init__.py b/setup/tank_api_proxy/sgtk/__init__.py index 1ad6f55df2..d0c107d401 100644 --- a/setup/tank_api_proxy/sgtk/__init__.py +++ b/setup/tank_api_proxy/sgtk/__init__.py @@ -14,7 +14,6 @@ import os import sys - # first look for our parent file current_folder = os.path.abspath(os.path.dirname(__file__)) file_name_lookup = { diff --git a/setup/tank_api_proxy/tank/__init__.py b/setup/tank_api_proxy/tank/__init__.py index 28184c8131..a02f7590bb 100644 --- a/setup/tank_api_proxy/tank/__init__.py +++ b/setup/tank_api_proxy/tank/__init__.py @@ -14,7 +14,6 @@ import os import sys - # first look for our parent file current_folder = os.path.abspath(os.path.dirname(__file__)) file_name_lookup = { From 5d123be9942fb0f8632b152d1e9bbf1f7d4d3280 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Thu, 22 Jan 2026 15:55:45 -0800 Subject: [PATCH 5/6] Cleanup --- azure-pipelines.yml | 2 +- developer/bake_config.py | 9 ++++----- tests/integration_tests/run_integration_tests.py | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 20ed8863fb..6516a3ae92 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,7 +24,7 @@ resources: trigger: branches: include: - - "*" + - master tags: include: - v* diff --git a/developer/bake_config.py b/developer/bake_config.py index a2a7c4613b..d7aeb89a79 100644 --- a/developer/bake_config.py +++ b/developer/bake_config.py @@ -191,7 +191,7 @@ def main(): desc = "Bake a self contained Toolkit config from a descriptor" - epilog = """ + epilog = f""" Details and Examples -------------------- @@ -211,15 +211,14 @@ def main(): By default, all bundle types are cached. If you want to omit certain types, simply provide a comma seperated list of bundle types to skip, e.g. --skip-bundle-types=app_store,shotgun,github_release. -{automated_setup_documentation} +f{automated_setup_documentation} For information about the various descriptors that can be used, see http://developer.shotgridsoftware.com/tk-core/descriptor -""".format(automated_setup_documentation=automated_setup_documentation).format( - script_name="bake_config.py" - ) +""" + parser = OptionParserLineBreakingEpilog( usage=usage, description=desc, epilog=epilog ) diff --git a/tests/integration_tests/run_integration_tests.py b/tests/integration_tests/run_integration_tests.py index d1ea787ba0..281139378a 100755 --- a/tests/integration_tests/run_integration_tests.py +++ b/tests/integration_tests/run_integration_tests.py @@ -37,9 +37,6 @@ def main(): os.path.join(current_folder, "..", "..", "python"), ] ) - # environ["SHOTGUN_SCRIPT_NAME"] = os.environ.get("SHOTGUN_SCRIPT_NAME") ### USELESS........ - # environ["SHOTGUN_SCRIPT_KEY"] = os.environ.get("SHOTGUN_SCRIPT_KEY") - # environ["SHOTGUN_HOST"] = os.environ.get("SHOTGUN_HOST") current_folder, current_file = os.path.split(__file__) @@ -62,6 +59,7 @@ def main(): continue uid = uuid.uuid4() + # Defines a unique id to be used for test results and coverage files print("=" * 79) print("Running %s" % os.path.basename(filename)) From ffc33faa28cb3dd3582751f0895a45d784467a45 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 28 Jan 2026 09:18:55 -0800 Subject: [PATCH 6/6] fixup! Cleanup --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6516a3ae92..9fb3e0d6e3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,7 +14,7 @@ resources: - repository: templates type: github name: shotgunsoftware/tk-ci-tools - ref: refs/heads/ticket/SG-38126-review-and-fixup-code-coverage + ref: refs/heads/master endpoint: shotgunsoftware # We want builds to trigger for 3 reasons: