Giter VIP home page Giter VIP logo

adafruit_circuitpython_typing's Introduction

Introduction

Documentation Status

Discord

Build Status

Code Style: Black

Definitions not in the standard typing module that are needed for type annotation of CircuitPython code.

This library is not needed at runtime for CircuitPython code, and does not need to be in the bundle.

Dependencies

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-typing

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-typing

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-typing

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_typing's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_typing's Issues

Image needs addititonal attrs

Originally noted here: adafruit/Adafruit_CircuitPython_RGB_Display#111 (comment)

The Image interface seems incomplete. With the changed import:

adafruit_rgb_display/rgb.py:68: error: "Image" has no attribute "convert" [attr-defined]
adafruit_rgb_display/rgb.py:213: error: "Image" has no attribute "rotate" [attr-defined]
adafruit_rgb_display/rgb.py:228: error: "Image" has no attribute "getpixel" [attr-defined]

I will still commit the change.

Image needs to have convert, rotate, and getpixel to satisfy those errors.

mpy zips don't contain mpy files

The assets on the release page that are supposed to contain mpy files for the library don't actually contain library files. Instead they contain only the examples:

image

This library is not typically used on devices so it's unlikely many people would be looking for it there, I guess that is why it has gone undiscovered.

I ran across a need to put it on a device to check something and noticed I'm unable to install it circup or grab the mpy files manually from the release assets.

Typing Examples Please

While taking on some "good first issues" the typing issues always seem to popup. Wthout a good prior knowledge of Python types and custom Circuit Python types such as i2c: busio.I2C it's actually much harder than expected. A place that lists most if not all the different types that can be used and examples of their syntax usage would be greatly appreciated. Having that live inside the typing repo as an example or multiple examples seems the most logical place.

Tekktrik suggested making this an issue and volunteered as tribute to do it.

1.1.0 requires python 3.8

typing.Protocol and the / syntax for function arguments both require python 3.8.
https://www.python.org/dev/peps/pep-0570/
https://www.python.org/dev/peps/pep-0544/

Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import adafruit_mprls
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/temp/venv/lib/python3.7/site-packages/adafruit_mprls.py", line 37, in <module>
    from adafruit_bus_device.i2c_device import I2CDevice
  File "/home/pi/temp/venv/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 13, in <module>
    from circuitpython_typing import ReadableBuffer, WriteableBuffer
  File "/home/pi/temp/venv/lib/python3.7/site-packages/circuitpython_typing/__init__.py", line 45
    def read(self, count: Optional[int] = None, /) -> Optional[bytes]:
                                                ^
SyntaxError: invalid syntax
>>>
>>> from typing import Protocol
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Protocol' from 'typing' (/usr/lib/python3.7/typing.py)
>>> 

Name of library causes inconsistency problems

This library is imported by import circuitpython_typing, which causes some issues, because the "circuitpython" prefix is often dropped for other libraries.

We could change it to import typing_circuitpython, and rename the repo to Adafruit_CircuitPython_Typing_CircuitPython, which is a mouthful, but would make its naming scheme consistent.

See discussion in #9.

Version 1.10.2 requires Python 3.8 again

Following in the footsteps of issue #3, the use of / notation has been reintroduced as of 1.10.2 and in doing so requires the use of Python 3.8. This is not a thing that can be guaranteed, especially when multiple devices are being built in a commercial capacity on limited hardware.

Rather than removing the / notation again, one option would be to restrict 1.10.2 to Python 3.8, and leave the current python requirements for older versions of the module.

Do not do mpy-cross builds of this library.

This library is not meant to run on CircuitPython directly. It does need mpy bundles build (they don't work anyway: #34), and now any CI PR build is failing because it's trying to run mpy-cross, but there's some syntax that's not compatible (def x(a, /):).

Now that we've factored out the build options, I don't see a way to force mpy-cross builds not to be done. There are parameters to the release actions that let you suppress certain bundles from being built, and those should be used. But there is no corresponding parameter in the build action. If you agree, we could open an appropriate issue in https://github.com/adafruit/circuitpython-build-tools.

@FoamyGuy @tekktrik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.