Skip to content

Commit d99c2fa

Browse files
style: Clean up unused imports and modernize type hints
- Remove unused imports from test file: json, ConcurrentDeclarativeSource, HttpMocker - Remove unused global variables: _CONFIG, _MANIFEST - Update Optional[Mapping[str, Any]] to Mapping[str, Any] | None per Python 3.10+ style - All 6 unit tests pass locally Co-Authored-By: AJ Steers <[email protected]>
1 parent c288814 commit d99c2fa

File tree

2 files changed

+2
-69
lines changed

2 files changed

+2
-69
lines changed

airbyte_cdk/sources/declarative/schema/inferred_schema_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections.abc import Mapping as ABCMapping
66
from collections.abc import Sequence
77
from dataclasses import InitVar, dataclass
8-
from typing import Any, Mapping, Optional
8+
from typing import Any, Mapping
99

1010
from airbyte_cdk.models import AirbyteRecordMessage
1111
from airbyte_cdk.sources.declarative.retrievers.retriever import Retriever
@@ -101,7 +101,7 @@ def get_json_schema(self) -> Mapping[str, Any]:
101101
if record_count >= self.record_sample_size:
102102
break
103103

104-
inferred_schema: Optional[Mapping[str, Any]] = schema_inferrer.get_stream_schema(
104+
inferred_schema: Mapping[str, Any] | None = schema_inferrer.get_stream_schema(
105105
self.stream_name
106106
)
107107

unit_tests/sources/declarative/schema/test_inferred_schema_loader.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,11 @@
22
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
33
#
44

5-
import json
65
from unittest.mock import MagicMock
76

87
import pytest
98

10-
from airbyte_cdk.sources.declarative.concurrent_declarative_source import (
11-
ConcurrentDeclarativeSource,
12-
)
139
from airbyte_cdk.sources.declarative.schema import InferredSchemaLoader
14-
from airbyte_cdk.test.mock_http import HttpMocker, HttpRequest, HttpResponse
15-
16-
_CONFIG = {
17-
"start_date": "2024-07-01T00:00:00.000Z",
18-
"api_key": "test_api_key",
19-
}
20-
21-
_MANIFEST = {
22-
"version": "6.7.0",
23-
"definitions": {
24-
"users_stream": {
25-
"type": "DeclarativeStream",
26-
"name": "users",
27-
"primary_key": [],
28-
"retriever": {
29-
"type": "SimpleRetriever",
30-
"requester": {
31-
"type": "HttpRequester",
32-
"url_base": "https://api.test.com",
33-
"path": "/users",
34-
"http_method": "GET",
35-
"authenticator": {
36-
"type": "ApiKeyAuthenticator",
37-
"header": "apikey",
38-
"api_token": "{{ config['api_key'] }}",
39-
},
40-
},
41-
"record_selector": {
42-
"type": "RecordSelector",
43-
"extractor": {"type": "DpathExtractor", "field_path": []},
44-
},
45-
"paginator": {"type": "NoPagination"},
46-
},
47-
"schema_loader": {
48-
"type": "InferredSchemaLoader",
49-
"retriever": {
50-
"type": "SimpleRetriever",
51-
"requester": {
52-
"type": "HttpRequester",
53-
"url_base": "https://api.test.com",
54-
"path": "/users",
55-
"http_method": "GET",
56-
"authenticator": {
57-
"type": "ApiKeyAuthenticator",
58-
"header": "apikey",
59-
"api_token": "{{ config['api_key'] }}",
60-
},
61-
},
62-
"record_selector": {
63-
"type": "RecordSelector",
64-
"extractor": {"type": "DpathExtractor", "field_path": []},
65-
},
66-
"paginator": {"type": "NoPagination"},
67-
},
68-
"record_sample_size": 3,
69-
},
70-
},
71-
},
72-
"streams": [
73-
"#/definitions/users_stream",
74-
],
75-
"check": {"stream_names": ["users"]},
76-
}
7710

7811

7912
@pytest.fixture

0 commit comments

Comments
 (0)