@@ -27,8 +27,12 @@ nothing about whether a shard's pipelines are well formed and silencing
2727them would lose a real judgment. A * required* one stops the entity,
2828because there is no honest reading of a ` blosc ` whose level is a string.
2929
30- The type judgment is read off the entity's own fields rather than
31- written twice. Which members exist, which may be left out (the type
30+ An entity has the shape of its metadata: its name is the class, and its
31+ configuration, for an entity that adds ` Configured ` beside its kind, is
32+ a frozen ` Configuration ` record named in the one field ` configuration `
33+ -- ` class GzipCodec(BytesBytesCodec, Configured) ` with `configuration:
34+ GzipOptions`. The type judgment is read off the record's fields rather
35+ than written twice. Which members exist, which may be left out (the type
3236admits ` UNSET ` ), and how each is type-checked all follow from the field
3337annotations: ` int ` , ` float ` for any number, ` bool ` , ` str ` , a ` Literal `
3438of names, the JSON-value alias, an array homogeneous or fixed, a union
@@ -37,17 +41,17 @@ dataclass, an object of undeclared keys as `Mapping[str, V]`, a
3741` NewType ` as the type it names, and a nested metadata field, written as
3842its kind with ` Opaque ` . That covers
3943every member this package models; an annotation outside them is refused
40- at registration, and ` Annotated[str, FROM_NAME] ` marks the one field
41- carried by the envelope's name rather than a configuration key ( ` r<N> ` ),
42- which ` coerce ` fills from the envelope. Whether a configuration is required
43- follows too, since the spec ties the bare-name spelling to whether any member is
44- required.
44+ at registration, and ` Annotated[str, FROM_NAME] ` marks the one field of
45+ the entity itself, carried by the envelope's name rather than a
46+ configuration key ( ` r<N> ` ), which ` coerce ` fills from the envelope.
47+ Whether a configuration is required follows too, since the spec ties the
48+ bare-name spelling to whether any member is required.
4549
46- Nothing is derived from the fields ahead of time: ` coerce ` parses a
47- configuration against them as it reads it. Field annotations are
48- resolved per class, skipping class variables by text, so a ` ClassVar `
49- naming something imported only for the type checker cannot fail
50- registration.
50+ The record's parser and writer are compiled once per class from its
51+ annotations, and ` coerce ` runs the parser over the configuration as it
52+ reads it. Field annotations are resolved per class, skipping class
53+ variables by text, so a ` ClassVar ` naming something imported only for
54+ the type checker cannot fail registration.
5155
5256One diagnostic became more precise: a malformed ` [value, count] ` pair in
5357a rectilinear grid is now reported at the offending element inside the
@@ -57,10 +61,10 @@ An entity that contains other entities declares the field --
5761` data_type: DataTypeEntity | Opaque ` , `codecs: tuple[ CodecEntity |
5862Opaque, ...] `, a record holding one -- and the contained entity is read
5963through the scope the containing one is read in, at whatever depth the
60- annotation puts it. Writing it back and putting it in canonical form
61- are the containing entity's own two lines, ` written(self.inner) ` in
62- ` to_json ` and ` replace(self, inner=canonicalized( self.inner))` in
63- ` canonical ` , the same way it writes and simplifies its own members.
64+ annotation puts it. Writing it back is the base's, through the contained
65+ entity's own ` to_json ` ; putting it in canonical form is the containing
66+ entity's one line, ` self.with_configuration( inner=self.inner.canonical( ))`
67+ in ` canonical ` , the same way it simplifies its own members.
6468` canonical ` is the entity itself by default, overridden where two
6569spellings of its members mean the same -- a rectilinear dimension's
6670run-length encoding, a ` typesize ` that ` noshuffle ` ignores. A field
@@ -69,19 +73,19 @@ refused at registration: no scope could place the one, and the other
6973lies about what the field holds when the inner name is out of scope.
7074
7175Everything finer than a type -- a bound, a rule about one member, a
72- rule that reads two members together -- is a function of the entity's
73- instance, in plain code, that yields each problem as it finds it,
74- located relative to the configuration, and is bound on the class as
75- ` problems ` . The constructor stops at the first, so ` BloscCodec(clevel=99) `
76- raises ` MetadataValidationError ` ; ` coerce ` runs it to the end and
77- reports every problem in the document; a consumer holding an entity may
78- run it too, stopping or collecting as it needs. The space of
76+ rule that reads two members together -- is the record's own ` problems ` ,
77+ in plain code, yielding each problem as it finds it, located relative
78+ to the configuration. The entity's constructor stops at the first, so
79+ ` BloscCodec(BloscOptions( clevel=99)) ` raises ` MetadataValidationError ` ;
80+ ` coerce ` asks the record before it builds anything and reports every
81+ problem in the document; a reader with a record asks it too, stopping
82+ or collecting as it needs. The space of
7983refinements is too wide to capture statically, and reading them in one
8084place per entity is what will show where a shared form is worth having.
8185
8286The set of annotation shapes the parser reads is closed: the shapes
8387JSON takes, and no others. A field annotation outside them is refused
8488at registration, and the field is written as one of them instead, with
85- any finer rule in the function bound as ` problems ` . The parser is one module that knows
89+ any finer rule in the record's ` problems ` . The parser is one module that knows
8690nothing of entities; the entity layer hands it the one shape of its own,
8791a field holding an entity, as a leaf it reads at any depth.
0 commit comments