Add py.typed and annotate most of the classes and methods #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Supersedes #205, fixes #187.
I annotated types in most of the classes and methods instead of keeping it unannotated and just plugging
mypycomplaints with# type: ignore. With some notable exceptions:# type: ignorehere and there because of this, this could be avoided using some base class forConnectionandaio.Connection, and also come common base class forConandaio.Coninstead of just inheriting one from the other.TypeVars forConand replies. I tried to keep all of this compatible with python 3.9, so I didn't use any recent additions to typing system. This also caused some# type: ignores because advanced parameter annotations are not available. In my opinion, callbacks with noeventargument should be deprecated though.I also used a contravariant
TypeVarto annotate theIpcBaseEventargument for event handlers. This makes it possible for the users of this library to annotate their callbacks with actual event types they are expecting to receive (WindowEventfor example).