Skip to content

Commit ac187a3

Browse files
Fix type annotations: replace builtin any with typing.Any
Occurrences in _internal.py, config.py, dbutils.py, oauth.py, and runtime/dbutils_stub.py were using the builtin any (an Iterable->bool callable) as a type annotation instead of typing.Any. mypy interprets these as the callable type, causing spurious attr-defined errors on annotated values. Signed-off-by: Victor Hugo Xavier <victor@coactive.ai> Signed-off-by: coactive-victor <victor@coactive.ai>
1 parent 2f40863 commit ac187a3

5 files changed

Lines changed: 23 additions & 21 deletions

File tree

databricks/sdk/config.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66
import pathlib
77
import re
88
import urllib.parse
9-
from typing import Dict, Iterable, List, Optional
9+
from typing import Any, Dict, Iterable, List, Optional
1010

1111
import requests
1212

1313
from . import useragent
1414
from ._base_client import _fix_host_if_needed
1515
from .client_types import ClientType, HostType
1616
from .clock import Clock, RealClock
17-
from .credentials_provider import (CredentialsStrategy, DefaultCredentials,
18-
OAuthCredentialsProvider)
19-
from .environments import (ALL_ENVS, AzureEnvironment, Cloud,
20-
DatabricksEnvironment, get_environment_for_hostname)
21-
from .oauth import (OidcEndpoints, Token,
22-
get_azure_entra_id_workspace_endpoints,
23-
get_endpoints_from_url, get_host_metadata)
17+
from .credentials_provider import CredentialsStrategy, DefaultCredentials, OAuthCredentialsProvider
18+
from .environments import ALL_ENVS, AzureEnvironment, Cloud, DatabricksEnvironment, get_environment_for_hostname
19+
from .oauth import (
20+
OidcEndpoints,
21+
Token,
22+
get_azure_entra_id_workspace_endpoints,
23+
get_endpoints_from_url,
24+
get_host_metadata,
25+
)
2426

2527
logger = logging.getLogger("databricks.sdk")
2628

@@ -47,7 +49,7 @@ def __get__(self, cfg: "Config", owner):
4749
return None
4850
return cfg._inner.get(self.name, None)
4951

50-
def __set__(self, cfg: "Config", value: any):
52+
def __set__(self, cfg: "Config", value: Any):
5153
cfg._inner[self.name] = self.transform(value)
5254

5355
def __repr__(self) -> str:

databricks/sdk/dbutils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def get(
186186
self,
187187
taskKey: str,
188188
key: str,
189-
default: any = None,
190-
debugValue: any = None,
189+
default: Any = None,
190+
debugValue: Any = None,
191191
) -> None:
192192
"""
193193
Returns `debugValue` if present, throws an error otherwise as this implementation is always run outside of a job run
@@ -198,7 +198,7 @@ def get(
198198
)
199199
return debugValue
200200

201-
def set(self, key: str, value: any) -> None:
201+
def set(self, key: str, value: Any) -> None:
202202
"""
203203
Sets a task value on the current task run
204204
"""

databricks/sdk/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def from_host(
789789
from .credentials_provider import credentials_strategy
790790

791791
@credentials_strategy("noop", [])
792-
def noop_credentials(_: any):
792+
def noop_credentials(_: Any):
793793
return lambda: {}
794794

795795
config = Config(host=host, credentials_strategy=noop_credentials)

databricks/sdk/runtime/dbutils_stub.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class data:
5757
"""
5858

5959
@staticmethod
60-
def summarize(df: any, precise: bool = False) -> None:
60+
def summarize(df: typing.Any, precise: bool = False) -> None:
6161
"""Summarize a Spark/pandas/Koalas DataFrame and visualize the statistics to get quick insights.
6262
6363
Example: dbutils.data.summarize(df)
@@ -200,16 +200,16 @@ class taskValues:
200200
def get(
201201
taskKey: str,
202202
key: str,
203-
default: any = None,
204-
debugValue: any = None,
203+
default: typing.Any = None,
204+
debugValue: typing.Any = None,
205205
) -> None:
206206
"""
207207
Returns the latest task value that belongs to the current job run
208208
"""
209209
...
210210

211211
@staticmethod
212-
def set(key: str, value: any) -> None:
212+
def set(key: str, value: typing.Any) -> None:
213213
"""
214214
Sets a task value on the current task run
215215
"""

databricks/sdk/service/_internal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from databricks.sdk.common.types.fieldmask import FieldMask
99

1010

11-
def _from_dict(d: Dict[str, any], field: str, cls: Type) -> any:
11+
def _from_dict(d: Dict[str, Any], field: str, cls: Type) -> Any:
1212
if field not in d or d[field] is None:
1313
return None
1414
return getattr(cls, "from_dict")(d[field])
1515

1616

17-
def _repeated_dict(d: Dict[str, any], field: str, cls: Type) -> any:
17+
def _repeated_dict(d: Dict[str, Any], field: str, cls: Type) -> Any:
1818
if field not in d or not d[field]:
1919
return []
2020
from_dict = getattr(cls, "from_dict")
@@ -28,14 +28,14 @@ def _get_enum_value(cls: Type, value: str) -> Optional[Type]:
2828
)
2929

3030

31-
def _enum(d: Dict[str, any], field: str, cls: Type) -> any:
31+
def _enum(d: Dict[str, Any], field: str, cls: Type) -> Any:
3232
"""Unknown enum values are returned as None."""
3333
if field not in d or not d[field]:
3434
return None
3535
return _get_enum_value(cls, d[field])
3636

3737

38-
def _repeated_enum(d: Dict[str, any], field: str, cls: Type) -> any:
38+
def _repeated_enum(d: Dict[str, Any], field: str, cls: Type) -> Any:
3939
"""For now, unknown enum values are not included in the response."""
4040
if field not in d or not d[field]:
4141
return None

0 commit comments

Comments
 (0)