Skip to content

more type annotations changes e.g. feat(ldap.schema.models): add missing type annotation for syntax_len - #672

Open
spaceone wants to merge 8 commits into
mainfrom
feat/schema-type-annotation
Open

spaceone wants to merge 8 commits into
mainfrom
feat/schema-type-annotation

Conversation

@spaceone

Copy link
Copy Markdown
Contributor

No description provided.

@spaceone spaceone changed the title feat(ldap.schema.models): add missing type annotation for syntax_len more type annotations changes e.g. feat(ldap.schema.models): add missing type annotation for syntax_len Oct 17, 2026
@spaceone
spaceone force-pushed the feat/schema-type-annotation branch from b9da2f8 to df75b45 Compare October 17, 2026 13:31
@spaceone

Copy link
Copy Markdown
Contributor Author

Please have a look - only the syncrepl change is questionable: it adds protocol semantics explicitly which exists implicitly. We can skip it as well.

Comment thread Lib/ldap/ldapobject.py Outdated
self,
msgid: int = ldap.RES_ANY,
all: int = 1,
all: bool = True,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These bool annotations reject supported calls such as result(all=0), result4(all=ldap.MSG_ALL), and search_s(.., attrsonly=1).
Could we retain int for the existing integer flag parameters while keeping the boolean defaults? That also preserves MSG_RECEIVED (whose value is 2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, thanks I didn't knew about LDAP_MSG_RECEIVED yet - it's useful for my async stuff.

I would change it into bool | int = True/False then, because that makes the intention more clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the type alias? See 1f574ef

LDAPMessageMode = Literal[0, 1, 2] | bool
"""The type of a message retrieval mode (:const:`ldap.MSG_ONE`, :const:`ldap.MSG_ALL`, or :const:`ldap.MSG_RECEIVED`)."""

or should bool be dropped?

@spaceone
spaceone force-pushed the feat/schema-type-annotation branch from 1f574ef to 4863a85 Compare October 21, 2026 17:25
the attributes must be annotated as ClassVar as the parent defines it as
such.
Type checkers complain about the generated stubgens:

> error: Cannot override class variable (previously declared on base class "SchemaElement") with instance variable
> error[invalid-attribute-override] Invalid override of attribute `schema_attribute`: instance variable cannot override class variable `SchemaElement.schema_attribute`
The schema is retrieved from a LDAP search whichs primary attributes are
`bytes`. `str` compatibility is just added on top.

Issue: #647
Issue: #647
@spaceone spaceone added this to the 3.5.0 milestone Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants