diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15a3ecc15a5..59613c75f7f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,11 +43,10 @@ repos: files: ^devtools/ci/ args: [-e, SC1091] # don't follow sourced files - - repo: https://github.com/ambv/black - rev: 25.12.0 + - repo: https://github.com/psf/black + rev: 26.5.1 hooks: - id: black language_version: python3 exclude: "^metaflow/_vendor/" - additional_dependencies: ["click<8.1.0"] - args: [-t, py34, -t, py35, -t, py36, -t, py37, -t, py38, -t, py39, -t, py310, -t, py311, -t, py312, -t, py313, -t, py314] + args: [-t, py34, -t, py35, -t, py36, -t, py37, -t, py38, -t, py39, -t, py310, -t, py311, -t, py312, -t, py313, -t, py314, -t, py315] diff --git a/metaflow/__init__.py b/metaflow/__init__.py index 9a0b005e286..727f310851f 100644 --- a/metaflow/__init__.py +++ b/metaflow/__init__.py @@ -125,7 +125,6 @@ class and related decorators. # Decorators from .decorators import step, _import_plugin_decorators - # Parsers (for configs) for now from .plugins import _import_tl_plugins diff --git a/metaflow/cmd/configure_cmd.py b/metaflow/cmd/configure_cmd.py index d4ef1a5a541..86f15b1633a 100644 --- a/metaflow/cmd/configure_cmd.py +++ b/metaflow/cmd/configure_cmd.py @@ -11,7 +11,6 @@ from .util import echo_always, makedirs - echo = echo_always # NOTE: This code needs to be in sync with metaflow/metaflow_config.py. diff --git a/metaflow/cmd/develop/stubs.py b/metaflow/cmd/develop/stubs.py index dcabae27f27..85e3b9caebe 100644 --- a/metaflow/cmd/develop/stubs.py +++ b/metaflow/cmd/develop/stubs.py @@ -155,8 +155,7 @@ def install(ctx: Any, force: bool): mf_version, _ = get_mf_version(True) with tempfile.TemporaryDirectory() as tmp_dir: with open(os.path.join(tmp_dir, "setup.py"), "w") as f: - f.write( - f""" + f.write(f""" from setuptools import setup, find_namespace_packages setup( include_package_data=True, @@ -171,16 +170,13 @@ def install(ctx: Any, force: bool): install_requires=["metaflow=={mf_version}"], python_requires=">=3.6.1", ) - """ - ) + """) with open(os.path.join(tmp_dir, "MANIFEST.in"), "w") as f: - f.write( - """ + f.write(""" include metaflow-stubs/generated_for.txt include metaflow-stubs/py.typed global-include *.pyi - """ - ) + """) StubGenerator(os.path.join(tmp_dir, "metaflow-stubs")).write_out() diff --git a/metaflow/extension_support/__init__.py b/metaflow/extension_support/__init__.py index 5a9d49f0ece..c71b7a7d804 100644 --- a/metaflow/extension_support/__init__.py +++ b/metaflow/extension_support/__init__.py @@ -16,7 +16,6 @@ from metaflow.meta_files import read_info_file from metaflow.util import walk_without_cycles - # # This file provides the support for Metaflow's extension mechanism which allows # a Metaflow developer to extend metaflow by providing a package `metaflow_extensions`. diff --git a/metaflow/plugins/airflow/airflow_utils.py b/metaflow/plugins/airflow/airflow_utils.py index d0574ad7401..c9592a80edc 100644 --- a/metaflow/plugins/airflow/airflow_utils.py +++ b/metaflow/plugins/airflow/airflow_utils.py @@ -5,7 +5,6 @@ from collections import defaultdict from datetime import datetime, timedelta - TASK_ID_XCOM_KEY = "metaflow_task_id" FOREACH_CARDINALITY_XCOM_KEY = "metaflow_foreach_cardinality" FOREACH_XCOM_KEY = "metaflow_foreach_indexes" diff --git a/metaflow/plugins/airflow/sensors/external_task_sensor.py b/metaflow/plugins/airflow/sensors/external_task_sensor.py index 264e47f18bc..8492ea1ac67 100644 --- a/metaflow/plugins/airflow/sensors/external_task_sensor.py +++ b/metaflow/plugins/airflow/sensors/external_task_sensor.py @@ -3,7 +3,6 @@ from ..exception import AirflowException from datetime import timedelta - AIRFLOW_STATES = dict( QUEUED="queued", RUNNING="running", diff --git a/metaflow/plugins/cards/card_creator.py b/metaflow/plugins/cards/card_creator.py index 597c25096de..ee2645a7d35 100644 --- a/metaflow/plugins/cards/card_creator.py +++ b/metaflow/plugins/cards/card_creator.py @@ -7,7 +7,6 @@ from metaflow import current from typing import Callable, Tuple, Dict - ASYNC_TIMEOUT = 30 diff --git a/metaflow/plugins/datastores/azure_storage.py b/metaflow/plugins/datastores/azure_storage.py index 41609c61ee1..8cd39bde238 100644 --- a/metaflow/plugins/datastores/azure_storage.py +++ b/metaflow/plugins/datastores/azure_storage.py @@ -25,7 +25,6 @@ get_azure_blob_service_client, ) - # How many threads / connections to use per upload or download operation from metaflow.plugins.storage_executor import ( StorageExecutor, diff --git a/metaflow/plugins/datastores/s3_storage.py b/metaflow/plugins/datastores/s3_storage.py index f9aed84b369..1d186015a30 100644 --- a/metaflow/plugins/datastores/s3_storage.py +++ b/metaflow/plugins/datastores/s3_storage.py @@ -6,7 +6,6 @@ from metaflow.metaflow_config import DATASTORE_SYSROOT_S3, ARTIFACT_LOCALROOT from metaflow.datastore.datastore_storage import CloseAfterUse, DataStoreStorage - try: # python2 from urlparse import urlparse diff --git a/metaflow/plugins/datatools/s3/s3util.py b/metaflow/plugins/datatools/s3/s3util.py index 51a79787653..fc9da03ac23 100644 --- a/metaflow/plugins/datatools/s3/s3util.py +++ b/metaflow/plugins/datatools/s3/s3util.py @@ -13,7 +13,6 @@ RETRY_WARNING_THRESHOLD, ) - TEST_S3_RETRY = "TEST_S3_RETRY" in os.environ TRANSIENT_RETRY_LINE_CONTENT = "" diff --git a/metaflow/runner/click_api.py b/metaflow/runner/click_api.py index 5d3e77da4f9..32448e7675b 100644 --- a/metaflow/runner/click_api.py +++ b/metaflow/runner/click_api.py @@ -8,11 +8,9 @@ elif _py_ver >= (3, 7): from metaflow._vendor.v3_7.typeguard import TypeCheckError, check_type else: - raise RuntimeError( - """ + raise RuntimeError(""" The Metaflow Programmatic API is not supported for versions of Python less than 3.7 - """ - ) + """) import functools import importlib diff --git a/metaflow/sidecar/sidecar_worker.py b/metaflow/sidecar/sidecar_worker.py index 104a92029c0..4055912e90f 100644 --- a/metaflow/sidecar/sidecar_worker.py +++ b/metaflow/sidecar/sidecar_worker.py @@ -5,7 +5,6 @@ import traceback - # add metaflow module to python path if not already present myDir = os.path.dirname(os.path.abspath(__file__)) parentDir = os.path.split(os.path.split(myDir)[0])[0] diff --git a/metaflow/user_configs/config_options.py b/metaflow/user_configs/config_options.py index 36eaae60108..4531bc3853b 100644 --- a/metaflow/user_configs/config_options.py +++ b/metaflow/user_configs/config_options.py @@ -13,7 +13,6 @@ from ..parameters import DeployTimeField, ParameterContext, current_flow from ..util import get_username - _CONVERT_PREFIX = "@!c!@:" _DEFAULT_PREFIX = "@!d!@:" _NO_FILE = "@!n!@:" diff --git a/test/core/tests/secrets_decorator.py b/test/core/tests/secrets_decorator.py index c553c0f7ae8..25584d39850 100644 --- a/test/core/tests/secrets_decorator.py +++ b/test/core/tests/secrets_decorator.py @@ -1,6 +1,5 @@ from metaflow_test import MetaflowTest, ExpectationFailed, steps, tag - INLINE_SECRETS_VARS = [ { "type": "inline", diff --git a/test/plugins/conda/test_parsers.py b/test/plugins/conda/test_parsers.py index 9e9dd12bbdf..8ec34525be4 100644 --- a/test/plugins/conda/test_parsers.py +++ b/test/plugins/conda/test_parsers.py @@ -12,7 +12,6 @@ requirements_txt_parser, ) - # --------------------------------------------------------------------------- # requirements_txt_parser # --------------------------------------------------------------------------- diff --git a/test/unit/graph_inference/test_graph_inference.py b/test/unit/graph_inference/test_graph_inference.py index f68d6833bfb..776bd5b339d 100644 --- a/test/unit/graph_inference/test_graph_inference.py +++ b/test/unit/graph_inference/test_graph_inference.py @@ -11,7 +11,6 @@ from metaflow.events import Trigger - # --------------------------------------------------------------------------- # Custom named flow (begin/middle/finish) # --------------------------------------------------------------------------- diff --git a/test/unit/test_add_to_package.py b/test/unit/test_add_to_package.py index e6106bc1b32..d397a629f4b 100644 --- a/test/unit/test_add_to_package.py +++ b/test/unit/test_add_to_package.py @@ -19,7 +19,6 @@ ) from metaflow.packaging_sys import ContentType - # --------------------------------------------------------------------------- # Helpers # --------------------------------------------------------------------------- diff --git a/test/unit/test_artifact_serializer.py b/test/unit/test_artifact_serializer.py index 80b2c15dcb0..004ac4902b7 100644 --- a/test/unit/test_artifact_serializer.py +++ b/test/unit/test_artifact_serializer.py @@ -8,7 +8,6 @@ SerializerStore, ) - # Snapshot the registry before this module's classes are defined. Module-level # test serializers (_HighPrioritySerializer, ...) self-register at class # definition time; the module-scoped fixture below removes them at teardown so diff --git a/test/unit/test_compute_resource_attributes.py b/test/unit/test_compute_resource_attributes.py index adb21c521b5..03c02b23e9b 100644 --- a/test/unit/test_compute_resource_attributes.py +++ b/test/unit/test_compute_resource_attributes.py @@ -1,7 +1,6 @@ from collections import namedtuple from metaflow.plugins.aws.aws_utils import compute_resource_attributes - MockDeco = namedtuple("MockDeco", ["name", "attributes"]) diff --git a/test/unit/test_pickle_serializer.py b/test/unit/test_pickle_serializer.py index d08206a88dd..7dd312ec333 100644 --- a/test/unit/test_pickle_serializer.py +++ b/test/unit/test_pickle_serializer.py @@ -8,7 +8,6 @@ ) from metaflow.plugins.datastores.serializers.pickle_serializer import PickleSerializer - # --------------------------------------------------------------------------- # Registration and identity # --------------------------------------------------------------------------- diff --git a/test/ux/core/test_compliance.py b/test/ux/core/test_compliance.py index 5f2057ce4ff..99225004a48 100644 --- a/test/ux/core/test_compliance.py +++ b/test/ux/core/test_compliance.py @@ -23,7 +23,6 @@ wait_for_deployed_run_allow_failure, ) - # --------------------------------------------------------------------------- # test_run_params_multiple_values # diff --git a/test/ux/core/test_utils.py b/test/ux/core/test_utils.py index 031d25e90b0..72776bf2ada 100644 --- a/test/ux/core/test_utils.py +++ b/test/ux/core/test_utils.py @@ -5,7 +5,6 @@ from metaflow import Deployer, Flow, Run, Runner, namespace from metaflow.exception import MetaflowNotFound - # Directory containing the test flows, relative to this file _FLOWS_DIR = os.path.join(os.path.dirname(__file__), "flows")