Skip to content

Add stubs for RPi.GPIO - #11345

Merged
srittau merged 2 commits into
python:mainfrom
fperrin:fperrin/RPI.GPIO
Jan 30, 2024
Merged

srittau merged 2 commits into
python:mainfrom
fperrin:fperrin/RPI.GPIO

Conversation

@fperrin

@fperrin fperrin commented Jan 30, 2024

Copy link
Copy Markdown
Contributor

Hi,

RPi.GPIO allows controlling Raspberry Pi GPIO channels in Python.

It provides all the basic functionality, but is unsuitable for real-time or timing critical applications. RPi.GPIO also does not support SPI, I²C or hardware PWM yet.

These stubs cover the entirety of the API exposed to Python.

The name of the project on PyPi is RPi.GPIO with a ., hopefully that won't cause any issue.

There is very little activity upstream, but that module is still useful, indeed it comes by default with Raspbian as provided with brand new Pi modules.

@github-actions

This comment has been minimized.

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, LGTM. Let's see whether it breaks our stub uploader.

Comment thread stubs/RPi.GPIO/RPi/GPIO/__init__.pyi Outdated
from typing_extensions import TypeAlias

VERSION: str
RPI_INFO: dict[str, Any]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This could be a TypedDict, but this can always be done later.

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.

Thank you for the review @srittau

I just tried that, and mypy failed with: https://github.com/fperrin/typeshed/actions/runs/7710857960/job/21015067471?pr=3

mypy --platform win32 --python-version 3.9 on the test cases for 'requests': FAILURE
...
File "mypy/fixup.py", line 127, in visit_symbol_table
File "mypy/lookup.py", line 31, in lookup_fully_qualified
AssertionError: Cannot find module for resource.struct_rusage

I really doubt this is related to my change, but who knows...

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.

@fperrin sorry about that! That's entirely unrelated, and it's very much on our minds right now: see

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.

in that case I'll ignore that failure and push Sebastian's suggestion

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit edd9922 into python:main Jan 30, 2024
@Avasam

Avasam commented Mar 13, 2024 •

Copy link
Copy Markdown
Collaborator

Cross-referencing the following for discoverability:

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.

4 participants