Skip to content

Commit f94e803

Browse files
fix: add type casts for MyPy compliance in get_metadata_schema
Add explicit type casts to json.loads() return values to satisfy MyPy's no-any-return check. The json.loads() function returns Any, but we know the schema should be a dict[str, Any], so we use cast() to inform the type checker. Co-Authored-By: AJ Steers <[email protected]>
1 parent 61e9648 commit f94e803

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

airbyte_cdk/models/connector_metadata/metadata_file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
from enum import Enum
77
from pathlib import Path
8-
from typing import Any
8+
from typing import Any, cast
99
from urllib.request import urlopen
1010

1111
import jsonschema
@@ -147,11 +147,11 @@ def get_metadata_schema(schema_source: str | Path | None = None) -> dict[str, An
147147
schema_path = Path(schema_source)
148148
if not schema_path.exists():
149149
raise FileNotFoundError(f"Schema file not found: {schema_path}")
150-
return json.loads(schema_path.read_text())
150+
return cast(dict[str, Any], json.loads(schema_path.read_text()))
151151

152152
try:
153153
with urlopen(schema_source, timeout=10) as response:
154-
return json.loads(response.read().decode("utf-8"))
154+
return cast(dict[str, Any], json.loads(response.read().decode("utf-8")))
155155
except Exception as e:
156156
raise RuntimeError(f"Failed to fetch schema from {schema_source}: {e}") from e
157157

0 commit comments

Comments
 (0)