-
Notifications
You must be signed in to change notification settings - Fork 63
Mypy type checking #1030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Mypy type checking #1030
Conversation
| ("adapter_sql_one_partition"), | ||
| ("adapter_duckdb_one_partition"), | ||
| ("adapter_psql_one_partition"), | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could instead shrink all the very similar SQLAdapter fixtures into one fixture that fetches the right database scheme and number of partitions?
async def _postgresql_uri() -> AsyncGenerator[str, None]:
uri = os.getenv("TILED_TEST_POSTGRESQL_URI")
if uri is None:
pytest.skip("TILED_TEST_POSTGRESQL_URI is not set")
async with temp_postgres(uri) as uri_with_database_name:
yield uri_with_database_name
async def _database_uri(scheme: str, tmp_path: Path) -> Generator[str, None, None]:
if schema == "postgresql":
url = await postgresql_uri()
yield url
else:
yield f"{scheme}:///{tmp_path}/test.db"
@asyncio.fixture
async def adapter(tmp_path: Path, request: pytest.FixtureRequest) -> Generator[SQLAdapter, None, None]:
database_params: tuple[str, int] = request.params
uri = await database_uri(database_params[0], tmp_path)
data_source = data_source_from_init_storage(uri, database_params[1])
yield SQLAdapter(
data_source.assets[0].data_uri,
data_source.structure,
data_source.parameters["table_name"],
data_source.parameters["dataset_id"],
)
@pytest.mark.parametrize(
"adapter",
[
("sqlite", 1),
("duckdb", 1),
("postgresql", 1),
],
indirect=True
)
def test_write_read_one_batch_one_part(adapter: SQLAdapter) -> None:And adapter_psql_many_partitions becomes ("postgresql", 3) etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I just don't like the pattern of fetching the fixture inside the test, this way the skip is done before the first line of the test)
| # By giving that a name ("_") we enable requests to asking for the | ||
| # last N by requesting the sorting ("_", -1). | ||
| sorting = [SortingItem(key="_", direction=1)] | ||
| sorting = [SortingItem(key="_", direction=SortingDirection.ASCENDING)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually work? Or as discussed, is the type hint wrong and the method works with what it was previously receiving?
Checklist