Repository navigation
Conversation
2cccfa3 to
23b4e23
Compare
23b4e23 to
b29584e
Compare
|
|
||
|
|
||
| class Entry(EntryBase): | ||
| class Entry(UserDict[str, list[bytes]]): |
There was a problem hiding this comment.
After entry |= {'sn': [b'Smith']}, sn appears in iteration, but entry['sn'] and dict(entry) raise KeyError. The inherited UserDict.__ior__ writes directly to data, skipping Entry's attribute-name bookkeeping. Could we override it to call self.update(other) and return self?
There was a problem hiding this comment.
Fancy stuff. I added __ior__.
| self._set_attrs(tokens, schema_element_attributes) | ||
| self.set_id(tokens[1]) | ||
| opts = extract_tokens(tokens, self.token_defaults) | ||
| self._set_attrs(opts) |
There was a problem hiding this comment.
I think we need to retain the existing _set_attrs(tokens, opts) signature. Subclasses overriding that method now fail during construction because this call supplies only opts. Keeping both arguments preserves those subclasses while still allowing the TypedDict changes.
There was a problem hiding this comment.
Ok, changed it so that it has the unused token parameter.
python-ldap provides classes for all schema elements which exists to my knowledge.
So, I hope there is not a single subclass out there.
| self.names = d.get('NAME', ()) | ||
| def _set_attrs(self, opts: TokenDefaults) -> None: | ||
| opts = cast(SchemaElementTokens, opts) | ||
| self.names = opts['NAME'] |
There was a problem hiding this comment.
Should we keep opts.get('NAME', ()) here? A custom SchemaElement with token_defaults = {'DESC': (None,)} worked previously but now raises KeyError('NAME') during construction. IMO, an absent NAME should continue to produce an empty names tuple.
There was a problem hiding this comment.
All internal schema elements define NAME - but if there is any subclass our there, I added that fallback.
Introduce a generic `_get_elements()` helper to preserve concrete schema element types, eliminate repeated casts or asserts and improve type safety.
add overloads for `get_inheritedattr()` using Literal attribute names to provide more precise return types for known schema attributes.
b29584e to
9317cb8
Compare
Reverts: 4277c52