Repository navigation
Commit 154288f
authored
Closes #3100
## Rationale for this change
`FileFormatModel` had only abstract methods (no shared implementation),
so an `ABC` was heavier than needed. This PR converts it to
`typing.Protocol`, which is the more Pythonic pattern for a pure
interface. `FileFormatWriter` remains an `ABC` since it has shared
`__enter__`/`__exit__`/`result` implementations that inheritance carries
for free. `FileFormatFactory` is unchanged - it matches the existing
`AuthManagerFactory` pattern.
## Changes
New format implementations can now conform structurally without
inheriting from `FileFormatModel`. Net: 2 `ABC`s → 1 `ABC` + 1
`Protocol`. No signature change for existing callers;
`ParquetFormatModel(FileFormatModel)` inheritance is retained
(`Protocol` supports explicit conformance).
## Are these changes tested?
Yes. `tests/io/test_fileformat.py` adds two tests using a shared
`_StructuralModel` helper:
- `test_file_format_model_is_protocol` - a structurally-conforming class
(no inheritance) passes `isinstance()` against `FileFormatModel`.
- `test_structural_model_works_with_factory` - a structurally-conforming
class can be registered and retrieved via `FileFormatFactory`
end-to-end.
## Are there any user-facing changes?
No. Default behavior is unchanged.
1 parent 23aa9a9 commit 154288f
2 files changed
Lines changed: 38 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | | - | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | 153 | | |
155 | 154 | | |
| 155 | + | |
156 | 156 | | |
157 | | - | |
158 | 157 | | |
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
165 | | - | |
166 | 164 | | |
167 | 165 | | |
| 166 | + | |
168 | 167 | | |
169 | 168 | | |
170 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
0 commit comments