Skip to content

Conversation

@yochem
Copy link
Contributor

@yochem yochem commented Dec 19, 2025

This is the first step of the work done in #144 and simply wraps the SpiDev class defined in the C module.

Please note that although this PR already looks quite large, most of the code looks like this:

def open_path(self, path: str) -> None:
    self._cmod.open_path(path)

Where the C module method is simply wrapped.

TODO:

  • Remove the module definition stuff from the C module
  • Test building of the C module

Next steps (after this PR):

  • Add Python goodies (__str__ and friends)
  • Proper subclass of one of the I/O base classes
  • Add the new interface methods, soft deprecating old ones
  • Docstrings

@yochem yochem force-pushed the pyclass-skeleton branch 5 times, most recently from 65ab548 to df6f718 Compare December 22, 2025 14:31
@yochem yochem marked this pull request as ready for review December 22, 2025 14:31
@yochem
Copy link
Contributor Author

yochem commented Dec 22, 2025

The skeleton is ready for review. It tries to do as few as possible by simply wrapping all properties and methods of the original SpiDev class.

  • Original (C module's) SpiDev class is renamed to spidev._spidev._SpiDev
  • Implementation moved to spidev/_spidev.c
  • New wrapper is spidev.SpiDev and defined in spidev/_spi.py
  • Both are 100% type annotated (the C module using a .pyi stub)

I was wondering if you want to merge this directly into master, or create a new branch where we'll continue lifting stuff from C to the wrapper and add the pythonic interface? Mostly with the suggestions from #144.

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.

1 participant