Skip to content
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

build(deps): bump the prod-deps group with 3 updates #1827

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 116 additions & 105 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/clickhouse/test_clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_get_form_query_with_good_database(clickhouse_connector):
"type": "string",
}
assert form["properties"]["table"] == {"$ref": "#/$defs/table", "default": None}
assert form["$defs"]["table"] == {"const": "city", "enum": ["city"], "title": "table", "type": "string"}
assert form["$defs"]["table"] == {"enum": ["city"], "title": "table", "type": "string"}
assert form["required"] == ["domain", "name", "database"]


Expand Down
1 change: 0 additions & 1 deletion tests/mongo/test_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ def test_get_form_query_with_good_database(mongo_connector):
assert form["$defs"]["collection"] == {
"title": "collection",
"type": "string",
"const": "test_col",
"enum": ["test_col"],
}

Expand Down
2 changes: 1 addition & 1 deletion tests/soap/test_soap.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_get_form(mocker, connector, create_datasource):
mocker.patch(f"{import_path}.SoapDataSource._get_methods_docs", return_value={"fake_func": "coucou"})
form = create_datasource.get_form(connector, {})
assert form["properties"]["parameters"]["description"] == "Services documentation: <br> coucou"
assert form["$defs"]["method"]["const"] == "fake_func"
assert form["$defs"]["method"] == {"enum": ["fake_func"], "title": "method", "type": "string"}


def test_create_client(mocker, connector):
Expand Down
4 changes: 2 additions & 2 deletions toucan_connectors/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ class AuthType(str, Enum):

# mypy complains about the `kwargs` field
class Auth(BaseModel): # type:ignore[no-redef]
type: AuthType = Field(
type: AuthType = Field( # type:ignore[call-overload]
...,
description="As we rely on the python request library, we suggest that you "
"refer to the dedicated "
'<a href="https://2.python-requests.org/en/master/user/authentication/">documentation</a> '
"for more details.",
description_mimetype="text/html", # type:ignore[call-arg]
description_mimetype="text/html",
)
args: list[str] = Field(
default_factory=list,
Expand Down
10 changes: 5 additions & 5 deletions toucan_connectors/awsathena/awsathena_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ class AwsathenaDataSource(ToucanDataSource):
..., description="The name of the database you want to query."
)
# To avoid previous config migrations, won't be used
table: str | None = Field(None, **{"ui.hidden": True}) # type:ignore[arg-type,pydantic-field]
language: str = Field("sql", **{"ui.hidden": True}) # type:ignore[arg-type,pydantic-field]
query: Annotated[str | None, StringConstraints(min_length=1)] = Field( # type:ignore[call-arg]
table: str | None = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[call-overload]
query: Annotated[str | None, StringConstraints(min_length=1)] = Field( # type: ignore[call-overload]
None,
description="The SQL query to execute.",
widget="sql",
)
query_object: dict | None = Field( # type:ignore[pydantic-field]
query_object: dict | None = Field( # type: ignore[call-overload]
None,
description="An object describing a simple select query This field is used internally",
**{"ui.hidden": True}, # type:ignore[arg-type]
**{"ui.hidden": True},
)
use_ctas: bool = Field(
False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ class Dialect(str, Enum):


class GoogleBigQueryDataSource(ToucanDataSource):
query: str = Field(
query: str = Field( # type: ignore[call-overload]
...,
description="You can find details on the query syntax "
'<a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax">here</a>',
widget="sql", # type:ignore[call-arg]
widget="sql",
)
query_object: dict | None = Field( # type:ignore[pydantic-field]
query_object: dict | None = Field( # type: ignore[call-overload]
None,
description="An object describing a simple select query This field is used internally",
**{"ui.hidden": True}, # type:ignore[arg-type]
**{"ui.hidden": True},
)
language: str = Field("sql", **{"ui.hidden": True}) # type:ignore[arg-type,pydantic-field]
database: str | None = Field(None, **{"ui.hidden": True}) # type:ignore[arg-type,pydantic-field]
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[call-overload]
database: str | None = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
db_schema: str | None = Field(None, description="The name of the db_schema you want to query.")

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions toucan_connectors/mongo/mongo_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _get_details(index: int, status: Optional[bool]):
def _get_mongo_client_kwargs(self) -> dict[str, Any]:
# We don't want parent class attributes nor the `client` property
# nor attributes with `None` value
to_exclude = set(ToucanConnector.model_fields.keys()) | {"client", "max_pool_size"}
to_exclude = set(ToucanConnector.__pydantic_fields__.keys()) | {"client", "max_pool_size"}
mongo_client_kwargs = self.model_dump(exclude=to_exclude, exclude_none=True).copy()

if "password" in mongo_client_kwargs:
Expand Down Expand Up @@ -267,7 +267,7 @@ def _retrieve_data(self, data_source, chunk_size: int | None = None):

if chunk_size:
chunks = []
while (chunk := list(itertools.islice(data, chunk_size))):
while chunk := list(itertools.islice(data, chunk_size)):
chunks.append(pd.DataFrame.from_records(chunk))
return pd.concat(chunks, ignore_index=True) if chunks else pd.DataFrame()
else:
Expand Down
14 changes: 7 additions & 7 deletions toucan_connectors/mysql/mysql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ class MySQLDataSource(ToucanDataSource):
"""

database: str = Field(..., description="The name of the database you want to query")
follow_relations: bool | None = Field( # type: ignore[pydantic-field]
follow_relations: bool | None = Field( # type: ignore[call-overload]
None,
**{"ui.hidden": True}, # type: ignore[arg-type]
**{"ui.hidden": True},
description="Deprecated, kept for compatibility purpose with old data sources configs",
)
table: str | None = Field(None, **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
query: Annotated[str, StringConstraints(min_length=1)] | None = Field( # type: ignore[call-arg]
table: str | None = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
query: Annotated[str, StringConstraints(min_length=1)] | None = Field( # type: ignore[call-overload]
None,
description="You can write a custom query against your "
"database here. It will take precedence over "
'the "table" parameter',
widget="sql",
)
query_object: dict | None = Field( # type: ignore[pydantic-field]
query_object: dict | None = Field( # type: ignore[call-overload]
None,
description="An object describing a simple select query" "This field is used internally",
**{"ui.hidden": True}, # type: ignore[arg-type]
**{"ui.hidden": True},
)
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[call-overload]

@classmethod
def get_form(cls, connector: "MySQLConnector", current_config: dict[str, Any]) -> dict:
Expand Down
8 changes: 4 additions & 4 deletions toucan_connectors/postgres/postgresql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@

class PostgresDataSource(ToucanDataSource):
database: str = Field(DEFAULT_DATABASE, description="The name of the database you want to query")
query: Annotated[str | None, StringConstraints(min_length=1)] = Field( # type:ignore[call-arg]
query: Annotated[str | None, StringConstraints(min_length=1)] = Field( # type: ignore[call-overload]
None,
description="You can write a custom query against your "
"database here. It will take precedence over "
'the "table" parameter',
widget="sql",
)
query_object: dict | None = Field( # type:ignore[pydantic-field]
query_object: dict | None = Field( # type: ignore[call-overload]
None,
description="An object describing a simple select query" "This field is used internally",
**{"ui.hidden": True}, # type:ignore[arg-type]
**{"ui.hidden": True},
)
table: Annotated[str | None, StringConstraints(min_length=1)] = Field(
None,
description="The name of the data table that you want to " 'get (equivalent to "SELECT * FROM ' 'your_table")',
)
language: str = Field("sql", **{"ui.hidden": True}) # type:ignore[pydantic-field,arg-type]
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[call-overload]

def __init__(self, **data):
super().__init__(**data)
Expand Down
12 changes: 6 additions & 6 deletions toucan_connectors/redshift/redshift_database_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ class AuthenticationMethodError(str, Enum):

class RedshiftDataSource(ToucanDataSource):
database: str = Field(DEFAULT_DATABASE, description="The name of the database you want to query")
query: Annotated[str, StringConstraints(min_length=1)] = Field( # type: ignore[call-arg,assignment]
query: Annotated[str, StringConstraints(min_length=1)] = Field( # type: ignore[call-overload]
None,
description="You can write a custom query against your "
"database here. It will take precedence over "
"the table parameter",
widget="sql",
)
query_object: dict[str, Any] = Field( # type: ignore[pydantic-field]
query_object: dict[str, Any] = Field( # type: ignore[call-overload]
None,
description="An object describing a simple select query, this field is used internally",
**{"ui.hidden": True}, # type: ignore[arg-type]
**{"ui.hidden": True},
)
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
language: str = Field("sql", **{"ui.hidden": True}) # type: ignore[call-overload]

@classmethod
def get_form(cls, connector: "RedshiftConnector", current_config: dict[str, Any]):
Expand All @@ -114,11 +114,11 @@ def get_form(cls, connector: "RedshiftConnector", current_config: dict[str, Any]


class RedshiftConnector(ToucanConnector, DiscoverableConnector, data_source_model=RedshiftDataSource):
authentication_method: AuthenticationMethod = Field( # type: ignore[pydantic-field]
authentication_method: AuthenticationMethod = Field( # type: ignore[call-overload]
None,
title="Authentication Method",
description="The authentication mechanism that will be used to connect to your redshift data source",
**{"ui": {"checkbox": False}}, # type: ignore[arg-type]
**{"ui": {"checkbox": False}},
)
host: str = Field(..., description="The hostname of the Amazon Redshift cluster")
port: int = Field(5439, description="The listening port of your Redshift Database")
Expand Down
20 changes: 10 additions & 10 deletions toucan_connectors/snowflake/snowflake_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ class SnowflakeDataSource(ToucanDataSource["SnowflakeConnector"]):
database: str = Field(..., description="The name of the database you want to query")
warehouse: str | None = Field(None, description="The name of the warehouse you want to query")

query: str = Field(
query: str = Field( # type:ignore[call-overload]
...,
description="You can write your SQL query here",
min_length=1,
widget="sql", # type:ignore[call-arg]
widget="sql",
)

# Pydantic sees **UI_HIDDEN as the third argument (the default factory) and raises an error
query_object: dict | None = Field( # type: ignore[pydantic-field]
query_object: dict | None = Field(
None,
description="An object describing a simple select query"
"For example "
'{"schema": "SHOW_SCHEMA", "table": "MY_TABLE", "columns": ["col1", "col2"]}'
"This field is used internally",
**UI_HIDDEN,
)
language: str = Field("sql", **UI_HIDDEN) # type: ignore[pydantic-field]
language: str = Field("sql", **UI_HIDDEN)

@classmethod
def _get_databases(cls, connector: "SnowflakeConnector"):
Expand Down Expand Up @@ -147,20 +147,20 @@ class SnowflakeConnector(
sso_credentials_keeper: Any = None
user_tokens_keeper: Any = None

account: str = Field(
account: str = Field( # type:ignore[call-overload]
...,
description="The full name of your Snowflake account. "
"It might require the region and cloud platform where your account is located, "
'in the form of: "your_account_name.region_id.cloud_platform". See more details '
'<a href="https://docs.snowflake.net/manuals/user-guide/python-connector-api.html#label-account-format-info" target="_blank">here</a>.', # noqa: E501
placeholder="your_account_name.region_id.cloud_platform", # type:ignore[call-arg]
placeholder="your_account_name.region_id.cloud_platform",
)

authentication_method: AuthenticationMethod = Field(
authentication_method: AuthenticationMethod = Field( # type:ignore[call-overload]
AuthenticationMethod.PLAIN,
title="Authentication Method",
description="The authentication mechanism that will be used to connect to your snowflake data source",
ui={"checkbox": False}, # type:ignore[call-arg]
ui={"checkbox": False},
)

user: str = Field(..., description="Your login username")
Expand All @@ -180,10 +180,10 @@ class SnowflakeConnector(
default_warehouse: str | None = Field(
None, description="The default warehouse that shall be used for any data source"
)
category: Category = Field(
category: Category = Field( # type:ignore[call-overload]
Category.SNOWFLAKE,
title="category",
ui={"checkbox": False}, # type:ignore[call-arg]
ui={"checkbox": False},
)

@classmethod
Expand Down
24 changes: 12 additions & 12 deletions toucan_connectors/snowflake_oauth2/snowflake_oauth2_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,29 @@ def get_form(cls, connector: "SnowflakeoAuth2Connector", current_config):


class SnowflakeoAuth2Connector(ToucanConnector, data_source_model=SnowflakeoAuth2DataSource):
client_id: str = Field( # type: ignore[pydantic-field]
client_id: str = Field( # type: ignore[call-overload]
"",
title="Client ID",
description="The client id of you Snowflake integration",
**{"ui.required": True}, # type: ignore[arg-type]
**{"ui.required": True},
)
client_secret: PlainJsonSecretStr = Field( # type: ignore[pydantic-field]
client_secret: PlainJsonSecretStr = Field( # type: ignore[call-overload]
"",
title="Client Secret",
description="The client secret of your Snowflake integration",
**{"ui.required": True}, # type: ignore[arg-type]
**{"ui.required": True},
)
authorization_url: str = Field(None, **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
scope: str = Field(None, Title="Scope", description="The scope the integration", placeholder="refresh_token") # type: ignore[call-arg,assignment]
token_url: str = Field(None, **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
auth_flow_id: str = Field(None, **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
authorization_url: str = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
scope: str = Field(None, Title="Scope", description="The scope the integration", placeholder="refresh_token") # type: ignore[call-overload]
token_url: str = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
auth_flow_id: str = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
_auth_flow = "oauth2"
_oauth_trigger = "connector"
oauth2_version: str = Field("1", **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
redirect_uri: str = Field(None, **{"ui.hidden": True}) # type: ignore[pydantic-field,arg-type]
oauth2_version: str = Field("1", **{"ui.hidden": True}) # type: ignore[call-overload]
redirect_uri: str = Field(None, **{"ui.hidden": True}) # type: ignore[call-overload]
_oauth2_connector: OAuth2Connector = PrivateAttr()

role: str = Field( # type: ignore[call-arg]
role: str = Field( # type: ignore[call-overload]
...,
title="Role",
description="Role to use for queries",
Expand All @@ -108,7 +108,7 @@ class SnowflakeoAuth2Connector(ToucanConnector, data_source_model=SnowflakeoAuth
'<a href="https://docs.snowflake.net/manuals/user-guide/python-connector-api.html#label-account-format-info" target="_blank">here</a>.', # noqa: E501
)
default_warehouse: str = Field(..., description="The default warehouse that shall be used for any data source")
category: Category = Field(Category.SNOWFLAKE, title="category", **{"ui": {"checkbox": False}}) # type: ignore[pydantic-field,arg-type]
category: Category = Field(Category.SNOWFLAKE, title="category", **{"ui": {"checkbox": False}}) # type: ignore[call-overload]

def __init__(self, **kwargs):
super().__init__(**{k: v for k, v in kwargs.items() if k != "secrets_keeper"})
Expand Down
4 changes: 2 additions & 2 deletions toucan_connectors/toucan_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def __init_subclass__(cls, /, *, data_source_model: type[DS]):
retry_policy: RetryPolicy | None = RetryPolicy()
_retry_on: Iterable[Type[BaseException]] = ()
type: str | None = None
secrets_storage_version: str = Field("1", **UI_HIDDEN) # type:ignore[pydantic-field]
secrets_storage_version: str = Field("1", **UI_HIDDEN)

# Default ttl for all connector's queries (overridable at the data_source level)
# /!\ cache ttl is used by the caching system which is not implemented in toucan_connectors.
Expand All @@ -311,7 +311,7 @@ def __init_subclass__(cls, /, *, data_source_model: type[DS]):
)

# Used to defined the connection
identifier: str | None = Field(None, **UI_HIDDEN) # type:ignore[pydantic-field]
identifier: str | None = Field(None, **UI_HIDDEN)
model_config = ConfigDict(extra="forbid", validate_assignment=True)

@property
Expand Down