diff --git a/databricks/sdk/config.py b/databricks/sdk/config.py index 219a115c1..2e4f00111 100644 --- a/databricks/sdk/config.py +++ b/databricks/sdk/config.py @@ -6,7 +6,7 @@ import pathlib import re import urllib.parse -from typing import Dict, Iterable, List, Optional +from typing import Any, Dict, Iterable, List, Optional import requests @@ -49,7 +49,7 @@ def __get__(self, cfg: "Config", owner): return None return cfg._inner.get(self.name, None) - def __set__(self, cfg: "Config", value: any): + def __set__(self, cfg: "Config", value: Any): cfg._inner[self.name] = self.transform(value) def __repr__(self) -> str: @@ -580,7 +580,7 @@ def debug_string(self) -> str: buf.append(f"Env: {', '.join(envs_used)}") return ". ".join(buf) - def to_dict(self) -> Dict[str, any]: + def to_dict(self) -> Dict[str, Any]: return self._inner @property @@ -713,7 +713,7 @@ def load_azure_tenant_id(self): self.azure_tenant_id = path_segments[1] logger.debug(f"Loaded tenant ID: {self.azure_tenant_id}") - def _set_inner_config(self, keyword_args: Dict[str, any]): + def _set_inner_config(self, keyword_args: Dict[str, Any]): for attr in self.attributes(): if attr.name not in keyword_args: continue diff --git a/databricks/sdk/dbutils.py b/databricks/sdk/dbutils.py index df8d3ccd5..9b178282c 100644 --- a/databricks/sdk/dbutils.py +++ b/databricks/sdk/dbutils.py @@ -188,8 +188,8 @@ def get( self, taskKey: str, key: str, - default: any = None, - debugValue: any = None, + default: Any = None, + debugValue: Any = None, ) -> None: """ Returns `debugValue` if present, throws an error otherwise as this implementation is always run outside of a job run @@ -200,7 +200,7 @@ def get( ) return debugValue - def set(self, key: str, value: any) -> None: + def set(self, key: str, value: Any) -> None: """ Sets a task value on the current task run """ diff --git a/databricks/sdk/logger/round_trip_logger.py b/databricks/sdk/logger/round_trip_logger.py index 7ff9d55c9..1b219cb4a 100644 --- a/databricks/sdk/logger/round_trip_logger.py +++ b/databricks/sdk/logger/round_trip_logger.py @@ -55,7 +55,7 @@ def generate(self) -> str: return "\n".join(sb) @staticmethod - def _mask(m: Dict[str, any]): + def _mask(m: Dict[str, Any]): for k in m: if k in { "bytes_value", @@ -67,7 +67,7 @@ def _mask(m: Dict[str, any]): m[k] = "**REDACTED**" @staticmethod - def _map_keys(m: Dict[str, any]) -> List[str]: + def _map_keys(m: Dict[str, Any]) -> List[str]: keys = list(m.keys()) keys.sort() return keys diff --git a/databricks/sdk/oauth.py b/databricks/sdk/oauth.py index e5d034ae2..47f2f5ef8 100644 --- a/databricks/sdk/oauth.py +++ b/databricks/sdk/oauth.py @@ -789,7 +789,7 @@ def from_host( from .credentials_provider import credentials_strategy @credentials_strategy("noop", []) - def noop_credentials(_: any): + def noop_credentials(_: Any): return lambda: {} config = Config(host=host, credentials_strategy=noop_credentials) diff --git a/databricks/sdk/runtime/dbutils_stub.py b/databricks/sdk/runtime/dbutils_stub.py index 47eb6eca7..5df705aad 100644 --- a/databricks/sdk/runtime/dbutils_stub.py +++ b/databricks/sdk/runtime/dbutils_stub.py @@ -55,7 +55,7 @@ class data: """ @staticmethod - def summarize(df: any, precise: bool = False) -> None: + def summarize(df: typing.Any, precise: bool = False) -> None: """Summarize a Spark/pandas/Koalas DataFrame and visualize the statistics to get quick insights. Example: dbutils.data.summarize(df) @@ -198,8 +198,8 @@ class taskValues: def get( taskKey: str, key: str, - default: any = None, - debugValue: any = None, + default: Any = None, + debugValue: Any = None, ) -> None: """ Returns the latest task value that belongs to the current job run @@ -207,7 +207,7 @@ def get( ... @staticmethod - def set(key: str, value: any) -> None: + def set(key: str, value: Any) -> None: """ Sets a task value on the current task run """ diff --git a/databricks/sdk/service/_internal.py b/databricks/sdk/service/_internal.py index 2800293b0..d27f0b77f 100644 --- a/databricks/sdk/service/_internal.py +++ b/databricks/sdk/service/_internal.py @@ -1,6 +1,6 @@ import datetime import urllib.parse -from typing import Callable, Dict, Generic, List, Optional, Type, TypeVar +from typing import Any, Callable, Dict, Generic, List, Optional, Type, TypeVar from google.protobuf.duration_pb2 import Duration from google.protobuf.timestamp_pb2 import Timestamp @@ -8,13 +8,13 @@ from databricks.sdk.common.types.fieldmask import FieldMask -def _from_dict(d: Dict[str, any], field: str, cls: Type) -> any: +def _from_dict(d: Dict[str, Any], field: str, cls: Type) -> Any: if field not in d or d[field] is None: return None return getattr(cls, "from_dict")(d[field]) -def _repeated_dict(d: Dict[str, any], field: str, cls: Type) -> any: +def _repeated_dict(d: Dict[str, Any], field: str, cls: Type) -> Any: if field not in d or not d[field]: return [] from_dict = getattr(cls, "from_dict") @@ -28,14 +28,14 @@ def _get_enum_value(cls: Type, value: str) -> Optional[Type]: ) -def _enum(d: Dict[str, any], field: str, cls: Type) -> any: +def _enum(d: Dict[str, Any], field: str, cls: Type) -> Any: """Unknown enum values are returned as None.""" if field not in d or not d[field]: return None return _get_enum_value(cls, d[field]) -def _repeated_enum(d: Dict[str, any], field: str, cls: Type) -> any: +def _repeated_enum(d: Dict[str, Any], field: str, cls: Type) -> Any: """For now, unknown enum values are not included in the response.""" if field not in d or not d[field]: return None @@ -51,7 +51,7 @@ def _escape_multi_segment_path_parameter(param: str) -> str: return urllib.parse.quote(param) -def _timestamp(d: Dict[str, any], field: str) -> Optional[Timestamp]: +def _timestamp(d: Dict[str, Any], field: str) -> Optional[Timestamp]: """ Helper function to convert a timestamp string to a Timestamp object. It takes a dictionary and a field name, and returns a Timestamp object. @@ -64,7 +64,7 @@ def _timestamp(d: Dict[str, any], field: str) -> Optional[Timestamp]: return ts -def _repeated_timestamp(d: Dict[str, any], field: str) -> Optional[List[Timestamp]]: +def _repeated_timestamp(d: Dict[str, Any], field: str) -> Optional[List[Timestamp]]: """ Helper function to convert a list of timestamp strings to a list of Timestamp objects. It takes a dictionary and a field name, and returns a list of Timestamp objects. @@ -80,7 +80,7 @@ def _repeated_timestamp(d: Dict[str, any], field: str) -> Optional[List[Timestam return result -def _duration(d: Dict[str, any], field: str) -> Optional[Duration]: +def _duration(d: Dict[str, Any], field: str) -> Optional[Duration]: """ Helper function to convert a duration string to a Duration object. It takes a dictionary and a field name, and returns a Duration object. @@ -93,7 +93,7 @@ def _duration(d: Dict[str, any], field: str) -> Optional[Duration]: return dur -def _repeated_duration(d: Dict[str, any], field: str) -> Optional[List[Duration]]: +def _repeated_duration(d: Dict[str, Any], field: str) -> Optional[List[Duration]]: """ Helper function to convert a list of duration strings to a list of Duration objects. It takes a dictionary and a field name, and returns a list of Duration objects. @@ -109,7 +109,7 @@ def _repeated_duration(d: Dict[str, any], field: str) -> Optional[List[Duration] return result -def _fieldmask(d: Dict[str, any], field: str) -> Optional[FieldMask]: +def _fieldmask(d: Dict[str, Any], field: str) -> Optional[FieldMask]: """ Helper function to convert a fieldmask string to a FieldMask object. It takes a dictionary and a field name, and returns a FieldMask object. @@ -122,7 +122,7 @@ def _fieldmask(d: Dict[str, any], field: str) -> Optional[FieldMask]: return fm -def _repeated_fieldmask(d: Dict[str, any], field: str) -> Optional[List[FieldMask]]: +def _repeated_fieldmask(d: Dict[str, Any], field: str) -> Optional[List[FieldMask]]: """ Helper function to convert a list of fieldmask strings to a list of FieldMask objects. It takes a dictionary and a field name, and returns a list of FieldMask objects. @@ -142,13 +142,13 @@ def _repeated_fieldmask(d: Dict[str, any], field: str) -> Optional[List[FieldMas class Wait(Generic[ReturnType]): - def __init__(self, waiter: Callable, response: any = None, **kwargs) -> None: + def __init__(self, waiter: Callable, response: Any = None, **kwargs) -> None: self.response = response self._waiter = waiter self._bind = kwargs - def __getattr__(self, key) -> any: + def __getattr__(self, key) -> Any: return self._bind[key] def bind(self) -> dict: diff --git a/databricks/sdk/service/aisearch.py b/databricks/sdk/service/aisearch.py index 1b9716a8b..0fd7f18ca 100644 --- a/databricks/sdk/service/aisearch.py +++ b/databricks/sdk/service/aisearch.py @@ -702,7 +702,7 @@ class EndpointType(Enum): class FacetResultData: """Facet aggregation rows returned by a query.""" - facet_array: Optional[List[List[any]]] = None + facet_array: Optional[List[List[Any]]] = None """Facet rows; each row is ``[facet_column_name, value_or_range, count]``.""" facet_row_count: Optional[int] = None @@ -1161,7 +1161,7 @@ def from_dict(cls, d: Dict[str, Any]) -> RerankerConfigRerankerParameters: class ResultData: """The rows of a query result set.""" - data_array: Optional[List[List[any]]] = None + data_array: Optional[List[List[Any]]] = None """Result rows; each row is a list of column values aligned with the manifest columns.""" row_count: Optional[int] = None @@ -1256,7 +1256,7 @@ class ScalingChangeState(Enum): class ScanIndexResponse: """Response for ScanIndex carrying a page of rows and an optional continuation token.""" - data: Optional[List[Dict[str, any]]] = None + data: Optional[List[Dict[str, Any]]] = None """The rows in this page, each a struct of column name to value.""" next_page_token: Optional[str] = None diff --git a/databricks/sdk/service/bundle.py b/databricks/sdk/service/bundle.py index ebc19fb5f..e41b4f759 100644 --- a/databricks/sdk/service/bundle.py +++ b/databricks/sdk/service/bundle.py @@ -387,7 +387,7 @@ class Operation: """The type of the deployment resource this operation applies to. Derived from the `resource_key` prefix (e.g. "jobs" → JOB); the caller does not set this field.""" - state: Optional[any] = None + state: Optional[Any] = None """Serialized local config state after the operation. Should be unset for delete operations.""" def as_dict(self) -> dict: @@ -497,7 +497,7 @@ class Resource: """Resource identifier within the bundle (e.g. "jobs.foo", "pipelines.bar", "jobs.foo.permissions").""" - state: Optional[any] = None + state: Optional[Any] = None """Serialized local config state (what the CLI deployed).""" def as_dict(self) -> dict: diff --git a/databricks/sdk/service/bundledeployments.py b/databricks/sdk/service/bundledeployments.py index a2e9ee1be..24f667b78 100644 --- a/databricks/sdk/service/bundledeployments.py +++ b/databricks/sdk/service/bundledeployments.py @@ -469,7 +469,7 @@ class Operation: """The type of the deployment resource this operation applies to. Derived from the ``resource_key`` prefix (e.g. "jobs" → JOB); the caller does not set this field.""" - state: Optional[any] = None + state: Optional[Any] = None """Serialized local config state after the operation. Should be unset for delete operations. Mutable: may be updated after creation via UpdateOperation. When updating, the caller must echo the last-observed ``sequence_id`` as a concurrency precondition.""" @@ -581,7 +581,7 @@ class Resource: """Resource identifier within the bundle (e.g. "jobs.foo", "pipelines.bar", "jobs.foo.permissions").""" - state: Optional[any] = None + state: Optional[Any] = None """Serialized local config state (what the CLI deployed).""" update_time: Optional[Timestamp] = None diff --git a/databricks/sdk/service/serving.py b/databricks/sdk/service/serving.py index 02f994f3d..992413845 100644 --- a/databricks/sdk/service/serving.py +++ b/databricks/sdk/service/serving.py @@ -2357,7 +2357,7 @@ class QueryEndpointResponse: """The type of object returned by the **external/foundation model** serving endpoint, one of [text_completion, chat.completion, list (of embeddings)].""" - outputs: Optional[List[any]] = None + outputs: Optional[List[Any]] = None """The outputs of the feature serving endpoint.""" predictions: Optional[List[Any]] = None diff --git a/docs/gen-client-docs.py b/docs/gen-client-docs.py index 0bc95398b..8e3f0fab9 100644 --- a/docs/gen-client-docs.py +++ b/docs/gen-client-docs.py @@ -457,7 +457,7 @@ def _write_client_package_doc(self, folder: str, pkg: Package, services: list[st if __name__ == '__main__': @credentials_strategy('noop', []) - def noop_credentials(_: any): + def noop_credentials(_: Any): return lambda: {} gen = Generator() diff --git a/tests/conftest.py b/tests/conftest.py index 7025c4395..d34b8621d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ import functools import os import platform +from typing import Any import pytest as pytest from pyfakefs.fake_filesystem_unittest import Patcher @@ -22,7 +23,7 @@ def stub_host_metadata(mocker): @credentials_strategy("noop", []) -def noop_credentials(_: any): +def noop_credentials(_: Any): return lambda: {} diff --git a/tests/databricks/sdk/service/jsonmarshallv2.py b/tests/databricks/sdk/service/jsonmarshallv2.py index 150fab8b4..efc912e4e 100755 --- a/tests/databricks/sdk/service/jsonmarshallv2.py +++ b/tests/databricks/sdk/service/jsonmarshallv2.py @@ -96,7 +96,7 @@ class OptionalFields: legacy_timestamp: Optional[str] = None - list_value: Optional[List[any]] = None + list_value: Optional[List[Any]] = None map: Optional[Dict[str, str]] = None """Lint disable reason: This is a dummy field used to test SDK Generation logic.""" @@ -111,13 +111,13 @@ class OptionalFields: optional_string: Optional[str] = None - struct: Optional[Dict[str, any]] = None + struct: Optional[Dict[str, Any]] = None test_enum: Optional[TestEnum] = None timestamp: Optional[Timestamp] = None - value: Optional[any] = None + value: Optional[Any] = None def as_dict(self) -> dict: """Serializes the OptionalFields into a dictionary suitable for use as a JSON request body.""" @@ -228,17 +228,17 @@ class RepeatedFields: repeated_int64: Optional[List[int]] = None - repeated_list_value: Optional[List[List[any]]] = None + repeated_list_value: Optional[List[List[Any]]] = None repeated_message: Optional[List[NestedMessage]] = None repeated_string: Optional[List[str]] = None - repeated_struct: Optional[List[Dict[str, any]]] = None + repeated_struct: Optional[List[Dict[str, Any]]] = None repeated_timestamp: Optional[List[Timestamp]] = None - repeated_value: Optional[List[any]] = None + repeated_value: Optional[List[Any]] = None test_repeated_enum: Optional[List[TestEnum]] = None @@ -344,11 +344,11 @@ class RequiredFields: required_timestamp: Timestamp - required_value: any + required_value: Any - required_list_value: List[any] + required_list_value: List[Any] - required_struct: Dict[str, any] + required_struct: Dict[str, Any] def as_dict(self) -> dict: """Serializes the RequiredFields into a dictionary suitable for use as a JSON request body.""" diff --git a/tests/generated/test_json_marshall.py b/tests/generated/test_json_marshall.py index 310f61d58..5b3796e56 100755 --- a/tests/generated/test_json_marshall.py +++ b/tests/generated/test_json_marshall.py @@ -423,7 +423,7 @@ def _fieldmask(d: str) -> FieldMask: "LegacyWellKnownTypes", ], ) -def test_python_marshall(from_dict_method: any, instance: Any, expected_json: str): +def test_python_marshall(from_dict_method: Any, instance: Any, expected_json: str): """Test Python object to dict conversion""" result = instance.as_dict() diff --git a/tests/test_dbutils.py b/tests/test_dbutils.py index 9792d8de5..f46404ac2 100644 --- a/tests/test_dbutils.py +++ b/tests/test_dbutils.py @@ -1,3 +1,5 @@ +from typing import Any + import pytest as pytest from databricks.sdk.dbutils import FileInfo as DBUtilsFileInfo @@ -144,7 +146,7 @@ def dbutils_proxy(mocker): return_value=Wait(lambda **kwargs: Created("y")), ) - def inner(results_data: any, expect_command: str): + def inner(results_data: Any, expect_command: str): import json command_execute = mocker.patch( diff --git a/tests/test_files_utils.py b/tests/test_files_utils.py index fb1d53d73..204f018de 100644 --- a/tests/test_files_utils.py +++ b/tests/test_files_utils.py @@ -2,7 +2,7 @@ import os from abc import ABC, abstractmethod from io import BytesIO, RawIOBase, UnsupportedOperation -from typing import BinaryIO, Callable, List, Optional, Tuple +from typing import Any, BinaryIO, Callable, List, Optional, Tuple import pytest @@ -133,7 +133,7 @@ def to_string(test_case) -> str: ] -def verify(test_case: ConcatenatedInputStreamTestCase, apply: Callable[[BinaryIO], Tuple[any, bool]]): +def verify(test_case: ConcatenatedInputStreamTestCase, apply: Callable[[BinaryIO], Tuple[Any, bool]]): """ This method applies given function iteratively to both implementation under test and reference implementation of the stream, and verifies the result on each step is identical. @@ -243,7 +243,7 @@ def read_and_restore(buf: BinaryIO) -> bytes: buf.seek(pos) return result - def safe_call(buf: BinaryIO, call: Callable[[BinaryIO], any]) -> (any, bool): + def safe_call(buf: BinaryIO, call: Callable[[BinaryIO], Any]) -> (Any, bool): """ Calls the provided function on the buffer and returns the result. It is a wrapper to handle exceptions gracefully.