diff --git a/docs/auto-classification/add-support-for-another-entity.md b/docs/auto-classification/add-support-for-another-entity.md index 00b65093a80f..fee61f0ca191 100644 --- a/docs/auto-classification/add-support-for-another-entity.md +++ b/docs/auto-classification/add-support-for-another-entity.md @@ -433,12 +433,11 @@ WHERE name = 'AutoClassificationBotPolicy'; **Location:** `ingestion/src/metadata/pii/types.py` ```python -from typing import Union from metadata.generated.schema.entity.data.container import Container from metadata.generated.schema.entity.data.table import Table from metadata.generated.schema.entity.data.topic import Topic # Your new entity -ClassifiableEntityType = Union[Table, Container, Topic] +ClassifiableEntityType = Table | Container | Topic ``` #### 3.2 Register Entity Adapter @@ -504,7 +503,7 @@ class YourEntityFetcherStrategy(FetcherStrategy): self, config: OpenMetadataWorkflowConfig, metadata: OpenMetadata, - global_profiler_config: Optional[Settings], + global_profiler_config: Settings | None, status: Status, ) -> None: super().__init__(config, metadata, global_profiler_config, status) diff --git a/skills/connector-building/references/connection-type-guide.md b/skills/connector-building/references/connection-type-guide.md index a5239df33976..9139a5840441 100644 --- a/skills/connector-building/references/connection-type-guide.md +++ b/skills/connector-building/references/connection-type-guide.md @@ -52,7 +52,7 @@ Add the `MultiDBSource` mixin when a single server connection can access multipl ```python class MyDbSource(CommonDbSourceService, MultiDBSource): - def get_configured_database(self) -> Optional[str]: + def get_configured_database(self) -> str | None: return self.service_connection.databaseName def get_database_names_raw(self) -> Iterable[str]: diff --git a/skills/standards/code_style.md b/skills/standards/code_style.md index 1da0e24ea17a..bb09aedfed66 100644 --- a/skills/standards/code_style.md +++ b/skills/standards/code_style.md @@ -8,8 +8,8 @@ Order: stdlib → third-party → OpenMetadata generated → OpenMetadata intern ```python import json import traceback +from collections.abc import Iterable from functools import partial -from typing import Iterable, Optional import requests from sqlalchemy.engine import Engine @@ -30,7 +30,7 @@ from metadata.utils.logger import ingestion_logger ### Type Annotations - All function signatures must have type annotations -- Use `Optional[T]` for nullable fields +- Use `T | None` for nullable fields - Use `Iterable[Either[...]]` for yield methods - Import types from `typing` or `collections.abc` @@ -44,7 +44,7 @@ from metadata.utils.logger import ingestion_logger When defining Pydantic models for API responses with aliased fields: - Always set `model_config = ConfigDict(populate_by_name=True)` when using `Field(alias=...)` — without it, constructing instances with Python attribute names raises `ValidationError` -- Use `Optional[T]` with `Field(None, alias=...)` for nullable fields +- Use `T | None` with `Field(None, alias=...)` for nullable fields - Create list response wrapper models inheriting from a base OData/pagination response ```python @@ -55,11 +55,11 @@ class MyApiReport(BaseModel): id: str = Field(alias="Id") name: str = Field(alias="Name") - description: Optional[str] = Field(None, alias="Description") + description: str | None = Field(None, alias="Description") class MyApiListResponse(BaseModel): - value: List[MyApiReport] = Field(default_factory=list) + value: list[MyApiReport] = Field(default_factory=list) ``` ### Error Messages diff --git a/skills/standards/memory.md b/skills/standards/memory.md index 22d520ed086c..4e54adeeff4a 100644 --- a/skills/standards/memory.md +++ b/skills/standards/memory.md @@ -27,14 +27,16 @@ def read_config(self, path: str) -> dict: ```python MAX_METADATA_FILE_SIZE = 50 * 1024 * 1024 # 50 MB -def read_metadata_file(self, path: str) -> Optional[dict]: +def read_metadata_file(self, path: str) -> dict | None: """Read a metadata/manifest file with size guard.""" head = self.client.head_object(Bucket=self.bucket, Key=path) size = head["ContentLength"] if size > MAX_METADATA_FILE_SIZE: logger.warning( - f"Skipping {path}: file size {size} exceeds limit " - f"{MAX_METADATA_FILE_SIZE}" + "Skipping %s: file size %s exceeds limit %s", + path, + size, + MAX_METADATA_FILE_SIZE, ) return None response = self.client.get_object(Bucket=self.bucket, Key=path) diff --git a/skills/standards/performance.md b/skills/standards/performance.md index 226ad467126a..cb8523cabca0 100644 --- a/skills/standards/performance.md +++ b/skills/standards/performance.md @@ -191,7 +191,7 @@ def _get(self, endpoint): response = self._session.get(f"{self._base_url}{endpoint}") if response.status_code == 429: retry_after = int(response.headers.get("Retry-After", 30)) - logger.warning(f"Rate limited, retrying after {retry_after}s") + logger.warning("Rate limited, retrying after %ss", retry_after) raise RateLimitError(retry_after) response.raise_for_status() return response.json() diff --git a/skills/standards/sql.md b/skills/standards/sql.md index 27c0c3c94437..bd08a63b6f00 100644 --- a/skills/standards/sql.md +++ b/skills/standards/sql.md @@ -139,7 +139,7 @@ Add `MultiDBSource` mixin when the database server hosts multiple independent da ```python class MyDbSource(CommonDbSourceService, MultiDBSource): - def get_configured_database(self) -> Optional[str]: + def get_configured_database(self) -> str | None: return self.service_connection.databaseName def get_database_names_raw(self) -> Iterable[str]: