adafruit / adafruit/Adafruit_CircuitPython_MCP2515

Missing Type Annotations

Open
#11 5 comments 0 reactions 0 assignees View on GitHub
documentation Hacktoberfest
Dominant language
Python
Stars
29
Forks
16
PR merge metrics
No merged PRs in 30d

Description

There are missing type annotations for some functions in this library.

The `typing` module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:

```python
try:
from typing import List, Tuple
except ImportError:
pass
```

Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:

```python
def wrap_text_to_pixels(
string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:
```
If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: `Sharing docs on ReadTheDocs` and `Check your code with pre-commit` contain the tools to install and commands to run locally to run the checks.

If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @foamyguy and @kattni or reach out to us on Discord: https://adafru.it/discord in the `#circuitpython-dev` channel.

The following locations are reported by mypy to be missing type annotations:

- [ ] adafruit_mcp2515/timer.py:11
- [ ] adafruit_mcp2515/timer.py:26
- [ ] adafruit_mcp2515/canio/\_\_init\_\_.py:14
- [ ] adafruit_mcp2515/canio/\_\_init\_\_.py:37
- [ ] adafruit_mcp2515/canio/\_\_init\_\_.py:77
- [ ] adafruit_mcp2515/canio/\_\_init\_\_.py:90
- [ ] adafruit_mcp2515/canio/\_\_init\_\_.py:147
- [ ] adafruit_mcp2515/\_\_init\_\_.py:192
- [ ] adafruit_mcp2515/\_\_init\_\_.py:335
- [ ] adafruit_mcp2515/\_\_init\_\_.py:372
- [ ] adafruit_mcp2515/\_\_init\_\_.py:425
- [ ] adafruit_mcp2515/\_\_init\_\_.py:476
- [ ] adafruit_mcp2515/\_\_init\_\_.py:489
- [ ] adafruit_mcp2515/\_\_init\_\_.py:493
- [ ] adafruit_mcp2515/\_\_init\_\_.py:498
- [ ] adafruit_mcp2515/\_\_init\_\_.py:515
- [ ] adafruit_mcp2515/\_\_init\_\_.py:549
- [ ] adafruit_mcp2515/\_\_init\_\_.py:622
- [ ] adafruit_mcp2515/\_\_init\_\_.py:638
- [ ] adafruit_mcp2515/\_\_init\_\_.py:652
- [ ] adafruit_mcp2515/\_\_init\_\_.py:662
- [ ] adafruit_mcp2515/\_\_init\_\_.py:682
- [ ] adafruit_mcp2515/\_\_init\_\_.py:721
- [ ] adafruit_mcp2515/\_\_init\_\_.py:739
- [ ] adafruit_mcp2515/\_\_init\_\_.py:875
- [ ] adafruit_mcp2515/\_\_init\_\_.py:881

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the mypy-reported locations in adafruit_mcp2515/timer.py, adafruit_mcp2515/canio/__init__.py, and adafruit_mcp2515/__init__.py. Review the existing wrap_text_to_pixels example and the project's CI guidance, then run the stated checks locally. Done means all listed functions have argument and return annotations, with the typing import safe on CircuitPython devices, and the checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.