Skip to content

Add stubs for RPi.GPIO #11345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Add stubs for RPi.GPIO #11345

merged 2 commits into from
Jan 30, 2024

Conversation

fperrin
Copy link
Contributor

@fperrin fperrin commented Jan 30, 2024

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.

This comment has been minimized.

Copy link
Collaborator

@srittau srittau left a comment

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.

from typing_extensions import TypeAlias

VERSION: str
RPI_INFO: dict[str, Any]
Copy link
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
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
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
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

Copy link
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
Copy link
Collaborator

Avasam commented Mar 13, 2024

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