Skip to content

Add missing type annotations - #63

Open
jay23606 wants to merge 3 commits into
adafruit:mainfrom
jay23606:pr-go/43-missing-type-annotations
Open

jay23606 wants to merge 3 commits into
adafruit:mainfrom
jay23606:pr-go/43-missing-type-annotations

Conversation

@jay23606

@jay23606 jay23606 commented Nov 6, 2026

Copy link
Copy Markdown

Closes #43.

The problem

Many functions and methods in adafruit_framebuf.py have no type annotations, so mypy reports them as missing annotations.

The change

  • Wrap from typing import Any, Optional, Tuple, Union in try/except ImportError, because typing does not exist on CircuitPython.
  • Add parameter and return annotations to all 43 functions and methods in the module. The forward reference to FrameBuffer is a string, and annotations are not evaluated on CircuitPython.
  • No runtime behaviour changes; only def lines and the import block are touched.

Testing

Added tests/test_annotations.py, which uses inspect to check that every function and method in the module has a return annotation and annotated parameters. After the change, it passes:

python -m unittest discover -s tests -p "test_annotations.py"

Regression test: tests/test_annotations.py checks the annotations added by this change.

Fixes #43

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.

Missing Type Annotations

1 participant