Skip to content

Commit 09150f0

Browse files
committed
[DOP-31720] Improve Literal annotation usage
1 parent 7a3c938 commit 09150f0

13 files changed

Lines changed: 48 additions & 39 deletions

File tree

syncmaster/schemas/v1/auth/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class ReadBasicAuthSchema(SecretDumpMixin):
11-
type: Literal["basic"] = Field(description="Auth type")
11+
type: Literal["basic"] = Field(default="basic", description="Auth type")
1212
user: str
1313

1414

syncmaster/schemas/v1/auth/iceberg_rest_s3_delegated/bearer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class ReadIcebergRESTCatalogBearerAuthSchema(SecretDumpMixin):
11-
type: Literal["iceberg_rest_bearer"] = Field(description="Auth type")
11+
type: Literal["iceberg_rest_bearer"] = Field(default="iceberg_rest_bearer", description="Auth type")
1212

1313

1414
class CreateIcebergRESTCatalogBearerAuthSchema(ReadIcebergRESTCatalogBearerAuthSchema):

syncmaster/schemas/v1/auth/iceberg_rest_s3_delegated/oauth2_client_credentials.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010

1111
class ReadIcebergRESTCatalogOAuth2ClientCredentialsAuthSchema(SecretDumpMixin):
12-
type: Literal["iceberg_rest_oauth2_client_credentials"] = Field(description="Auth type")
12+
type: Literal["iceberg_rest_oauth2_client_credentials"] = Field(
13+
default="iceberg_rest_oauth2_client_credentials",
14+
description="Auth type",
15+
)
1316
rest_catalog_oauth2_client_id: str
1417
rest_catalog_oauth2_scopes: list[str] = Field(default_factory=list)
1518
rest_catalog_oauth2_resource: str | None = None

syncmaster/schemas/v1/auth/iceberg_rest_s3_direct/bearer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99

1010
class ReadIcebergRESTCatalogBearerS3BasicAuthSchema(SecretDumpMixin):
11-
type: Literal["iceberg_rest_bearer_s3_basic"] = Field(description="Auth type")
11+
type: Literal["iceberg_rest_bearer_s3_basic"] = Field(
12+
default="iceberg_rest_bearer_s3_basic",
13+
description="Auth type",
14+
)
1215
s3_access_key: str
1316

1417

syncmaster/schemas/v1/auth/iceberg_rest_s3_direct/oauth2_client_credentials.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99

1010
class ReadIcebergRESTCatalogOAuth2ClientCredentialsS3BasicAuthSchema(SecretDumpMixin):
11-
type: Literal["iceberg_rest_oauth2_client_credentials_s3_basic"] = Field(description="Auth type")
11+
type: Literal["iceberg_rest_oauth2_client_credentials_s3_basic"] = Field(
12+
default="iceberg_rest_oauth2_client_credentials_s3_basic",
13+
description="Auth type",
14+
)
1215
rest_catalog_oauth2_client_id: str
1316
rest_catalog_oauth2_scopes: list[str] = Field(default_factory=list)
1417
rest_catalog_oauth2_resource: str | None = None

syncmaster/schemas/v1/auth/s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class ReadS3AuthSchema(SecretDumpMixin):
11-
type: Literal["s3"] = Field(description="Auth type")
11+
type: Literal["s3"] = Field(default="s3", description="Auth type")
1212
access_key: str
1313

1414

syncmaster/schemas/v1/auth/samba.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class ReadSambaAuthSchema(SecretDumpMixin):
11-
type: Literal["samba"] = Field(description="Auth type")
11+
type: Literal["samba"] = Field(default="samba", description="Auth type")
1212
user: str
1313
auth_type: Literal["NTLMv1", "NTLMv2"] = "NTLMv2"
1414

syncmaster/schemas/v1/connections/iceberg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
class IcebergRESTCatalogS3DirectConnectionDataSchema(BaseModel):
27-
type: Literal["iceberg_rest_s3_direct"]
27+
type: Literal["iceberg_rest_s3_direct"] = "iceberg_rest_s3_direct"
2828
rest_catalog_url: URL
2929
s3_warehouse_path: str
3030
s3_host: str
@@ -37,7 +37,7 @@ class IcebergRESTCatalogS3DirectConnectionDataSchema(BaseModel):
3737

3838

3939
class IcebergRESTCatalogS3DelegatedConnectionDataSchema(BaseModel):
40-
type: Literal["iceberg_rest_s3_delegated"]
40+
type: Literal["iceberg_rest_s3_delegated"] = "iceberg_rest_s3_delegated"
4141
rest_catalog_url: URL
4242
s3_warehouse_name: str | None = None
4343
s3_access_delegation: Literal["vended-credentials", "remote-signing"] = "vended-credentials"

syncmaster/schemas/v1/transfers/file_format.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class XMLCompression(str, Enum): # noqa: UP042
5858

5959

6060
class CSV(BaseModel):
61-
type: CSV_FORMAT
61+
type: CSV_FORMAT = "csv"
6262
delimiter: str = ","
6363
encoding: str = "utf-8"
6464
quote: str = '"'
@@ -69,37 +69,37 @@ class CSV(BaseModel):
6969

7070

7171
class JSONLine(BaseModel):
72-
type: JSONLINE_FORMAT
72+
type: JSONLINE_FORMAT = "jsonline"
7373
encoding: str = "utf-8"
7474
line_sep: str = "\n"
7575
compression: JSONCompression = JSONCompression.GZIP
7676

7777

7878
class JSON(BaseModel):
79-
type: JSON_FORMAT
79+
type: JSON_FORMAT = "json"
8080
encoding: str = "utf-8"
8181
line_sep: str = "\n"
8282
compression: JSONCompression = JSONCompression.GZIP
8383

8484

8585
class Excel(BaseModel):
86-
type: EXCEL_FORMAT
86+
type: EXCEL_FORMAT = "excel"
8787
include_header: bool = False
8888
start_cell: str | None = None
8989

9090

9191
class XML(BaseModel):
92-
type: XML_FORMAT
92+
type: XML_FORMAT = "xml"
9393
root_tag: str
9494
row_tag: str
9595
compression: XMLCompression = XMLCompression.GZIP
9696

9797

9898
class ORC(BaseModel):
99-
type: ORC_FORMAT
99+
type: ORC_FORMAT = "orc"
100100
compression: ORCCompression = ORCCompression.ZLIB
101101

102102

103103
class Parquet(BaseModel):
104-
type: PARQUET_FORMAT
104+
type: PARQUET_FORMAT = "parquet"
105105
compression: ParquetCompression = ParquetCompression.SNAPPY

syncmaster/schemas/v1/transfers/transformations/dataframe_columns_filter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ class BaseColumnsFilter(BaseModel):
1010

1111

1212
class IncludeFilter(BaseColumnsFilter):
13-
type: Literal["include"]
13+
type: Literal["include"] = "include"
1414

1515

1616
class RenameFilter(BaseColumnsFilter):
17-
type: Literal["rename"]
17+
type: Literal["rename"] = "rename"
1818
to: str = Field(examples=["new_column_name"])
1919

2020

2121
class CastFilter(BaseColumnsFilter):
22-
type: Literal["cast"]
22+
type: Literal["cast"] = "cast"
2323
as_type: str = Field(examples=["int"])
2424

2525

2626
ColumnsFilter = IncludeFilter | RenameFilter | CastFilter
2727

2828

2929
class DataframeColumnsFilter(BaseModel):
30-
type: Literal["dataframe_columns_filter"]
30+
type: Literal["dataframe_columns_filter"] = "dataframe_columns_filter"
3131
filters: list[Annotated[ColumnsFilter, Field(discriminator="type")]] = Field(default_factory=list)

0 commit comments

Comments
 (0)