Skip to content

feat: add type annotations to all public API#28

Open
algojogacor wants to merge 1 commit into
DanielSank:masterfrom
algojogacor:master
Open

feat: add type annotations to all public API#28
algojogacor wants to merge 1 commit into
DanielSank:masterfrom
algojogacor:master

Conversation

@algojogacor
Copy link
Copy Markdown

Summary

Add comprehensive type annotations to all public API surfaces of the observed library. This improves IDE support, enables static type checking (mypy/pyright), and makes the codebase more maintainable.

Changes

  • Added from typing import Any, Callable, Dict, Optional, Tuple, Union import
  • Annotated all class __init__, __call__, and method signatures with proper types
  • Annotated module-level functions: observable_function, get_observable_method, observable_method

Classes annotated:

  • ObserverFunction — function + weakref wrapper
  • ObserverBoundMethod — bound method + weakref wrapper
  • ObservableFunction — observed function with add/discard observer
  • ObservableBoundMethod — observed bound method
  • ObservableMethodManager_PersistOnInstances / PersistOnDescriptor — descriptors
  • ObservableUnboundMethod — unbound method wrapper
  • CleanupHandler — weakref cleanup callback

Testing

  • All 5 existing tests pass: pytest observed_test.py -v
  • Module imports cleanly: python3 -c "import observed"
  • No functional changes — annotations only

Closes #20

Add comprehensive type annotations to the observer pattern library:
- ObserverFunction, ObserverBoundMethod, ObservableFunction
- ObservableBoundMethod, ObservableMethodManager_PersistOnInstances
- ObservableMethodManager_PersistOnDescriptor, ObservableUnboundMethod
- CleanupHandler, observable_function, observable_method

All 5 existing tests pass with annotations applied.

Closes DanielSank#20
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.

Add type annotations

1 participant