refactor: Fix MRO of schema stream attribute#3621
Conversation
Reviewer's GuideRefactors how stream schemas are exposed by turning Class diagram for the refactored stream schema descriptor systemclassDiagram
direction LR
class SchemaSource~_TKey~ {
<<abstract>>
+preprocess_schema(raw_schema: Schema) Schema
+get_schema(key: _TKey, key_properties: Sequence~str~) Schema
}
class StreamSchema~_TKey~ {
-schema_source: SchemaSource~_TKey~ | None
-key: _TKey | None
+__init__(schema_source: SchemaSource~_TKey~ | None = None, key: _TKey | None = None)
+__get__(obj: Stream | None, objtype: type~Stream~ | None = None) Schema | StreamSchema~_TKey~
+__set__(obj: Stream, _value: object) void
+get_stream_schema(stream: Stream, stream_class: type~Stream~) Schema
}
class _InstanceSchemaDescriptor {
<<descriptor>>
+__init__()
+get_stream_schema(stream: Stream, stream_class: type~Stream~) Schema
}
class Stream {
<<abstract>>
+schema: StreamSchema~any~ $class
-_schema: dict | None
+__init__(tap: Tap, schema: dict | None, name: str)
+primary_keys: Sequence~str~
+schema_filepath: Path | Traversable | None
}
class SQLStream {
<<abstract>>
+connector_class: type~SQLConnector~
+supports_nulls_first: bool
+__init__(tap: Tap, catalog_entry: CatalogEntry, name: str)
+metadata: MetadataMapping
+tap_stream_id: str
}
class FilesystemStream {
+filesystem: AbstractFileSystem
-_schema: dict | None
+__init__(tap: Tap, name: str, filesystem: AbstractFileSystem)
+_get_full_schema() dict~str, any~
}
class DiscoveryError {
}
StreamSchema~_TKey~ --> SchemaSource~_TKey~ : uses
_InstanceSchemaDescriptor --|> StreamSchema~str~ : extends
Stream "1" --> "1" StreamSchema~any~ : schema
SQLStream --|> Stream : extends
FilesystemStream --|> Stream : extends
StreamSchema~_TKey~ ..> DiscoveryError : may raise
_InstanceSchemaDescriptor ..> DiscoveryError : may raise
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
3 files changed± genindex.html± classes/singer_sdk.Stream.html± classes/singer_sdk.sql.SQLStream.html |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (69.23%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3621 +/- ##
==========================================
- Coverage 93.86% 93.83% -0.03%
==========================================
Files 73 73
Lines 5947 5955 +8
Branches 729 732 +3
==========================================
+ Hits 5582 5588 +6
Misses 271 271
- Partials 94 96 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
137b41f to
ec5aa1e
Compare
Summary by Sourcery
Refactor stream schema handling to use a descriptor-based
StreamSchemaon the baseStreamclass and fix method resolution order so schema access works consistently for instances and subclasses.New Features:
schemadescriptor onStreambacked byStreamSchemaand a fallback instance schema descriptor.Bug Fixes:
schemaattribute on streams correctly resolves via MRO and falls back to instance-level schema when no class-level schema is defined.schemadescriptor read-only on instances and raising an error if no schema source is configured.Enhancements:
Selftyping to theStreamSchemadescriptor for better static type checking.