You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, x509.name.NameAttribute.value is typed as str | bytes, as it might be bytes for X500_UNIQUE_IDENTIFIER. To improve type checking, I'd suggest to use two subclasses of NameAttribute (say StringNameAttribute and BytesNameAttribute) which use correct typing for value. Now @overrides can be used for get_attributes_for_oid to deliver list[BytesNameAttribute] or list[StringNameAttribute] respectively.
I could draft a PR if the idea is generally accepted, just let me know :)
The text was updated successfully, but these errors were encountered:
In practice, lots of uses like iterating a name won't have a known type.
I'm also a bit concerned about extensibility if there's other non-string
OIDs.
While I'm not positive this makes sense for this reason, I'd be interested
to try it out. Perhaps without subclassing though
On Thu, Nov 28, 2024, 6:10 AM Patrick Rauscher ***@***.***> wrote:
Currently, x509.name.NameAttribute.value is typed as str | bytes, as it
might be bytes for X500_UNIQUE_IDENTIFIER. To improve type checking, I'd
suggest to use two subclasses of NameAttribute (say StringNameAttribute
and BytesNameAttribute) which use correct typing for value. Now @OVERRIDES
can be used for get_attributes_for_oid to deliver list[BytesNameAttribute]
or list[StringNameAttribute] respectively.
I could draft a PR if the idea is generally accepted, just let me know :)
—
Reply to this email directly, view it on GitHub
<#12056>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBD7PKIM7RUHX6YXELD2C324FAVCNFSM6AAAAABSU4EHUKVHI2DSMVQWIX3LMV43ASLTON2WKOZSG4YDCNZZGQYTMOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
Currently,
x509.name.NameAttribute.value
is typed asstr | bytes
, as it might bebytes
forX500_UNIQUE_IDENTIFIER
. To improve type checking, I'd suggest to use two subclasses ofNameAttribute
(sayStringNameAttribute
andBytesNameAttribute
) which use correct typing forvalue
. Now@override
s can be used forget_attributes_for_oid
to deliverlist[BytesNameAttribute]
orlist[StringNameAttribute]
respectively.I could draft a PR if the idea is generally accepted, just let me know :)
The text was updated successfully, but these errors were encountered: