Skip to content

Commit 1e74eef

Browse files
committed
lint fixes
1 parent 310ea68 commit 1e74eef

File tree

8 files changed

+55
-58
lines changed

8 files changed

+55
-58
lines changed

airbyte_cdk/test/declarative/models/scenario.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from __future__ import annotations
1111

1212
from pathlib import Path
13-
from typing import Literal
13+
from typing import Any, Literal, cast
1414

1515
import yaml
1616
from pydantic import BaseModel
@@ -33,7 +33,7 @@ class AcceptanceTestFileTypes(BaseModel):
3333
bypass_reason: str
3434

3535
config_path: Path | None = None
36-
config_dict: dict | None = None
36+
config_dict: dict[str, Any] | None = None
3737

3838
id: str | None = None
3939

@@ -43,27 +43,27 @@ class AcceptanceTestFileTypes(BaseModel):
4343
file_types: AcceptanceTestFileTypes | None = None
4444
status: Literal["succeed", "failed"] | None = None
4545

46-
def get_config_dict(self) -> dict:
46+
def get_config_dict(self) -> dict[str, Any]:
4747
"""Return the config dictionary.
4848
4949
If a config dictionary has already been loaded, return it. Otherwise, load
50-
Otherwise, load the config file and return the dictionary.
50+
the config file and return the dictionary.
5151
"""
5252
if self.config_dict:
5353
return self.config_dict
5454

5555
if self.config_path:
56-
return yaml.safe_load(self.config_path.read_text())
56+
return cast(dict[str, Any], yaml.safe_load(self.config_path.read_text()))
5757

5858
raise ValueError("No config dictionary or path provided.")
5959

6060
@property
6161
def expect_exception(self) -> bool:
62-
return self.status and self.status == "failed"
62+
return self.status and self.status == "failed" or False
6363

6464
@property
6565
def instance_name(self) -> str:
66-
return self.config_path.stem
66+
return self.config_path.stem if self.config_path else "Unnamed Scenario"
6767

6868
def __str__(self) -> str:
6969
if self.id:

airbyte_cdk/test/declarative/test_suites/connector_base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
AirbyteMessage,
2121
Type,
2222
)
23+
from airbyte_cdk.sources.declarative.declarative_source import (
24+
AbstractSource,
25+
ConcurrentDeclarativeSource,
26+
Source,
27+
)
2328
from airbyte_cdk.test import entrypoint_wrapper
2429
from airbyte_cdk.test.declarative.models import (
2530
ConnectorTestScenario,
@@ -41,10 +46,10 @@ class RunnableConnector(abc.ABC):
4146
"""A connector that can be run in a test scenario."""
4247

4348
@abc.abstractmethod
44-
def launch(cls, args: list[str] | None): ...
49+
def launch(cls, args: list[str] | None) -> None: ...
4550

4651

47-
def generate_tests(metafunc):
52+
def generate_tests(metafunc) -> None:
4853
"""
4954
A helper for pytest_generate_tests hook.
5055

airbyte_cdk/test/declarative/test_suites/declarative_sources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class DeclarativeSourceTestSuite(SourceTestSuiteBase):
2626
def create_connector(
2727
self, connector_test: ConnectorTestScenario
2828
) -> ConcurrentDeclarativeSource:
29+
"""Create a connector instance for the test suite."""
2930
config = connector_test.get_config_dict()
3031
# catalog = connector_test.get_catalog()
3132
# state = connector_test.get_state()

airbyte_cdk/test/declarative/utils/job_runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import tempfile
22
import uuid
33
from pathlib import Path
4-
from typing import Callable, Literal
4+
from typing import Any, Callable, Literal
55

66
import orjson
77

@@ -22,7 +22,7 @@ def run_test_job(
2222
verb: Literal["read", "check", "discover"],
2323
test_instance: ConnectorTestScenario,
2424
*,
25-
catalog: dict | None = None,
25+
catalog: dict[str, Any] | None = None,
2626
) -> entrypoint_wrapper.EntrypointOutput:
2727
"""Run a test job from provided CLI args and return the result."""
2828
if not connector:
@@ -49,7 +49,7 @@ def run_test_job(
4949
else:
5050
raise ValueError(f"Invalid source type: {type(connector)}")
5151

52-
args = [verb]
52+
args: list[str] = [verb]
5353
if test_instance.config_path:
5454
args += ["--config", str(test_instance.config_path)]
5555
elif test_instance.config_dict:
@@ -103,12 +103,12 @@ def run_test_job(
103103
assert len(result.connection_status_messages) == 1, (
104104
"Expected exactly one CONNECTION_STATUS message. Got "
105105
f"{len(result.connection_status_messages)}:\n"
106-
+ "\n".join(result.connection_status_messages)
106+
+ "\n".join([str(msg) for msg in result.connection_status_messages])
107107
)
108108
if test_instance.expect_exception:
109109
assert result.connection_status_messages[0].connectionStatus.status == Status.FAILED, (
110110
"Expected CONNECTION_STATUS message to be FAILED. Got: \n"
111-
+ "\n".join([str(result.connection_status_messages)])
111+
+ "\n".join([str(msg) for msg in result.connection_status_messages])
112112
)
113113
return result
114114

airbyte_cdk/test/fixtures/general.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
"""Global pytest configuration for the Airbyte CDK tests."""
2+
13
from pathlib import Path
4+
from typing import Optional
25

36
import pytest
47

58

6-
def pytest_collect_file(parent, path):
7-
if path.basename == "test_connector.py":
8-
return pytest.Module.from_parent(parent, path=path)
9+
def pytest_collect_file(parent: Optional[pytest.Module], path: Path) -> pytest.Module | None:
10+
"""Collect test files based on their names."""
11+
if path.name == "test_connector.py":
12+
return cast(pytest.Module, pytest.Module.from_parent(parent, path=path))
13+
14+
return None
915

1016

11-
def pytest_configure(config):
17+
def pytest_configure(config: pytest.Config) -> None:
1218
config.addinivalue_line("markers", "connector: mark test as a connector test")
1319

1420

15-
def pytest_addoption(parser):
21+
def pytest_addoption(parser: pytest.Parser) -> None:
1622
parser.addoption(
1723
"--run-connector",
1824
action="store_true",
@@ -21,7 +27,7 @@ def pytest_addoption(parser):
2127
)
2228

2329

24-
def pytest_collection_modifyitems(config, items):
30+
def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> None:
2531
if config.getoption("--run-connector"):
2632
return
2733
skip_connector = pytest.mark.skip(reason="need --run-connector option to run")
@@ -30,11 +36,11 @@ def pytest_collection_modifyitems(config, items):
3036
item.add_marker(skip_connector)
3137

3238

33-
def pytest_runtest_setup(item):
39+
def pytest_runtest_setup(item: pytest.Item) -> None:
3440
# This hook is called before each test function is executed
3541
print(f"Setting up test: {item.name}")
3642

3743

38-
def pytest_runtest_teardown(item, nextitem):
44+
def pytest_runtest_teardown(item: pytest.Item, nextitem: Optional[pytest.Item]) -> None:
3945
# This hook is called after each test function is executed
4046
print(f"Tearing down test: {item.name}")

poetry.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ whenever = "^0.6.16"
8888
freezegun = "*"
8989
mypy = "*"
9090
asyncio = "3.4.3"
91-
ruff = "^0.7.2"
91+
ruff = "^0.11.4"
9292
pdoc = "^15.0.0"
9393
poethepoet = "^0.24.2"
9494
pyproject-flake8 = "^6.1.0"

0 commit comments

Comments
 (0)