mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-14 02:25:30 +00:00
Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfa0b69e93 | ||
|
|
f664757ef3 | ||
|
|
b747520d1c | ||
|
|
dcddf15d15 | ||
|
|
c64458d3b9 | ||
|
|
2a963b2a0b | ||
|
|
6df509b66e | ||
|
|
ac9585b7a5 | ||
|
|
0982d5d65b | ||
|
|
8e7f8c619e | ||
|
|
a0b3ba1d74 | ||
|
|
3dc28579ef | ||
|
|
923f9df3da | ||
|
|
1665b77847 | ||
|
|
96e7e5f3d0 | ||
|
|
1b51d71061 | ||
|
|
9d706d719a | ||
|
|
7c62a2833a | ||
|
|
03ee7f74e8 | ||
|
|
025147680c | ||
|
|
e467bb57c9 | ||
|
|
33d0c9fa49 | ||
|
|
e95386e23e | ||
|
|
a758eaa1db | ||
|
|
470eebd1c5 |
@@ -3,7 +3,19 @@
|
||||
|
||||
name: Build Python package and docs
|
||||
|
||||
on: [ push, pull_request ]
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- "*"
|
||||
pull_request:
|
||||
paths:
|
||||
- doc/**
|
||||
- src/**
|
||||
- poetry.lock
|
||||
- poetry.toml
|
||||
- pyproject.toml
|
||||
- setup.cfg
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -27,7 +27,10 @@ jobs:
|
||||
python-version: "3.10"
|
||||
- run: pipx install poetry
|
||||
- run: poetry install
|
||||
working-directory: ./jedi
|
||||
- run: poetry build
|
||||
working-directory: ./jedi
|
||||
- run: poetry publish
|
||||
working-directory: ./jedi
|
||||
env:
|
||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_PYBRICKS_JEDI_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Release @pybricks/jedi
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '@pybricks/jedi/**'
|
||||
|
||||
jobs:
|
||||
publish_ide_docs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# Setup .npmrc file to publish to npm
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: ./build.py
|
||||
working-directory: npm/jedi
|
||||
- run: yarn publish
|
||||
working-directory: npm/jedi/build
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
@@ -58,3 +58,4 @@ genrst/
|
||||
# Virtual environment
|
||||
######################
|
||||
.venv/
|
||||
.python-version
|
||||
|
||||
Vendored
+7
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"**/__pycache__": true,
|
||||
},
|
||||
|
||||
"python.autoComplete.extraPaths": ["jedi/src"],
|
||||
"python.formatting.provider": "black",
|
||||
"python.linting.pylintEnabled": false,
|
||||
@@ -49,4 +53,7 @@
|
||||
"python.analysis.extraPaths": [
|
||||
"jedi/src"
|
||||
],
|
||||
"yaml.schemas": {
|
||||
"https://json.schemastore.org/github-workflow.json": "file:///home/david/work/pybricks/pybricks-api/.github/workflows/build.yml"
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- Code auto-completion for `EssentialHub`.
|
||||
|
||||
### Fixed
|
||||
- Fixed some type hints in `parameters` submodule.
|
||||
|
||||
## 3.2.0b1-r3 - 2022-06-26
|
||||
|
||||
### Fixed
|
||||
- Fixed more type hints and improved compatibility with jedi.
|
||||
|
||||
## 3.2.0b1-r2 - 2022-06-24
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -26,6 +26,7 @@ HUB_FEATURES = {
|
||||
"technichub": {"technichub"} | FEATURES_MEDIUM,
|
||||
"primehub": {"primehub", "inventorhub"} | FEATURES_LARGE,
|
||||
"inventorhub": {"primehub", "inventorhub"} | FEATURES_LARGE,
|
||||
"essentialhub": {"essentialhub"} | FEATURES_LARGE,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# Pybricks documentation build configuration file
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
|
||||
# General information about the project.
|
||||
project = "pybricks"
|
||||
@@ -50,3 +51,7 @@ if "ide" in tags.tags: # noqa F821
|
||||
extensions.remove("sphinx.ext.mathjax") # noqa F821
|
||||
extensions.append("sphinx.ext.imgmath") # noqa F821
|
||||
html_theme_options["prev_next_buttons_location"] = None # noqa F821
|
||||
|
||||
# Build hub specific example scripts.
|
||||
sys.path.append(os.path.abspath("../../examples/pup/hub_common"))
|
||||
import make_examples # noqa F401, E402
|
||||
|
||||
@@ -44,25 +44,25 @@ Turning the light on and off
|
||||
****************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_cityhub/light_off.py
|
||||
../../../examples/pup/hub_common/build/light_off_cityhub.py
|
||||
|
||||
Changing brightness and using custom colors
|
||||
*******************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_cityhub/light_hsv.py
|
||||
../../../examples/pup/hub_common/build/light_hsv_cityhub.py
|
||||
|
||||
Making the light blink
|
||||
**********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_cityhub/light_blink.py
|
||||
../../../examples/pup/hub_common/build/light_blink_cityhub.py
|
||||
|
||||
Creating light animations
|
||||
*************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_cityhub/light_animate.py
|
||||
../../../examples/pup/hub_common/build/light_animate_cityhub.py
|
||||
|
||||
Button and system examples
|
||||
----------------------------------
|
||||
@@ -71,10 +71,10 @@ Using the stop button during your program
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_cityhub/button_single.py
|
||||
../../../examples/pup/hub_common/build/button_single_cityhub.py
|
||||
|
||||
Turning the hub off
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_cityhub/system_shutdown.py
|
||||
../../../examples/pup/hub_common/build/system_shutdown_cityhub.py
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
.. pybricks-requirements:: essentialhub
|
||||
|
||||
Essential Hub
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. figure:: ../../main/images/essentialhub.png
|
||||
:height: 15 em
|
||||
|
||||
|
||||
.. note:: Pybricks support for this hub is in beta.
|
||||
Check the `installation instructions`_ to try it out.
|
||||
The following functions may change before the final release.
|
||||
|
||||
.. _installation instructions: https://pybricks.com/install/
|
||||
|
||||
|
||||
.. autoclass:: pybricks.hubs.EssentialHub
|
||||
:no-members:
|
||||
|
||||
.. rubric:: Using the hub status light
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.light.on
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.light.off
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.light.blink
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.light.animate
|
||||
|
||||
.. rubric:: Using the button
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.button.pressed
|
||||
|
||||
.. rubric:: Using the IMU
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.up
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.tilt
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.acceleration
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.angular_velocity
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.heading
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.reset_heading
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.battery.voltage
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.battery.current
|
||||
|
||||
.. rubric:: Getting the charger status
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.charger.connected
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.charger.current
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.charger.status
|
||||
|
||||
.. rubric:: System control
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.system.set_stop_button
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.system.name
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.system.shutdown
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.system.reset_reason
|
||||
|
||||
Status light examples
|
||||
---------------------
|
||||
|
||||
Turning the light on and off
|
||||
****************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/light_off_essentialhub.py
|
||||
|
||||
Changing brightness and using custom colors
|
||||
*******************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/light_hsv_essentialhub.py
|
||||
|
||||
Making the light blink
|
||||
**********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/light_blink_essentialhub.py
|
||||
|
||||
Creating light animations
|
||||
*************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/light_animate_essentialhub.py
|
||||
|
||||
IMU examples
|
||||
---------------
|
||||
|
||||
Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_up_essentialhub.py
|
||||
|
||||
|
||||
Reading the tilt value
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_tilt_essentialhub.py
|
||||
|
||||
Using a custom hub orientation
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_tilt_blast_essentialhub.py
|
||||
|
||||
Reading acceleration and angular velocity vectors
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_read_vector_essentialhub.py
|
||||
|
||||
Reading acceleration and angular velocity on one axis
|
||||
*****************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_read_scalar_essentialhub.py
|
||||
|
||||
System examples
|
||||
----------------------------------
|
||||
|
||||
Using the stop button during your program
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/button_single_essentialhub.py
|
||||
|
||||
Turning the hub off
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/system_shutdown_essentialhub.py
|
||||
@@ -13,6 +13,7 @@
|
||||
cityhub
|
||||
technichub
|
||||
primehub
|
||||
essentialhub
|
||||
|
||||
.. pybricks-classlink:: MoveHub
|
||||
|
||||
@@ -44,3 +45,8 @@
|
||||
:height: 10 em
|
||||
:target: primehub.html
|
||||
|
||||
.. pybricks-classlink:: EssentialHub
|
||||
|
||||
.. figure:: ../../main/images/essentialhub.png
|
||||
:height: 10 em
|
||||
:target: essentialhub.html
|
||||
|
||||
@@ -56,13 +56,13 @@ Turning the light on and off
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/light_off.py
|
||||
../../../examples/pup/hub_common/build/light_off_movehub.py
|
||||
|
||||
Making the light blink
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/light_blink.py
|
||||
../../../examples/pup/hub_common/build/light_blink_movehub.py
|
||||
|
||||
IMU examples
|
||||
---------------
|
||||
@@ -71,7 +71,7 @@ Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/imu_up.py
|
||||
../../../examples/pup/hub_common/build/imu_up_movehub.py
|
||||
|
||||
Reading acceleration
|
||||
**************************************************
|
||||
@@ -86,10 +86,10 @@ Using the stop button during your program
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/button_single.py
|
||||
../../../examples/pup/hub_common/build/button_single_movehub.py
|
||||
|
||||
Turning the hub off
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/system_shutdown.py
|
||||
../../../examples/pup/hub_common/build/system_shutdown_movehub.py
|
||||
|
||||
+10
-10
@@ -119,25 +119,25 @@ Turning the light on and off
|
||||
****************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_off.py
|
||||
../../../examples/pup/hub_common/build/light_off_primehub.py
|
||||
|
||||
Changing brightness and using custom colors
|
||||
*******************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_hsv.py
|
||||
../../../examples/pup/hub_common/build/light_hsv_primehub.py
|
||||
|
||||
Making the light blink
|
||||
**********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_blink.py
|
||||
../../../examples/pup/hub_common/build/light_blink_primehub.py
|
||||
|
||||
Creating light animations
|
||||
*************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/light_animate.py
|
||||
../../../examples/pup/hub_common/build/light_animate_primehub.py
|
||||
|
||||
Matrix display examples
|
||||
-----------------------
|
||||
@@ -209,32 +209,32 @@ Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_up.py
|
||||
../../../examples/pup/hub_common/build/imu_up_primehub.py
|
||||
|
||||
|
||||
Reading the tilt value
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_tilt.py
|
||||
../../../examples/pup/hub_common/build/imu_tilt_primehub.py
|
||||
|
||||
Using a custom hub orientation
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_tilt_blast.py
|
||||
../../../examples/pup/hub_common/build/imu_tilt_blast_primehub.py
|
||||
|
||||
Reading acceleration and angular velocity vectors
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_read_vector.py
|
||||
../../../examples/pup/hub_common/build/imu_read_vector_primehub.py
|
||||
|
||||
Reading acceleration and angular velocity on one axis
|
||||
*****************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/imu_read_scalar.py
|
||||
../../../examples/pup/hub_common/build/imu_read_scalar_primehub.py
|
||||
|
||||
System examples
|
||||
----------------------------------
|
||||
@@ -249,7 +249,7 @@ Turning the hub off
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_primehub/system_shutdown.py
|
||||
../../../examples/pup/hub_common/build/system_shutdown_primehub.py
|
||||
|
||||
.. _installation instructions: https://pybricks.com/install/
|
||||
|
||||
|
||||
@@ -58,25 +58,25 @@ Turning the light on and off
|
||||
****************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/light_off.py
|
||||
../../../examples/pup/hub_common/build/light_off_technichub.py
|
||||
|
||||
Changing brightness and using custom colors
|
||||
*******************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/light_hsv.py
|
||||
../../../examples/pup/hub_common/build/light_hsv_technichub.py
|
||||
|
||||
Making the light blink
|
||||
**********************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/light_blink.py
|
||||
../../../examples/pup/hub_common/build/light_blink_technichub.py
|
||||
|
||||
Creating light animations
|
||||
*************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/light_animate.py
|
||||
../../../examples/pup/hub_common/build/light_animate_technichub.py
|
||||
|
||||
IMU examples
|
||||
---------------
|
||||
@@ -85,32 +85,32 @@ Testing which way is up
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_up.py
|
||||
../../../examples/pup/hub_common/build/imu_up_technichub.py
|
||||
|
||||
|
||||
Reading the tilt value
|
||||
********************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_tilt.py
|
||||
../../../examples/pup/hub_common/build/imu_tilt_technichub.py
|
||||
|
||||
Using a custom hub orientation
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_tilt_blast.py
|
||||
../../../examples/pup/hub_common/build/imu_tilt_blast_technichub.py
|
||||
|
||||
Reading acceleration and angular velocity vectors
|
||||
**************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_read_vector.py
|
||||
../../../examples/pup/hub_common/build/imu_read_vector_technichub.py
|
||||
|
||||
Reading acceleration and angular velocity on one axis
|
||||
*****************************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/imu_read_scalar.py
|
||||
../../../examples/pup/hub_common/build/imu_read_scalar_technichub.py
|
||||
|
||||
Button and system examples
|
||||
----------------------------------
|
||||
@@ -119,10 +119,10 @@ Using the stop button during your program
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/button_single.py
|
||||
../../../examples/pup/hub_common/build/button_single_technichub.py
|
||||
|
||||
Turning the hub off
|
||||
*****************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_technichub/system_shutdown.py
|
||||
../../../examples/pup/hub_common/build/system_shutdown_technichub.py
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
+2
-2
@@ -28,8 +28,8 @@ Pybricks Documentation
|
||||
|
||||
.. list-table::
|
||||
|
||||
* - **Technic Hub, City Hub, BOOST Move Hub**
|
||||
- **SPIKE Prime Hub / MINDSTORMS Inventor Hub**
|
||||
* - **Technic, City, and BOOST Move Hubs**
|
||||
- **SPIKE Essential/Prime, and MINDSTORMS Inventor Hubs**
|
||||
|
||||
* - .. figure:: ../main/images/powereduphubs.png
|
||||
:target: https://pybricks.com/install/technic-boost-city/
|
||||
|
||||
@@ -36,26 +36,12 @@ Basic types
|
||||
|
||||
.. pybricks-requirements::
|
||||
|
||||
..
|
||||
_comment: The int class is defined manually because otherwise the classmethod is hidden, see https://github.com/pybricks/pybricks-api/issues/86
|
||||
|
||||
.. autoclass:: ubuiltins.int
|
||||
:no-members:
|
||||
|
||||
.. automethod:: ubuiltins.int.to_bytes
|
||||
|
||||
.. classmethod:: from_bytes(bytes: Union[bytes, bytearray], byteorder: Literal["little", "big"]) -> int
|
||||
|
||||
Returns the integer represented by the given bytes.
|
||||
|
||||
:param bytes: The bytes to convert.
|
||||
:param byteorder: Determines the byte order used to represent the
|
||||
integer. If byteorder is ``"big"``, the most significant byte is at
|
||||
the beginning of the byte sequence. If byteorder is ``"little"``,
|
||||
the most significant byte is at the end of the byte sequence.
|
||||
|
||||
:returns: The integer represented by the bytes.
|
||||
|
||||
.. automethod:: ubuiltins.int.from_bytes
|
||||
|
||||
.. pybricks-requirements::
|
||||
|
||||
|
||||
@@ -41,6 +41,11 @@ Side
|
||||
.. figure:: ../../main/images/orientation_inventorhub_label.png
|
||||
:height: 17 em
|
||||
|
||||
**Essential Hub**
|
||||
|
||||
.. figure:: ../../main/images/orientation_essentialhub_label.png
|
||||
:height: 17 em
|
||||
|
||||
**Move Hub**
|
||||
|
||||
.. figure:: ../../main/images/orientation_movehub_label.png
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
from pybricks.hubs import CityHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
from umath import sin, pi
|
||||
|
||||
# Initialize the hub.
|
||||
hub = CityHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Make the color RED grow faint and bright using a sine pattern.
|
||||
hub.light.animate([Color.RED * (0.5 * sin(i / 15 * pi) + 0.5) for i in range(30)], 40)
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Cycle through a rainbow of colors.
|
||||
hub.light.animate([Color(h=i * 8) for i in range(45)], interval=40)
|
||||
|
||||
wait(10000)
|
||||
@@ -1,16 +0,0 @@
|
||||
from pybricks.hubs import CityHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub
|
||||
hub = CityHub()
|
||||
|
||||
# Keep blinking red on and off.
|
||||
hub.light.blink(Color.RED, [500, 500])
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Keep blinking green slowly and then quickly.
|
||||
hub.light.blink(Color.GREEN, [500, 500, 50, 900])
|
||||
|
||||
wait(10000)
|
||||
@@ -1,21 +0,0 @@
|
||||
from pybricks.hubs import CityHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = CityHub()
|
||||
|
||||
# Show the color at 30% brightness.
|
||||
hub.light.on(Color.RED * 0.3)
|
||||
|
||||
wait(2000)
|
||||
|
||||
# Use your own custom color.
|
||||
hub.light.on(Color(h=30, s=100, v=50))
|
||||
|
||||
wait(2000)
|
||||
|
||||
# Go through all the colors.
|
||||
for hue in range(360):
|
||||
hub.light.on(Color(hue))
|
||||
wait(10)
|
||||
@@ -1,12 +0,0 @@
|
||||
from pybricks.hubs import CityHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = CityHub()
|
||||
|
||||
# Say goodbye and give some time to send it.
|
||||
print("Goodbye!")
|
||||
wait(100)
|
||||
|
||||
# Shut the hub down.
|
||||
hub.system.shutdown()
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
from pybricks.hubs import CityHub
|
||||
# ThisHub = MoveHub CityHub TechnicHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.parameters import Color, Button
|
||||
from pybricks.tools import wait, StopWatch
|
||||
|
||||
# Initialize the hub.
|
||||
hub = CityHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Disable the stop button.
|
||||
hub.system.set_stop_button(None)
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
# ThisHub = TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.tools import wait
|
||||
from pybricks.geometry import Axis
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Get the acceleration or angular_velocity along a single axis.
|
||||
# If you need only one value, this is more memory efficient.
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
# ExampleHub = TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
# ThisHub = TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Get the acceleration vector in g's.
|
||||
print(hub.imu.acceleration() / 9810)
|
||||
@@ -1,8 +1,9 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
# ThisHub = TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
hub = ThisHub()
|
||||
|
||||
while True:
|
||||
# Read the tilt values.
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
# ThisHub = TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.tools import wait
|
||||
from pybricks.geometry import Axis
|
||||
|
||||
# Initialize the hub. In this case, specify that the hub is mounted with the
|
||||
# top side facing forward and the front side facing to the right.
|
||||
# For example, this is how the hub is mounted in BLAST in the 51515 set.
|
||||
hub = TechnicHub(top_side=Axis.X, front_side=-Axis.Y)
|
||||
hub = ThisHub(top_side=Axis.X, front_side=-Axis.Y)
|
||||
|
||||
while True:
|
||||
# Read the tilt values. Now, the values are 0 when BLAST stands upright.
|
||||
@@ -1,9 +1,10 @@
|
||||
from pybricks.hubs import MoveHub
|
||||
# ThisHub = TechnicHub PrimeHub MoveHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.parameters import Color, Side
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = MoveHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Define colors for each side in a dictionary.
|
||||
SIDE_COLORS = {
|
||||
@@ -1,11 +1,11 @@
|
||||
# ExampleHub = CityHub TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
# ThisHub = CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
from umath import sin, pi
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
@@ -1,9 +1,10 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub
|
||||
hub = PrimeHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Keep blinking red on and off.
|
||||
hub.light.blink(Color.RED, [500, 500])
|
||||
@@ -1,10 +1,10 @@
|
||||
# ExampleHub = CityHub TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
# ThisHub = CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Show the color at 30% brightness.
|
||||
hub.light.on(Color.RED * 0.3)
|
||||
@@ -1,9 +1,10 @@
|
||||
from pybricks.hubs import CityHub
|
||||
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = CityHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Turn the light on and off 5 times.
|
||||
for i in range(5):
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generates hub-specific examples from common template script."""
|
||||
|
||||
import pathlib
|
||||
|
||||
# Make build directory.
|
||||
dir_path = pathlib.Path(__file__).parent
|
||||
build_path = dir_path / "build"
|
||||
build_path.mkdir(exist_ok=True)
|
||||
|
||||
# Get list of scripts to be parsed.
|
||||
file_paths = [f for f in dir_path.glob("*.py") if f.stem != "make_examples"]
|
||||
|
||||
# Go through all template scripts
|
||||
for file_path in file_paths:
|
||||
|
||||
with open(file_path) as template:
|
||||
|
||||
# First line contains hub info
|
||||
hubs = template.readline().strip().split()[3:]
|
||||
|
||||
print("Converting", template.name, "to", hubs)
|
||||
|
||||
for hub in hubs:
|
||||
# Path to hub-specific output script.
|
||||
gen_path = build_path / (file_path.stem + "_" + hub.lower() + ".py")
|
||||
|
||||
# Reset source script and skip over header.
|
||||
template.seek(0)
|
||||
template.readline()
|
||||
|
||||
# Open destination script:
|
||||
with open(gen_path, "w") as dest_file:
|
||||
|
||||
# Read script line by line.
|
||||
for line in template.readlines():
|
||||
|
||||
# Replace hub name if present.
|
||||
dest_file.writelines(line.replace("ThisHub", hub))
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
hub = ThisHub()
|
||||
|
||||
# Say goodbye and give some time to send it.
|
||||
print("Goodbye!")
|
||||
@@ -1,25 +0,0 @@
|
||||
from pybricks.hubs import MoveHub
|
||||
from pybricks.parameters import Color, Button
|
||||
from pybricks.tools import wait, StopWatch
|
||||
|
||||
# Initialize the hub.
|
||||
hub = MoveHub()
|
||||
|
||||
# Disable the stop button.
|
||||
hub.system.set_stop_button(None)
|
||||
|
||||
# Check the button for 5 seconds.
|
||||
watch = StopWatch()
|
||||
while watch.time() < 5000:
|
||||
|
||||
# Set light to green if pressed, else red.
|
||||
if hub.button.pressed():
|
||||
hub.light.on(Color.GREEN)
|
||||
else:
|
||||
hub.light.on(Color.RED)
|
||||
|
||||
# Enable the stop button again.
|
||||
hub.system.set_stop_button(Button.CENTER)
|
||||
|
||||
# Now you can press the stop button as usual.
|
||||
wait(5000)
|
||||
@@ -1,16 +0,0 @@
|
||||
from pybricks.hubs import MoveHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub
|
||||
hub = MoveHub()
|
||||
|
||||
# Keep blinking red on and off.
|
||||
hub.light.blink(Color.RED, [500, 500])
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Keep blinking green slowly and then quickly.
|
||||
hub.light.blink(Color.GREEN, [500, 500, 50, 900])
|
||||
|
||||
wait(10000)
|
||||
@@ -1,15 +0,0 @@
|
||||
from pybricks.hubs import MoveHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = MoveHub()
|
||||
|
||||
# Turn the light on and off 5 times.
|
||||
for i in range(5):
|
||||
|
||||
hub.light.on(Color.RED)
|
||||
wait(1000)
|
||||
|
||||
hub.light.off()
|
||||
wait(500)
|
||||
@@ -1,12 +0,0 @@
|
||||
from pybricks.hubs import MoveHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = MoveHub()
|
||||
|
||||
# Say goodbye and give some time to send it.
|
||||
print("Goodbye!")
|
||||
wait(100)
|
||||
|
||||
# Shut the hub down.
|
||||
hub.system.shutdown()
|
||||
@@ -1,14 +0,0 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
|
||||
# Get the acceleration vector in g's.
|
||||
print(hub.imu.acceleration() / 9810)
|
||||
|
||||
# Get the angular velocity vector.
|
||||
print(hub.imu.angular_velocity())
|
||||
|
||||
# Wait so we can see what we printed
|
||||
wait(5000)
|
||||
@@ -1,17 +0,0 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
from pybricks.tools import wait
|
||||
from pybricks.geometry import Axis
|
||||
|
||||
# Initialize the hub. In this case, specify that the hub is mounted with the
|
||||
# top side facing forward and the front side facing to the right.
|
||||
# For example, this is how the hub is mounted in BLAST in the 51515 set.
|
||||
hub = PrimeHub(top_side=Axis.X, front_side=-Axis.Y)
|
||||
|
||||
while True:
|
||||
# Read the tilt values. Now, the values are 0 when BLAST stands upright.
|
||||
# Leaning forward gives positive pitch. Leaning right gives positive roll.
|
||||
pitch, roll = hub.imu.tilt()
|
||||
|
||||
# Print the result.
|
||||
print(pitch, roll)
|
||||
wait(200)
|
||||
@@ -1,29 +0,0 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
from pybricks.parameters import Color, Side
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
|
||||
# Define colors for each side in a dictionary.
|
||||
SIDE_COLORS = {
|
||||
Side.TOP: Color.RED,
|
||||
Side.BOTTOM: Color.BLUE,
|
||||
Side.LEFT: Color.GREEN,
|
||||
Side.RIGHT: Color.YELLOW,
|
||||
Side.FRONT: Color.MAGENTA,
|
||||
Side.BACK: Color.BLACK,
|
||||
}
|
||||
|
||||
# Keep updating the color based on detected up side.
|
||||
while True:
|
||||
|
||||
# Check which side of the hub is up.
|
||||
up_side = hub.imu.up()
|
||||
|
||||
# Change the color based on the side.
|
||||
hub.light.on(SIDE_COLORS[up_side])
|
||||
|
||||
# Also print the result.
|
||||
print(up_side)
|
||||
wait(50)
|
||||
@@ -1,22 +0,0 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
from umath import sin, pi
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Make the color RED grow faint and bright using a sine pattern.
|
||||
hub.light.animate([Color.RED * (0.5 * sin(i / 15 * pi) + 0.5) for i in range(30)], 40)
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Cycle through a rainbow of colors.
|
||||
hub.light.animate([Color(h=i * 8) for i in range(45)], interval=40)
|
||||
|
||||
wait(10000)
|
||||
@@ -1,21 +0,0 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
|
||||
# Show the color at 30% brightness.
|
||||
hub.light.on(Color.RED * 0.3)
|
||||
|
||||
wait(2000)
|
||||
|
||||
# Use your own custom color.
|
||||
hub.light.on(Color(h=30, s=100, v=50))
|
||||
|
||||
wait(2000)
|
||||
|
||||
# Go through all the colors.
|
||||
for hue in range(360):
|
||||
hub.light.on(Color(hue))
|
||||
wait(10)
|
||||
@@ -1,15 +0,0 @@
|
||||
from pybricks.hubs import PrimeHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = PrimeHub()
|
||||
|
||||
# Turn the light on and off 5 times.
|
||||
for i in range(5):
|
||||
|
||||
hub.light.on(Color.RED)
|
||||
wait(1000)
|
||||
|
||||
hub.light.off()
|
||||
wait(500)
|
||||
@@ -1,26 +0,0 @@
|
||||
# ExampleHub = MoveHub CityHub TechnicHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.parameters import Color, Button
|
||||
from pybricks.tools import wait, StopWatch
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
|
||||
# Disable the stop button.
|
||||
hub.system.set_stop_button(None)
|
||||
|
||||
# Check the button for 5 seconds.
|
||||
watch = StopWatch()
|
||||
while watch.time() < 5000:
|
||||
|
||||
# Set light to green if pressed, else red.
|
||||
if hub.button.pressed():
|
||||
hub.light.on(Color.GREEN)
|
||||
else:
|
||||
hub.light.on(Color.RED)
|
||||
|
||||
# Enable the stop button again.
|
||||
hub.system.set_stop_button(Button.CENTER)
|
||||
|
||||
# Now you can press the stop button as usual.
|
||||
wait(5000)
|
||||
@@ -1,21 +0,0 @@
|
||||
# ExampleHub = TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.tools import wait
|
||||
from pybricks.geometry import Axis
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
|
||||
# Get the acceleration or angular_velocity along a single axis.
|
||||
# If you need only one value, this is more memory efficient.
|
||||
while True:
|
||||
|
||||
# Read the forward acceleration.
|
||||
forward_acceleration = hub.imu.acceleration(Axis.X)
|
||||
|
||||
# Read the yaw rate.
|
||||
yaw_rate = hub.imu.angular_velocity(Axis.Z)
|
||||
|
||||
# Print the yaw rate.
|
||||
print(yaw_rate)
|
||||
wait(100)
|
||||
@@ -1,14 +0,0 @@
|
||||
# ExampleHub = TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
|
||||
while True:
|
||||
# Read the tilt values.
|
||||
pitch, roll = hub.imu.tilt()
|
||||
|
||||
# Print the result.
|
||||
print(pitch, roll)
|
||||
wait(200)
|
||||
@@ -1,18 +0,0 @@
|
||||
# ExampleHub = TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.tools import wait
|
||||
from pybricks.geometry import Axis
|
||||
|
||||
# Initialize the hub. In this case, specify that the hub is mounted with the
|
||||
# top side facing forward and the front side facing to the right.
|
||||
# For example, this is how the hub is mounted in BLAST in the 51515 set.
|
||||
hub = ExampleHub(top_side=Axis.X, front_side=-Axis.Y)
|
||||
|
||||
while True:
|
||||
# Read the tilt values. Now, the values are 0 when BLAST stands upright.
|
||||
# Leaning forward gives positive pitch. Leaning right gives positive roll.
|
||||
pitch, roll = hub.imu.tilt()
|
||||
|
||||
# Print the result.
|
||||
print(pitch, roll)
|
||||
wait(200)
|
||||
@@ -1,30 +0,0 @@
|
||||
# ExampleHub = TechnicHub PrimeHub MoveHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.parameters import Color, Side
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
|
||||
# Define colors for each side in a dictionary.
|
||||
SIDE_COLORS = {
|
||||
Side.TOP: Color.RED,
|
||||
Side.BOTTOM: Color.BLUE,
|
||||
Side.LEFT: Color.GREEN,
|
||||
Side.RIGHT: Color.YELLOW,
|
||||
Side.FRONT: Color.MAGENTA,
|
||||
Side.BACK: Color.BLACK,
|
||||
}
|
||||
|
||||
# Keep updating the color based on detected up side.
|
||||
while True:
|
||||
|
||||
# Check which side of the hub is up.
|
||||
up_side = hub.imu.up()
|
||||
|
||||
# Change the color based on the side.
|
||||
hub.light.on(SIDE_COLORS[up_side])
|
||||
|
||||
# Also print the result.
|
||||
print(up_side)
|
||||
wait(50)
|
||||
@@ -1,17 +0,0 @@
|
||||
# ExampleHub = MoveHub CityHub TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub
|
||||
hub = ExampleHub()
|
||||
|
||||
# Keep blinking red on and off.
|
||||
hub.light.blink(Color.RED, [500, 500])
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Keep blinking green slowly and then quickly.
|
||||
hub.light.blink(Color.GREEN, [500, 500, 50, 900])
|
||||
|
||||
wait(10000)
|
||||
@@ -1,16 +0,0 @@
|
||||
# ExampleHub = MoveHub CityHub TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
|
||||
# Turn the light on and off 5 times.
|
||||
for i in range(5):
|
||||
|
||||
hub.light.on(Color.RED)
|
||||
wait(1000)
|
||||
|
||||
hub.light.off()
|
||||
wait(500)
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Replaces all instances of ExampleHub in template with actual hub names."""
|
||||
import os
|
||||
|
||||
# Get list of scripts to be parsed
|
||||
script_names = [f for f in os.listdir(".") if f != "make_shared_examples.py"]
|
||||
|
||||
# Go through all template scripts
|
||||
for script in (open(f, "r") for f in script_names):
|
||||
|
||||
# First line contains hub info
|
||||
hubs = script.readline().strip().split()[3:]
|
||||
|
||||
print("Converting", script.name, "for", hubs)
|
||||
|
||||
for hub in hubs:
|
||||
# Determine path to the hub
|
||||
hub_path = os.path.join("..", "hub_" + hub.lower())
|
||||
|
||||
# Reset source script
|
||||
script.seek(0)
|
||||
script.readline()
|
||||
|
||||
# Open destination script:
|
||||
with open(os.path.join(hub_path, script.name), "w") as dest_file:
|
||||
|
||||
# Read script line by line
|
||||
for line in script.readlines():
|
||||
|
||||
# Replace hub name if present
|
||||
dest_file.writelines(line.replace("ExampleHub", hub))
|
||||
@@ -1,13 +0,0 @@
|
||||
# ExampleHub = MoveHub CityHub TechnicHub PrimeHub
|
||||
from pybricks.hubs import ExampleHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ExampleHub()
|
||||
|
||||
# Say goodbye and give some time to send it.
|
||||
print("Goodbye!")
|
||||
wait(100)
|
||||
|
||||
# Shut the hub down.
|
||||
hub.system.shutdown()
|
||||
@@ -1,25 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.parameters import Color, Button
|
||||
from pybricks.tools import wait, StopWatch
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Disable the stop button.
|
||||
hub.system.set_stop_button(None)
|
||||
|
||||
# Check the button for 5 seconds.
|
||||
watch = StopWatch()
|
||||
while watch.time() < 5000:
|
||||
|
||||
# Set light to green if pressed, else red.
|
||||
if hub.button.pressed():
|
||||
hub.light.on(Color.GREEN)
|
||||
else:
|
||||
hub.light.on(Color.RED)
|
||||
|
||||
# Enable the stop button again.
|
||||
hub.system.set_stop_button(Button.CENTER)
|
||||
|
||||
# Now you can press the stop button as usual.
|
||||
wait(5000)
|
||||
@@ -1,20 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.tools import wait
|
||||
from pybricks.geometry import Axis
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Get the acceleration or angular_velocity along a single axis.
|
||||
# If you need only one value, this is more memory efficient.
|
||||
while True:
|
||||
|
||||
# Read the forward acceleration.
|
||||
forward_acceleration = hub.imu.acceleration(Axis.X)
|
||||
|
||||
# Read the yaw rate.
|
||||
yaw_rate = hub.imu.angular_velocity(Axis.Z)
|
||||
|
||||
# Print the yaw rate.
|
||||
print(yaw_rate)
|
||||
wait(100)
|
||||
@@ -1,14 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Get the acceleration vector in g's.
|
||||
print(hub.imu.acceleration() / 9810)
|
||||
|
||||
# Get the angular velocity vector.
|
||||
print(hub.imu.angular_velocity())
|
||||
|
||||
# Wait so we can see what we printed
|
||||
wait(5000)
|
||||
@@ -1,13 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
while True:
|
||||
# Read the tilt values.
|
||||
pitch, roll = hub.imu.tilt()
|
||||
|
||||
# Print the result.
|
||||
print(pitch, roll)
|
||||
wait(200)
|
||||
@@ -1,29 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.parameters import Color, Side
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Define colors for each side in a dictionary.
|
||||
SIDE_COLORS = {
|
||||
Side.TOP: Color.RED,
|
||||
Side.BOTTOM: Color.BLUE,
|
||||
Side.LEFT: Color.GREEN,
|
||||
Side.RIGHT: Color.YELLOW,
|
||||
Side.FRONT: Color.MAGENTA,
|
||||
Side.BACK: Color.BLACK,
|
||||
}
|
||||
|
||||
# Keep updating the color based on detected up side.
|
||||
while True:
|
||||
|
||||
# Check which side of the hub is up.
|
||||
up_side = hub.imu.up()
|
||||
|
||||
# Change the color based on the side.
|
||||
hub.light.on(SIDE_COLORS[up_side])
|
||||
|
||||
# Also print the result.
|
||||
print(up_side)
|
||||
wait(50)
|
||||
@@ -1,22 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
from umath import sin, pi
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Make an animation with multiple colors.
|
||||
hub.light.animate([Color.RED, Color.GREEN, Color.NONE], interval=500)
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Make the color RED grow faint and bright using a sine pattern.
|
||||
hub.light.animate([Color.RED * (0.5 * sin(i / 15 * pi) + 0.5) for i in range(30)], 40)
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Cycle through a rainbow of colors.
|
||||
hub.light.animate([Color(h=i * 8) for i in range(45)], interval=40)
|
||||
|
||||
wait(10000)
|
||||
@@ -1,16 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub
|
||||
hub = TechnicHub()
|
||||
|
||||
# Keep blinking red on and off.
|
||||
hub.light.blink(Color.RED, [500, 500])
|
||||
|
||||
wait(10000)
|
||||
|
||||
# Keep blinking green slowly and then quickly.
|
||||
hub.light.blink(Color.GREEN, [500, 500, 50, 900])
|
||||
|
||||
wait(10000)
|
||||
@@ -1,21 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Show the color at 30% brightness.
|
||||
hub.light.on(Color.RED * 0.3)
|
||||
|
||||
wait(2000)
|
||||
|
||||
# Use your own custom color.
|
||||
hub.light.on(Color(h=30, s=100, v=50))
|
||||
|
||||
wait(2000)
|
||||
|
||||
# Go through all the colors.
|
||||
for hue in range(360):
|
||||
hub.light.on(Color(hue))
|
||||
wait(10)
|
||||
@@ -1,15 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.parameters import Color
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Turn the light on and off 5 times.
|
||||
for i in range(5):
|
||||
|
||||
hub.light.on(Color.RED)
|
||||
wait(1000)
|
||||
|
||||
hub.light.off()
|
||||
wait(500)
|
||||
@@ -1,12 +0,0 @@
|
||||
from pybricks.hubs import TechnicHub
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = TechnicHub()
|
||||
|
||||
# Say goodbye and give some time to send it.
|
||||
print("Goodbye!")
|
||||
wait(100)
|
||||
|
||||
# Shut the hub down.
|
||||
hub.system.shutdown()
|
||||
@@ -0,0 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- Added LICENSE file.
|
||||
|
||||
## 1.1.0 - 2022-06-26
|
||||
|
||||
### Added
|
||||
- Added this changelog.
|
||||
- Added support for parameter documentation in signatures.
|
||||
|
||||
### Changed
|
||||
- Updated to pybricks API package v3.2.0b1-r3.
|
||||
- Documentation is now treated as markdown.
|
||||
|
||||
### Fixed
|
||||
- Fixed including docstring for `__init__` on classes.
|
||||
|
||||
## 1.0.0 - 2022-06-24
|
||||
|
||||
Initial release.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 The Pybricks Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Generated
+17
-5
@@ -15,9 +15,9 @@ optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.extras]
|
||||
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
|
||||
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
|
||||
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
|
||||
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope-interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
|
||||
docs = ["furo", "sphinx", "zope-interface", "sphinx-notfound-page"]
|
||||
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope-interface", "cloudpickle"]
|
||||
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
|
||||
|
||||
[[package]]
|
||||
@@ -60,6 +60,14 @@ category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "docstring-parser"
|
||||
version = "0.14.1"
|
||||
description = "Parse Python docstrings in reST, Google and Numpydoc format"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6,<4.0"
|
||||
|
||||
[[package]]
|
||||
name = "flake8"
|
||||
version = "4.0.1"
|
||||
@@ -177,7 +185,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "pybricks"
|
||||
version = "3.2.0b1-r2"
|
||||
version = "3.2.0b1-r3"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
category = "main"
|
||||
optional = false
|
||||
@@ -255,7 +263,7 @@ python-versions = ">=3.7"
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">= 3.10, < 3.11"
|
||||
content-hash = "9b91afcb8ccd46cc8be150f48170e45e86a6c65686d7e6e97ac3de67988c0ff5"
|
||||
content-hash = "acab2fb183ac5598666cfb333e1dfc1e8a06eb73c7d3297de36b199e9277508c"
|
||||
|
||||
[metadata.files]
|
||||
atomicwrites = [
|
||||
@@ -299,6 +307,10 @@ colorama = [
|
||||
{file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
|
||||
{file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
|
||||
]
|
||||
docstring-parser = [
|
||||
{file = "docstring_parser-0.14.1-py3-none-any.whl", hash = "sha256:14ac6ec1f1ba6905c4d8cb90fd0bc55394f5678183752c90e44812bf28d7a515"},
|
||||
{file = "docstring_parser-0.14.1.tar.gz", hash = "sha256:2c77522e31b7c88b1ab457a1f3c9ae38947ad719732260ba77ee8a3deb58622a"},
|
||||
]
|
||||
flake8 = [
|
||||
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
|
||||
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
|
||||
|
||||
+5
-4
@@ -1,15 +1,16 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks_jedi"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
description = "Code completion for Pybricks."
|
||||
authors = ["The Pybricks Authors"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">= 3.10, < 3.11"
|
||||
pybricks = "^3.2.0b1-r2"
|
||||
jedi = "^0.18.1"
|
||||
typing-extensions = "^4.2.0"
|
||||
pybricks = "3.2.0b1-r3"
|
||||
jedi = "0.18.1"
|
||||
typing-extensions = "4.2.0"
|
||||
docstring-parser = "0.14.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^7.1.2"
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from enum import IntEnum
|
||||
import io
|
||||
import json
|
||||
from typing_extensions import TypedDict, NotRequired
|
||||
import re
|
||||
from enum import IntEnum
|
||||
|
||||
import docstring_parser
|
||||
import jedi
|
||||
from jedi.api.classes import Completion, Signature, ParamName
|
||||
from jedi.api.classes import BaseName, Completion, Name, ParamName, Signature
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
# Packages included in Pybricks firmware that ships with Pybricks Code.
|
||||
PYBRICKS_CODE_PACKAGES = {
|
||||
@@ -132,6 +136,23 @@ class Command(TypedDict):
|
||||
arguments: NotRequired[list]
|
||||
|
||||
|
||||
class UriComponents(TypedDict):
|
||||
scheme: str
|
||||
authority: str
|
||||
path: str
|
||||
query: str
|
||||
fragment: str
|
||||
|
||||
|
||||
class IMarkdownString(TypedDict):
|
||||
value: str
|
||||
isTrusted: NotRequired[bool]
|
||||
supportThemeIcons: NotRequired[bool]
|
||||
supportHtml: NotRequired[bool]
|
||||
baseUri: NotRequired[UriComponents]
|
||||
uris: NotRequired[dict[str, UriComponents]]
|
||||
|
||||
|
||||
class CompletionItemKind(IntEnum):
|
||||
Method = 0
|
||||
Function = 1
|
||||
@@ -251,6 +272,66 @@ def _is_pybricks(c: Completion) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def _get_docstring(name: BaseName) -> str:
|
||||
"""
|
||||
Gets the docstring for a name.
|
||||
"""
|
||||
|
||||
docstring = name.docstring(raw=True)
|
||||
|
||||
# jedi does not appear to be smart enough to use __init__ docstring for class
|
||||
if name.type == "class" and isinstance(name, Name):
|
||||
n: Name
|
||||
for n in name.defined_names():
|
||||
if n.name == "__init__":
|
||||
docstring = "\n".join([docstring, _get_docstring(n)])
|
||||
|
||||
return docstring
|
||||
|
||||
|
||||
def _parse_docstring(text: str) -> tuple[IMarkdownString, list[IMarkdownString]]:
|
||||
"""
|
||||
Parses a doc string, removes the overload declarations, performs some
|
||||
fixups and extracts the individual parameter strings.
|
||||
|
||||
Args:
|
||||
The raw docstring.
|
||||
|
||||
Returns:
|
||||
A tuple with the fixed up doc string and a list of parameter doc strings.
|
||||
"""
|
||||
# docstring_parser does not support signatures at the beginning of the
|
||||
# docstring, so we have to remove them
|
||||
# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_docstring_signature
|
||||
|
||||
lines, end_of_signatures = [], False
|
||||
|
||||
for line in io.StringIO(text).readlines():
|
||||
# signatures look like: "name(params...)"
|
||||
if not end_of_signatures and re.match(r"^\w+\(.*\)", line):
|
||||
continue
|
||||
|
||||
end_of_signatures = True
|
||||
|
||||
# TODO: we may want to do some restructured text to markdown fixes,
|
||||
# e.g. strip off ":class:" from ":class:`SomeClass`" and replace
|
||||
# ".. some-directive::" with an appropriate header
|
||||
|
||||
lines.append(line)
|
||||
|
||||
text = "".join(lines)
|
||||
|
||||
doc = docstring_parser.parse(text, docstring_parser.DocstringStyle.GOOGLE)
|
||||
|
||||
# convert to numpy doc for better markdown rendering (section names are underlined)
|
||||
numpy_doc = docstring_parser.compose(doc, docstring_parser.Style.NUMPYDOC)
|
||||
|
||||
docstring = IMarkdownString(value=numpy_doc)
|
||||
param_docstrings = [IMarkdownString(value=p.description) for p in doc.params]
|
||||
|
||||
return docstring, param_docstrings
|
||||
|
||||
|
||||
def _map_completion_kind(type: str) -> CompletionItemKind:
|
||||
match type:
|
||||
case "module":
|
||||
@@ -294,22 +375,23 @@ def _map_completion_item(
|
||||
endLineNumber=line,
|
||||
endColumn=column,
|
||||
),
|
||||
documentation=completion.docstring(),
|
||||
documentation=_parse_docstring(_get_docstring(completion))[0],
|
||||
)
|
||||
|
||||
|
||||
def _map_parameter(param: ParamName) -> ParameterInformation:
|
||||
# NB: it is not possible to get docstring for individual parameters from jedi
|
||||
return ParameterInformation(label=param.to_string())
|
||||
def _map_parameter(param: ParamName, docstr: str) -> ParameterInformation:
|
||||
return ParameterInformation(label=param.to_string(), documentation=docstr)
|
||||
|
||||
|
||||
def _map_signature(signature: Signature) -> SignatureInformation:
|
||||
optional = {} if signature.index is None else dict(activeParameter=signature.index)
|
||||
|
||||
docstr, param_docstr = _parse_docstring(_get_docstring(signature))
|
||||
|
||||
return SignatureInformation(
|
||||
label=signature.to_string(),
|
||||
documentation=signature.docstring(),
|
||||
parameters=[_map_parameter(p) for p in signature.params],
|
||||
documentation=docstr,
|
||||
parameters=[_map_parameter(*p) for p in zip(signature.params, param_docstr)],
|
||||
**optional,
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2022 The Pybricks Authors
|
||||
|
||||
"""
|
||||
Tests for correct code completion of the EssentialHub class.
|
||||
"""
|
||||
|
||||
|
||||
import json
|
||||
from pybricks_jedi import CompletionItem, complete
|
||||
|
||||
IMPORT = "from pybricks.hubs import EssentialHub"
|
||||
CREATE_INSTANCE = "hub = EssentialHub()"
|
||||
|
||||
|
||||
def _create_snippet(line: str) -> str:
|
||||
"""
|
||||
Creates a code snippet::
|
||||
|
||||
from pybricks.hubs import EssentialHub
|
||||
hub = EssentialHub()
|
||||
{line}
|
||||
|
||||
Args:
|
||||
line: The value substituted for ``{line}``
|
||||
"""
|
||||
return "\n".join((IMPORT, CREATE_INSTANCE, line))
|
||||
|
||||
|
||||
def test_hub_dot():
|
||||
line = "hub."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"button",
|
||||
"charger",
|
||||
"imu",
|
||||
"light",
|
||||
"system",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_battery_dot():
|
||||
line = "hub.battery."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"current",
|
||||
"voltage",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_buttons_dot():
|
||||
line = "hub.button."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"pressed",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_charger_dot():
|
||||
line = "hub.charger."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"connected",
|
||||
"current",
|
||||
"status",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_imu_dot():
|
||||
line = "hub.imu."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"acceleration",
|
||||
"angular_velocity",
|
||||
"heading",
|
||||
"reset_heading",
|
||||
"tilt",
|
||||
"up",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_light_dot():
|
||||
line = "hub.light."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"animate",
|
||||
"blink",
|
||||
"off",
|
||||
"on",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_system_dot():
|
||||
line = "hub.system."
|
||||
code = _create_snippet(line)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"name",
|
||||
"reset_reason",
|
||||
"set_stop_button",
|
||||
"shutdown",
|
||||
]
|
||||
@@ -69,6 +69,7 @@ def test_from_pybricks_hubs_import():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"CityHub",
|
||||
"EssentialHub",
|
||||
"EV3Brick",
|
||||
"InventorHub",
|
||||
"MoveHub",
|
||||
|
||||
@@ -7,7 +7,7 @@ Tests for correct code completion of the InventorHub class.
|
||||
|
||||
|
||||
import json
|
||||
from pybricks_jedi import SignatureHelp, complete, get_signatures, CompletionItem
|
||||
from pybricks_jedi import complete, CompletionItem
|
||||
|
||||
IMPORT = "from pybricks.hubs import InventorHub"
|
||||
CREATE_INSTANCE = "hub = InventorHub()"
|
||||
@@ -53,22 +53,6 @@ def test_hub_dot_battery_dot():
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_battery_dot_current():
|
||||
line = "hub.battery.current("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == ["current() -> int"]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_battery_dot_voltage():
|
||||
line = "hub.battery.voltage("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == ["voltage() -> int"]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_buttons_dot():
|
||||
line = "hub.buttons."
|
||||
code = _create_snippet(line)
|
||||
@@ -78,16 +62,6 @@ def test_hub_dot_buttons_dot():
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_battery_dot_pressed():
|
||||
line = "hub.buttons.pressed("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"pressed() -> Tuple[Button]"
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_charger_dot():
|
||||
line = "hub.charger."
|
||||
code = _create_snippet(line)
|
||||
@@ -99,22 +73,6 @@ def test_hub_dot_charger_dot():
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_charger_dot_connected():
|
||||
line = "hub.charger.connected("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == ["connected() -> bool"]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_charger_dot_current():
|
||||
line = "hub.charger.current("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == ["current() -> int"]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_display_dot():
|
||||
line = "hub.display."
|
||||
code = _create_snippet(line)
|
||||
@@ -157,62 +115,6 @@ def test_hub_dot_light_dot():
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_light_dot_animate():
|
||||
line = "hub.light.animate("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"animate(colors: Collection[Color], interval: Number) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [0]
|
||||
assert [
|
||||
[p["label"] for p in s["parameters"]] for s in signatures["signatures"]
|
||||
] == [["colors: Collection[Color]", "interval: Number"]]
|
||||
|
||||
|
||||
def test_hub_dot_light_dot_animate2():
|
||||
line = "hub.light.animate([],"
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"animate(colors: Collection[Color], interval: Number) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [1]
|
||||
assert [
|
||||
[p["label"] for p in s["parameters"]] for s in signatures["signatures"]
|
||||
] == [["colors: Collection[Color]", "interval: Number"]]
|
||||
|
||||
|
||||
def test_hub_dot_light_dot_blink():
|
||||
line = "hub.light.blink("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"blink(color: Color, durations: Collection[int]) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [0]
|
||||
|
||||
|
||||
def test_hub_dot_light_dot_blink2():
|
||||
line = "hub.light.blink(Color.RED,"
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"blink(color: Color, durations: Collection[int]) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [1]
|
||||
|
||||
|
||||
def test_hub_dot_light_dot_on():
|
||||
line = "hub.light.on("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"on(color: Color) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [0]
|
||||
|
||||
|
||||
def test_hub_dot_speaker_dot():
|
||||
line = "hub.speaker."
|
||||
code = _create_snippet(line)
|
||||
@@ -224,57 +126,6 @@ def test_hub_dot_speaker_dot():
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_speaker_dot_beep():
|
||||
line = "hub.speaker.beep("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"beep(frequency: Number=500, duration: Number=100) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [0]
|
||||
|
||||
|
||||
def test_hub_dot_speaker_dot_beep2():
|
||||
line = "hub.speaker.beep(100,"
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"beep(frequency: Number=500, duration: Number=100) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [1]
|
||||
|
||||
|
||||
def test_hub_dot_speaker_dot_play_notes():
|
||||
line = "hub.speaker.play_notes("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"play_notes(notes: Iterable[str], tempo: Number=120) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [0]
|
||||
|
||||
|
||||
def test_hub_dot_speaker_dot_play_notes2():
|
||||
line = "hub.speaker.play_notes([],"
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"play_notes(notes: Iterable[str], tempo: Number=120) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [1]
|
||||
|
||||
|
||||
def test_hub_dot_speaker_dot_volume():
|
||||
line = "hub.speaker.volume("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"volume() -> int",
|
||||
"volume(volume: Number) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None, 0]
|
||||
|
||||
|
||||
def test_hub_dot_system_dot():
|
||||
line = "hub.system."
|
||||
code = _create_snippet(line)
|
||||
@@ -285,43 +136,3 @@ def test_hub_dot_system_dot():
|
||||
"set_stop_button",
|
||||
"shutdown",
|
||||
]
|
||||
|
||||
|
||||
def test_hub_dot_system_dot_name():
|
||||
line = "hub.system.name("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"name() -> str",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_system_dot_reset_reason():
|
||||
line = "hub.system.reset_reason("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"reset_reason() -> int",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
|
||||
def test_hub_dot_system_dot_set_stop_button():
|
||||
line = "hub.system.set_stop_button("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"set_stop_button(button: Optional[Union[Button, Iterable[Button]]]) -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [0]
|
||||
|
||||
|
||||
def test_hub_dot_system_dot_shutdown():
|
||||
line = "hub.system.shutdown("
|
||||
code = _create_snippet(line)
|
||||
signatures: SignatureHelp = json.loads(get_signatures(code, 3, len(line) + 1))
|
||||
assert [s["label"] for s in signatures["signatures"]] == [
|
||||
"shutdown() -> None",
|
||||
]
|
||||
assert [s.get("activeParameter") for s in signatures["signatures"]] == [None]
|
||||
|
||||
@@ -0,0 +1,835 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2022 The Pybricks Authors
|
||||
|
||||
"""
|
||||
Tests for correct signatures of the pupdevices.Motor class.
|
||||
"""
|
||||
|
||||
|
||||
from itertools import zip_longest
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from pybricks_jedi import SignatureHelp, get_signatures
|
||||
|
||||
|
||||
def _get_function_signature(module: str, function: str) -> SignatureHelp:
|
||||
"""
|
||||
Gets the signature help object for code like::
|
||||
|
||||
from {module} import {function}
|
||||
{function}(
|
||||
|
||||
Args:
|
||||
module: the module name
|
||||
func: the function name (a function in the module)
|
||||
"""
|
||||
code = f"from {module} import {function}; {function}("
|
||||
return json.loads(get_signatures(code, 1, len(code) + 1))
|
||||
|
||||
|
||||
FUNCTION_PARAMS = [
|
||||
pytest.param("pybricks.tools", "wait", [(["time: Number"], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.geometry",
|
||||
"vector",
|
||||
[
|
||||
(["x: float", "y: float"], "Matrix"),
|
||||
(["x: float", "y: float", "z: float"], "Matrix"),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module,function,signatures", FUNCTION_PARAMS)
|
||||
def test_get_signature_for_functions(
|
||||
module: str, function: str, signatures: list[tuple[list[str], str]]
|
||||
):
|
||||
help = _get_function_signature(module, function)
|
||||
|
||||
assert help["activeSignature"] == 0
|
||||
assert help["activeParameter"] == 0
|
||||
assert help["signatures"]
|
||||
|
||||
for sig, (params, returns) in zip_longest(help["signatures"], signatures):
|
||||
assert sig["label"] == f"{function}({', '.join(params)}) -> {returns}"
|
||||
assert sig["documentation"]["value"]
|
||||
# ensure signatures are stripped from doc comment
|
||||
assert not sig["documentation"]["value"].startswith(f"{function}(")
|
||||
|
||||
for pi, p in zip_longest(sig["parameters"], params):
|
||||
assert pi["label"] == p
|
||||
assert pi["documentation"]["value"]
|
||||
|
||||
|
||||
def _get_constructor_signature(module: str, type: str) -> SignatureHelp:
|
||||
"""
|
||||
Gets the signature help object for code like::
|
||||
|
||||
from {module} import {type}
|
||||
instance = {type}(
|
||||
|
||||
Args:
|
||||
module: the module name
|
||||
type: the type name (a type in the module)
|
||||
"""
|
||||
code = f"from {module} import {type}; {type}("
|
||||
return json.loads(get_signatures(code, 1, len(code) + 1))
|
||||
|
||||
|
||||
CONSTRUCTOR_PARAMS = [
|
||||
pytest.param("pybricks.hubs", "MoveHub", [[]]),
|
||||
pytest.param("pybricks.hubs", "CityHub", [[]]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
[["top_side: Axis=Axis.Z", "front_side: Axis=Axis.X"]],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
[["top_side: Axis=Axis.Z", "front_side: Axis=Axis.X"]],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"DCMotor",
|
||||
[["port: Port", "positive_direction: Direction=Direction.CLOCKWISE"]],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
[
|
||||
[
|
||||
"port: Port",
|
||||
"positive_direction: Direction=Direction.CLOCKWISE",
|
||||
"gears: Optional[Union[Collection[int], Collection[Collection[int]]]]=None",
|
||||
"reset_angle: bool=True",
|
||||
]
|
||||
],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "TiltSensor", [["port: Port"]]),
|
||||
pytest.param("pybricks.pupdevices", "InfraredSensor", [["port: Port"]]),
|
||||
pytest.param("pybricks.pupdevices", "ColorDistanceSensor", [["port: Port"]]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"PFMotor",
|
||||
[
|
||||
[
|
||||
"sensor: ColorDistanceSensor",
|
||||
"channel: int",
|
||||
"color: Color",
|
||||
"positive_direction: Direction=Direction.CLOCKWISE",
|
||||
]
|
||||
],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorSensor", [["port: Port"]]),
|
||||
pytest.param("pybricks.pupdevices", "UltrasonicSensor", [["port: Port"]]),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", [["port: Port"]]),
|
||||
pytest.param("pybricks.pupdevices", "ColorLightMatrix", [["port: Port"]]),
|
||||
pytest.param("pybricks.pupdevices", "Light", [["port: Port"]]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Remote",
|
||||
[["name: Optional[str]=None", "timeout: int=10000"]],
|
||||
),
|
||||
# TODO: iodevices go here
|
||||
pytest.param(
|
||||
"pybricks.parameters",
|
||||
"Color",
|
||||
[["h: Number", "s: Number=100", "v: Number=100"]],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
[
|
||||
[
|
||||
"left_motor: Motor",
|
||||
"right_motor: Motor",
|
||||
"wheel_diameter: Number",
|
||||
"axle_track: Number",
|
||||
]
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.geometry",
|
||||
"Matrix",
|
||||
[["rows: Sequence[Sequence[float]]"]],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module,type,signatures", CONSTRUCTOR_PARAMS)
|
||||
def test_get_signature_for_constructors(
|
||||
module: str, type: str, signatures: list[list[str]]
|
||||
):
|
||||
help = _get_constructor_signature(module, type)
|
||||
|
||||
assert help["activeSignature"] == 0
|
||||
assert help["activeParameter"] == 0
|
||||
assert help["signatures"]
|
||||
|
||||
for sig, params in zip_longest(help["signatures"], signatures):
|
||||
assert sig["label"] == f"{type}({', '.join(params)})"
|
||||
assert sig["documentation"]["value"]
|
||||
# ensure signatures are stripped from doc comment
|
||||
assert not sig["documentation"]["value"].startswith(f"{type}(")
|
||||
|
||||
for pi, p in zip_longest(sig["parameters"], params):
|
||||
assert pi["label"] == p
|
||||
assert pi["documentation"]["value"]
|
||||
|
||||
|
||||
def _get_method_signature(module: str, type: str, method: str) -> SignatureHelp:
|
||||
"""
|
||||
Gets the signature help object for code like::
|
||||
|
||||
from {module} import {type}
|
||||
instance = {type}()
|
||||
instance.{method}(
|
||||
|
||||
Args:
|
||||
module: the module name
|
||||
type: the type name (a type in the module)
|
||||
method: the method name (a method of the type)
|
||||
"""
|
||||
code = f"from {module} import {type}; x = {type}(); x.{method}("
|
||||
return json.loads(get_signatures(code, 1, len(code) + 1))
|
||||
|
||||
|
||||
METHOD_PARAMS = [
|
||||
pytest.param("pybricks.hubs", "MoveHub", "light.on", [(["color: Color"], "None")]),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"MoveHub",
|
||||
"light.blink",
|
||||
[(["color: Color", "durations: Collection[Number]"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"MoveHub",
|
||||
"light.animate",
|
||||
[(["colors: Collection[Color]", "interval: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "imu.up", [([], "Side")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "MoveHub", "imu.acceleration", [([], "Tuple[int, int, int]")]
|
||||
),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "battery.voltage", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "battery.current", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "MoveHub", "button.pressed", [([], "Collection[Button]")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"MoveHub",
|
||||
"system.set_stop_button",
|
||||
[(["button: Optional[Union[Button, Iterable[Button]]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "system.name", [([], "str")]),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "system.shutdown", [([], "None")]),
|
||||
pytest.param("pybricks.hubs", "MoveHub", "system.reset_reason", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "CityHub", "light.on", [(["color: Color"], "None")]),
|
||||
pytest.param("pybricks.hubs", "CityHub", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"CityHub",
|
||||
"light.blink",
|
||||
[(["color: Color", "durations: Collection[Number]"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"CityHub",
|
||||
"light.animate",
|
||||
[(["colors: Collection[Color]", "interval: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "CityHub", "battery.voltage", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "CityHub", "battery.current", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "CityHub", "button.pressed", [([], "Collection[Button]")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"CityHub",
|
||||
"system.set_stop_button",
|
||||
[(["button: Optional[Union[Button, Iterable[Button]]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "CityHub", "system.name", [([], "str")]),
|
||||
pytest.param("pybricks.hubs", "CityHub", "system.shutdown", [([], "None")]),
|
||||
pytest.param("pybricks.hubs", "CityHub", "system.reset_reason", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "TechnicHub", "light.on", [(["color: Color"], "None")]
|
||||
),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
"light.blink",
|
||||
[(["color: Color", "durations: Collection[Number]"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
"light.animate",
|
||||
[(["colors: Collection[Color]", "interval: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "imu.up", [([], "Side")]),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "imu.tilt", [([], "Tuple[int, int]")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
"imu.acceleration",
|
||||
[(["axis: Axis"], "float"), ([], "Matrix")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
"imu.angular_velocity",
|
||||
[(["axis: Axis"], "float"), ([], "Matrix")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "imu.heading", [([], "float")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
"imu.reset_heading",
|
||||
[(["angle: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "battery.voltage", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "battery.current", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "TechnicHub", "button.pressed", [([], "Collection[Button]")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
"system.set_stop_button",
|
||||
[(["button: Optional[Union[Button, Iterable[Button]]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "system.name", [([], "str")]),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "system.shutdown", [([], "None")]),
|
||||
pytest.param("pybricks.hubs", "TechnicHub", "system.reset_reason", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "light.on", [(["color: Color"], "None")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"light.blink",
|
||||
[(["color: Color", "durations: Collection[Number]"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"light.animate",
|
||||
[(["colors: Collection[Color]", "interval: Number"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "PrimeHub", "display.orientation", [(["up: Side"], "None")]
|
||||
),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "display.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"display.pixel",
|
||||
[(["row: Number", "column: Number", "brightness: Number=100"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "PrimeHub", "display.image", [(["matrix: Matrix"], "None")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"display.animate",
|
||||
[(["matrices: Collection[Matrix]", "interval: Number"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "PrimeHub", "display.number", [(["number: Number"], "None")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "PrimeHub", "display.char", [(["char: str"], "None")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"display.text",
|
||||
[(["text: str", "on: Number=500", "off: Number=50"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "PrimeHub", "buttons.pressed", [([], "Collection[Button]")]
|
||||
),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "imu.up", [([], "Side")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "imu.tilt", [([], "Tuple[int, int]")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"imu.acceleration",
|
||||
[(["axis: Axis"], "float"), ([], "Matrix")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"imu.angular_velocity",
|
||||
[(["axis: Axis"], "float"), ([], "Matrix")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "imu.heading", [([], "float")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"imu.reset_heading",
|
||||
[(["angle: Number"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"speaker.volume",
|
||||
[(["volume: Number"], "None"), ([], "int")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"speaker.beep",
|
||||
[(["frequency: Number=500", "duration: Number=100"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"speaker.play_notes",
|
||||
[(["notes: Iterable[str]", "tempo: Number=120"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "battery.voltage", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "battery.current", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "charger.connected", [([], "bool")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "charger.current", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "charger.status", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"system.set_stop_button",
|
||||
[(["button: Optional[Union[Button, Iterable[Button]]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "system.name", [([], "str")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "system.shutdown", [([], "None")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "system.reset_reason", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "EssentialHub", "light.on", [(["color: Color"], "None")]
|
||||
),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
"light.blink",
|
||||
[(["color: Color", "durations: Collection[Number]"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
"light.animate",
|
||||
[(["colors: Collection[Color]", "interval: Number"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "EssentialHub", "button.pressed", [([], "Collection[Button]")]
|
||||
),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "imu.up", [([], "Side")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "EssentialHub", "imu.tilt", [([], "Tuple[int, int]")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
"imu.acceleration",
|
||||
[(["axis: Axis"], "float"), ([], "Matrix")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
"imu.angular_velocity",
|
||||
[(["axis: Axis"], "float"), ([], "Matrix")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "imu.heading", [([], "float")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
"imu.reset_heading",
|
||||
[(["angle: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "battery.voltage", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "battery.current", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "charger.connected", [([], "bool")]),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "charger.current", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "charger.status", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
"system.set_stop_button",
|
||||
[(["button: Optional[Union[Button, Iterable[Button]]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "system.name", [([], "str")]),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "system.shutdown", [([], "None")]),
|
||||
pytest.param("pybricks.hubs", "EssentialHub", "system.reset_reason", [([], "int")]),
|
||||
# TODO: iodevices module here
|
||||
pytest.param("pybricks.pupdevices", "DCMotor", "dc", [(["duty: Number"], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "DCMotor", "stop", [([], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "DCMotor", "brake", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"DCMotor",
|
||||
"settings",
|
||||
[(["max_voltage: Number"], "None"), ([], "Tuple[int]")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "speed", [([], "int")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "angle", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"reset_angle",
|
||||
[(["angle: Optional[Number]=None"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "stop", [([], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "brake", [([], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "hold", [([], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "run", [(["speed: Number"], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"run_time",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Number",
|
||||
"time: Number",
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"run_angle",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Number",
|
||||
"rotation_angle: Number",
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"run_target",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Number",
|
||||
"target_angle: Number",
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"track_target",
|
||||
[(["target_angle: Number"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"run_until_stalled",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Number",
|
||||
"then: Stop=Stop.COAST",
|
||||
"duty_limit: Optional[Number]=None",
|
||||
],
|
||||
"int",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "dc", [(["duty: Number"], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "control.done", [([], "bool")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "control.stalled", [([], "bool")]),
|
||||
pytest.param("pybricks.pupdevices", "Motor", "control.load", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"settings",
|
||||
[(["max_voltage: Number"], "None"), ([], "Tuple[int]")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"control.limits",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Optional[Number]=None",
|
||||
"acceleration: Optional[Number]=None",
|
||||
"torque: Optional[Number]=None",
|
||||
],
|
||||
"None",
|
||||
),
|
||||
([], "Tuple[int, int, int]"),
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"control.pid",
|
||||
[
|
||||
(
|
||||
[
|
||||
"kp: Optional[Number]=None",
|
||||
"ki: Optional[Number]=None",
|
||||
"kd: Optional[Number]=None",
|
||||
"reserved: Optional[Number]=None",
|
||||
"integral_rate: Optional[Number]=None",
|
||||
],
|
||||
"None",
|
||||
),
|
||||
([], "Tuple[int, int, int, None, int]"),
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"control.target_tolerances",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Optional[Number]=None",
|
||||
"position: Optional[Number]=None",
|
||||
],
|
||||
"None",
|
||||
),
|
||||
([], "Tuple[int, int]"),
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Motor",
|
||||
"control.stall_tolerances",
|
||||
[
|
||||
(
|
||||
[
|
||||
"speed: Optional[Number]=None",
|
||||
"time: Optional[Number]=None",
|
||||
],
|
||||
"None",
|
||||
),
|
||||
([], "Tuple[int, int]"),
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "TiltSensor", "tilt", [([], "Tuple[int, int]")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "InfraredSensor", "distance", [([], "int")]),
|
||||
pytest.param("pybricks.pupdevices", "InfraredSensor", "reflection", [([], "int")]),
|
||||
pytest.param("pybricks.pupdevices", "InfraredSensor", "count", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "color", [([], "Color")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "reflection", [([], "int")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "ambient", [([], "int")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "distance", [([], "int")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorDistanceSensor", "hsv", [([], "Color")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"detectable_colors",
|
||||
[(["colors: Collection[Color]"], "None"), ([], "Collection[Color]")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"light.on",
|
||||
[(["color: Color"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "light.off", [([], "None")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "PFMotor", "dc", [(["duty: Number"], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "PFMotor", "stop", [([], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "PFMotor", "brake", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"color",
|
||||
[(["surface: bool=True"], "Optional[Color]")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorSensor", "reflection", [([], "int")]),
|
||||
pytest.param("pybricks.pupdevices", "ColorSensor", "ambient", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"hsv",
|
||||
[(["surface: bool=True"], "Color")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"detectable_colors",
|
||||
[(["colors: Collection[Color]"], "None"), ([], "Collection[Color]")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"lights.on",
|
||||
[(["brightness: Union[Number, Tuple[Number, Number, Number]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorSensor", "lights.off", [([], "None")]),
|
||||
pytest.param("pybricks.pupdevices", "UltrasonicSensor", "distance", [([], "int")]),
|
||||
pytest.param("pybricks.pupdevices", "UltrasonicSensor", "presence", [([], "bool")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"UltrasonicSensor",
|
||||
"lights.on",
|
||||
[
|
||||
(
|
||||
["brightness: Union[Number, Tuple[Number, Number, Number, Number]]"],
|
||||
"None",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "UltrasonicSensor", "lights.off", [([], "None")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", "force", [([], "float")]),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", "distance", [([], "float")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ForceSensor",
|
||||
"pressed",
|
||||
[(["force: Number=3"], "bool")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", "touched", [([], "bool")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorLightMatrix",
|
||||
"on",
|
||||
[(["color: Union[Color, Collection[Color]]"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorLightMatrix", "off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "Light", "on", [(["brightness: Number=100"], "None")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "Light", "off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Remote",
|
||||
"name",
|
||||
[(["name: str"], "None"), ([], "str")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "Remote", "light.on", [(["color: Color"], "None")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "Remote", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Remote",
|
||||
"buttons.pressed",
|
||||
[([], "Collection[Button]")],
|
||||
),
|
||||
pytest.param("pybricks.tools", "StopWatch", "time", [([], "int")]),
|
||||
pytest.param("pybricks.tools", "StopWatch", "pause", [([], "None")]),
|
||||
pytest.param("pybricks.tools", "StopWatch", "resume", [([], "None")]),
|
||||
pytest.param("pybricks.tools", "StopWatch", "reset", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"straight",
|
||||
[(["distance: Number", "then: Stop=Stop.HOLD", "wait: bool=True"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"turn",
|
||||
[(["angle: Number", "then: Stop=Stop.HOLD", "wait: bool=True"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"curve",
|
||||
[
|
||||
(
|
||||
[
|
||||
"radius: Number",
|
||||
"angle: Number",
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"settings",
|
||||
[
|
||||
(
|
||||
[
|
||||
"straight_speed: Optional[Number]=None",
|
||||
"straight_acceleration: Optional[Number]=None",
|
||||
"turn_rate: Optional[Number]=None",
|
||||
"turn_acceleration: Optional[Number]=None",
|
||||
],
|
||||
"None",
|
||||
),
|
||||
([], "Tuple[int, int, int, int]"),
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"drive",
|
||||
[(["speed: Number", "turn_rate: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "stop", [([], "None")]),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "distance", [([], "int")]),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "angle", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.robotics", "DriveBase", "state", [([], "Tuple[int, int, int, int]")]
|
||||
),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "reset", [([], "None")]),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module,type,method,signatures", METHOD_PARAMS)
|
||||
def test_get_signature_for_methods(
|
||||
module: str, type: str, method: str, signatures: list[tuple[list[str], str]]
|
||||
):
|
||||
help = _get_method_signature(module, type, method)
|
||||
|
||||
# strip method now that code has been generated (may have leading subcomponent)
|
||||
method = method.split(".")[-1]
|
||||
|
||||
assert help["activeSignature"] == 0
|
||||
assert help["activeParameter"] == 0
|
||||
assert help["signatures"]
|
||||
|
||||
for sig, (params, returns) in zip_longest(help["signatures"], signatures):
|
||||
assert sig["label"] == f"{method}({', '.join(params)}) -> {returns}"
|
||||
assert sig["documentation"]["value"]
|
||||
# ensure signatures are stripped from doc comment
|
||||
assert not sig["documentation"]["value"].startswith(f"{method}(")
|
||||
|
||||
for pi, p in zip_longest(sig["parameters"], params):
|
||||
assert pi["label"] == p
|
||||
assert pi["documentation"]["value"]
|
||||
@@ -0,0 +1,2 @@
|
||||
version-tag-prefix "@pybricks/jedi/v"
|
||||
version-git-message "@pybricks/jedi v%s"
|
||||
@@ -0,0 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## 1.0.1 - 2022-09-07
|
||||
|
||||
### Fixed
|
||||
- Fixed exports.
|
||||
- Fixed missing README and CHANGELOG.
|
||||
|
||||
## 1.0.0 - 2022-09-07
|
||||
|
||||
### Added
|
||||
- Added new @pybricks/jedi package.
|
||||
@@ -0,0 +1,5 @@
|
||||
@pybricks/jedi
|
||||
==============
|
||||
|
||||
Binary distribution of the `pybricks-jedi` Python package and its dependencies
|
||||
for using in JavaScript/WASM, e.g. via Pyodide.
|
||||
Executable
+132
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import email.parser
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
|
||||
|
||||
package_json = {
|
||||
"name": "@pybricks/jedi",
|
||||
"version": "1.0.1",
|
||||
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pybricks/pybricks-api",
|
||||
"directory": "npm/jedi",
|
||||
},
|
||||
"publishConfig": {"registry": "https://registry.npmjs.org", "access": "public"},
|
||||
}
|
||||
|
||||
license_identifiers: set[str] = set()
|
||||
license_text: dict[str, str] = {}
|
||||
whl_map: dict[str, str] = {}
|
||||
|
||||
# ensure empty build directory so we don't end up with stale files
|
||||
shutil.rmtree(BUILD_DIR, True)
|
||||
BUILD_DIR.mkdir()
|
||||
|
||||
# download package and depedencies (*.whl files)
|
||||
subprocess.check_call(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"pip",
|
||||
"download",
|
||||
"--only-binary=any",
|
||||
"pybricks-jedi==1.1.0",
|
||||
],
|
||||
cwd=BUILD_DIR,
|
||||
)
|
||||
|
||||
# extract info from wheel files to generate javascript package files
|
||||
for whl in BUILD_DIR.glob("*.whl"):
|
||||
with zipfile.ZipFile(whl) as f:
|
||||
|
||||
def is_dist_info_metadata(info: zipfile.ZipInfo):
|
||||
return info.filename.endswith(".dist-info/METADATA")
|
||||
|
||||
def is_dist_info_license(info: zipfile.ZipInfo):
|
||||
return ".dist-info" in info.filename and "LICENSE" in info.filename
|
||||
|
||||
metadata = next(filter(is_dist_info_metadata, f.filelist))
|
||||
|
||||
with f.open(metadata.filename) as mf:
|
||||
meta = email.parser.BytesParser().parse(mf)
|
||||
|
||||
# extract package name from metadata
|
||||
name = meta["Name"]
|
||||
|
||||
if not name:
|
||||
raise RuntimeError(f"missing 'Name' in {whl.name} METADATA")
|
||||
|
||||
whl_map[name] = whl.name
|
||||
|
||||
# extract license identifier from metadata
|
||||
|
||||
license = meta["License"]
|
||||
|
||||
if not license:
|
||||
# some packages are missing license in metadata
|
||||
if whl.name.startswith("typing_extensions-"):
|
||||
license = "Python-2.0"
|
||||
else:
|
||||
raise RuntimeError(f"missing 'License' in {whl.name} METADATA")
|
||||
|
||||
license_identifiers.add(license)
|
||||
|
||||
# TODO: The LICENSE workaround for the pybricks-jedi package can be
|
||||
# dropped after the next release of that package
|
||||
if whl.name.startswith("pybricks_jedi-"):
|
||||
LICENSE = (
|
||||
pathlib.Path(__file__).parent.parent.parent / "jedi" / "LICENSE"
|
||||
).resolve()
|
||||
with open(LICENSE) as lf:
|
||||
license_text[whl.name] = lf.read()
|
||||
else:
|
||||
try:
|
||||
license = next(filter(is_dist_info_license, f.filelist))
|
||||
except StopIteration:
|
||||
raise RuntimeError(f"missing license for {whl.name}")
|
||||
|
||||
with f.open(license) as lf:
|
||||
license_text[whl.name] = lf.read().decode()
|
||||
|
||||
|
||||
# generate package.json file
|
||||
|
||||
# create "license" item from collected license identifiers
|
||||
package_json["license"] = (
|
||||
license_identifiers[0]
|
||||
if len(license_identifiers) < 2
|
||||
else f"({' AND '.join(license_identifiers)})"
|
||||
)
|
||||
|
||||
# create "exports" item from collect whl map
|
||||
package_json["exports"] = {f"./{k}.whl": f"./{v}" for k, v in whl_map.items()}
|
||||
|
||||
with open(BUILD_DIR / "package.json", "w") as f:
|
||||
json.dump(package_json, f, indent=2)
|
||||
|
||||
# generate LICENSE file
|
||||
|
||||
NEWLINE = "\n"
|
||||
DIVIDER = "=" * 80 + NEWLINE
|
||||
with open(BUILD_DIR / "LICENSE", "w") as f:
|
||||
for whl, text in license_text.items():
|
||||
f.write(DIVIDER)
|
||||
f.write(whl)
|
||||
f.writelines([NEWLINE, DIVIDER, NEWLINE])
|
||||
f.write(text)
|
||||
f.write(NEWLINE)
|
||||
|
||||
# copy additional files
|
||||
|
||||
ROOT_DIR = (pathlib.Path(__file__).parent).resolve()
|
||||
|
||||
for file in "README.md", "CHANGELOG.md":
|
||||
shutil.copy(ROOT_DIR / file, BUILD_DIR / file)
|
||||
Generated
+117
-113
@@ -7,8 +7,8 @@ optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "babel"
|
||||
version = "2.10.1"
|
||||
name = "Babel"
|
||||
version = "2.10.3"
|
||||
description = "Internationalization utilities"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -19,7 +19,7 @@ pytz = ">=2015.7"
|
||||
|
||||
[[package]]
|
||||
name = "black"
|
||||
version = "22.3.0"
|
||||
version = "22.8.0"
|
||||
description = "The uncompromising code formatter."
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -30,7 +30,7 @@ click = ">=8.0.0"
|
||||
mypy-extensions = ">=0.4.3"
|
||||
pathspec = ">=0.9.0"
|
||||
platformdirs = ">=2"
|
||||
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
||||
tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""}
|
||||
typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""}
|
||||
|
||||
[package.extras]
|
||||
@@ -41,7 +41,7 @@ uvloop = ["uvloop (>=0.15.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2022.5.18.1"
|
||||
version = "2022.6.15"
|
||||
description = "Python package for providing Mozilla's CA Bundle."
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -49,19 +49,19 @@ python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "chardet"
|
||||
version = "4.0.0"
|
||||
description = "Universal encoding detector for Python 2 and 3"
|
||||
version = "5.0.0"
|
||||
description = "Universal encoding detector for Python 3"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "charset-normalizer"
|
||||
version = "2.0.12"
|
||||
version = "2.1.1"
|
||||
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.5.0"
|
||||
python-versions = ">=3.6.0"
|
||||
|
||||
[package.extras]
|
||||
unicode_backport = ["unicodedata2"]
|
||||
@@ -79,7 +79,7 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
description = "Cross-platform colored terminal text."
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -132,7 +132,7 @@ python-versions = ">=3.5"
|
||||
|
||||
[[package]]
|
||||
name = "imagesize"
|
||||
version = "1.3.0"
|
||||
version = "1.4.1"
|
||||
description = "Getting image size from png/jpeg/jpeg2000/gif file"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -140,7 +140,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
|
||||
[[package]]
|
||||
name = "importlib-metadata"
|
||||
version = "4.11.4"
|
||||
version = "4.12.0"
|
||||
description = "Read metadata from Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -150,12 +150,12 @@ python-versions = ">=3.7"
|
||||
zipp = ">=0.5"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)"]
|
||||
docs = ["jaraco.packaging (>=9)", "rst.linker (>=1.9)", "sphinx"]
|
||||
perf = ["ipython"]
|
||||
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)", "importlib-resources (>=1.3)"]
|
||||
testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "jinja2"
|
||||
name = "Jinja2"
|
||||
version = "3.1.2"
|
||||
description = "A very fast and expressive template engine."
|
||||
category = "dev"
|
||||
@@ -169,7 +169,7 @@ MarkupSafe = ">=2.0"
|
||||
i18n = ["Babel (>=2.7)"]
|
||||
|
||||
[[package]]
|
||||
name = "markupsafe"
|
||||
name = "MarkupSafe"
|
||||
version = "2.1.1"
|
||||
description = "Safely add untrusted strings to HTML/XML markup."
|
||||
category = "dev"
|
||||
@@ -205,15 +205,15 @@ pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
|
||||
|
||||
[[package]]
|
||||
name = "pathspec"
|
||||
version = "0.9.0"
|
||||
version = "0.10.1"
|
||||
description = "Utility library for gitignore style pattern matching of file paths."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "pbr"
|
||||
version = "5.9.0"
|
||||
version = "5.10.0"
|
||||
description = "Python Build Reasonableness"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -228,8 +228,8 @@ optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"]
|
||||
test = ["appdirs (1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"]
|
||||
docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx (>=4)", "sphinx-autodoc-typehints (>=1.12)"]
|
||||
test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"]
|
||||
|
||||
[[package]]
|
||||
name = "pycodestyle"
|
||||
@@ -248,13 +248,16 @@ optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
|
||||
[[package]]
|
||||
name = "pygments"
|
||||
version = "2.12.0"
|
||||
name = "Pygments"
|
||||
version = "2.13.0"
|
||||
description = "Pygments is a syntax highlighting package written in Python."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
plugins = ["importlib-metadata"]
|
||||
|
||||
[[package]]
|
||||
name = "pyparsing"
|
||||
version = "3.0.9"
|
||||
@@ -264,11 +267,11 @@ optional = false
|
||||
python-versions = ">=3.6.8"
|
||||
|
||||
[package.extras]
|
||||
diagrams = ["railroad-diagrams", "jinja2"]
|
||||
diagrams = ["jinja2", "railroad-diagrams"]
|
||||
|
||||
[[package]]
|
||||
name = "pytz"
|
||||
version = "2022.1"
|
||||
version = "2022.2.1"
|
||||
description = "World timezone definitions, modern and historical"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -276,21 +279,21 @@ python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "requests"
|
||||
version = "2.27.1"
|
||||
version = "2.28.1"
|
||||
description = "Python HTTP for Humans."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
|
||||
python-versions = ">=3.7, <4"
|
||||
|
||||
[package.dependencies]
|
||||
certifi = ">=2017.4.17"
|
||||
charset-normalizer = {version = ">=2.0.0,<2.1.0", markers = "python_version >= \"3\""}
|
||||
idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""}
|
||||
charset-normalizer = ">=2,<3"
|
||||
idna = ">=2.5,<4"
|
||||
urllib3 = ">=1.21.1,<1.27"
|
||||
|
||||
[package.extras]
|
||||
socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"]
|
||||
use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
|
||||
use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"]
|
||||
|
||||
[[package]]
|
||||
name = "restructuredtext-lint"
|
||||
@@ -321,11 +324,12 @@ python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "Sphinx"
|
||||
version = "5.1.0.dev20220527.dev-20220527"
|
||||
version = "5.1.0.dev20220621"
|
||||
description = "Python documentation generator"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
develop = false
|
||||
|
||||
[package.dependencies]
|
||||
alabaster = ">=0.7,<0.8"
|
||||
@@ -348,8 +352,8 @@ sphinxcontrib-serializinghtml = ">=1.1.5"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinxcontrib-websupport"]
|
||||
lint = ["flake8 (>=3.5.0)", "isort", "mypy (>=0.950)", "docutils-stubs", "types-typed-ast", "types-requests"]
|
||||
test = ["pytest (>=4.6)", "html5lib", "cython", "typed-ast"]
|
||||
lint = ["docutils-stubs", "flake8 (>=3.5.0)", "isort", "mypy (>=0.950)", "types-requests", "types-typed-ast"]
|
||||
test = ["cython", "html5lib", "pytest (>=4.6)", "typed_ast"]
|
||||
|
||||
[package.source]
|
||||
type = "git"
|
||||
@@ -370,7 +374,7 @@ docutils = "<0.18"
|
||||
sphinx = ">=1.6"
|
||||
|
||||
[package.extras]
|
||||
dev = ["transifex-client", "sphinxcontrib-httpdomain", "bump2version"]
|
||||
dev = ["bump2version", "sphinxcontrib-httpdomain", "transifex-client"]
|
||||
|
||||
[[package]]
|
||||
name = "sphinxcontrib-applehelp"
|
||||
@@ -381,7 +385,7 @@ optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
lint = ["flake8", "mypy", "docutils-stubs"]
|
||||
lint = ["docutils-stubs", "flake8", "mypy"]
|
||||
test = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
@@ -393,7 +397,7 @@ optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
lint = ["flake8", "mypy", "docutils-stubs"]
|
||||
lint = ["docutils-stubs", "flake8", "mypy"]
|
||||
test = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
@@ -405,8 +409,8 @@ optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
lint = ["flake8", "mypy", "docutils-stubs"]
|
||||
test = ["pytest", "html5lib"]
|
||||
lint = ["docutils-stubs", "flake8", "mypy"]
|
||||
test = ["html5lib", "pytest"]
|
||||
|
||||
[[package]]
|
||||
name = "sphinxcontrib-jsmath"
|
||||
@@ -417,7 +421,7 @@ optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
test = ["pytest", "flake8", "mypy"]
|
||||
test = ["flake8", "mypy", "pytest"]
|
||||
|
||||
[[package]]
|
||||
name = "sphinxcontrib-qthelp"
|
||||
@@ -428,7 +432,7 @@ optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
lint = ["flake8", "mypy", "docutils-stubs"]
|
||||
lint = ["docutils-stubs", "flake8", "mypy"]
|
||||
test = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
@@ -440,16 +444,16 @@ optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
lint = ["flake8", "mypy", "docutils-stubs"]
|
||||
lint = ["docutils-stubs", "flake8", "mypy"]
|
||||
test = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
name = "stevedore"
|
||||
version = "3.5.0"
|
||||
version = "4.0.0"
|
||||
description = "Manage dynamic plugins for Python applications"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
python-versions = ">=3.8"
|
||||
|
||||
[package.dependencies]
|
||||
pbr = ">=2.0.0,<2.1.0 || >2.1.0"
|
||||
@@ -472,7 +476,7 @@ python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.2.0"
|
||||
version = "4.3.0"
|
||||
description = "Backported and Experimental Type Hints for Python 3.7+"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -480,28 +484,28 @@ python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "urllib3"
|
||||
version = "1.26.9"
|
||||
version = "1.26.12"
|
||||
description = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"]
|
||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
|
||||
socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"]
|
||||
brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"]
|
||||
secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "zipp"
|
||||
version = "3.8.0"
|
||||
version = "3.8.1"
|
||||
description = "Backport of pathlib-compatible object wrapper for zip files"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)"]
|
||||
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"]
|
||||
docs = ["jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx"]
|
||||
testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
@@ -513,54 +517,54 @@ alabaster = [
|
||||
{file = "alabaster-0.7.12-py2.py3-none-any.whl", hash = "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359"},
|
||||
{file = "alabaster-0.7.12.tar.gz", hash = "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02"},
|
||||
]
|
||||
babel = [
|
||||
{file = "Babel-2.10.1-py3-none-any.whl", hash = "sha256:3f349e85ad3154559ac4930c3918247d319f21910d5ce4b25d439ed8693b98d2"},
|
||||
{file = "Babel-2.10.1.tar.gz", hash = "sha256:98aeaca086133efb3e1e2aad0396987490c8425929ddbcfe0550184fdc54cd13"},
|
||||
Babel = [
|
||||
{file = "Babel-2.10.3-py3-none-any.whl", hash = "sha256:ff56f4892c1c4bf0d814575ea23471c230d544203c7748e8c68f0089478d48eb"},
|
||||
{file = "Babel-2.10.3.tar.gz", hash = "sha256:7614553711ee97490f732126dc077f8d0ae084ebc6a96e23db1482afabdb2c51"},
|
||||
]
|
||||
black = [
|
||||
{file = "black-22.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:2497f9c2386572e28921fa8bec7be3e51de6801f7459dffd6e62492531c47e09"},
|
||||
{file = "black-22.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5795a0375eb87bfe902e80e0c8cfaedf8af4d49694d69161e5bd3206c18618bb"},
|
||||
{file = "black-22.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e3556168e2e5c49629f7b0f377070240bd5511e45e25a4497bb0073d9dda776a"},
|
||||
{file = "black-22.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67c8301ec94e3bcc8906740fe071391bce40a862b7be0b86fb5382beefecd968"},
|
||||
{file = "black-22.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:fd57160949179ec517d32ac2ac898b5f20d68ed1a9c977346efbac9c2f1e779d"},
|
||||
{file = "black-22.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cc1e1de68c8e5444e8f94c3670bb48a2beef0e91dddfd4fcc29595ebd90bb9ce"},
|
||||
{file = "black-22.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2fc92002d44746d3e7db7cf9313cf4452f43e9ea77a2c939defce3b10b5c82"},
|
||||
{file = "black-22.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:a6342964b43a99dbc72f72812bf88cad8f0217ae9acb47c0d4f141a6416d2d7b"},
|
||||
{file = "black-22.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:328efc0cc70ccb23429d6be184a15ce613f676bdfc85e5fe8ea2a9354b4e9015"},
|
||||
{file = "black-22.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b"},
|
||||
{file = "black-22.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ad4efa5fad66b903b4a5f96d91461d90b9507a812b3c5de657d544215bb7877a"},
|
||||
{file = "black-22.3.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8477ec6bbfe0312c128e74644ac8a02ca06bcdb8982d4ee06f209be28cdf163"},
|
||||
{file = "black-22.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:637a4014c63fbf42a692d22b55d8ad6968a946b4a6ebc385c5505d9625b6a464"},
|
||||
{file = "black-22.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:863714200ada56cbc366dc9ae5291ceb936573155f8bf8e9de92aef51f3ad0f0"},
|
||||
{file = "black-22.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10dbe6e6d2988049b4655b2b739f98785a884d4d6b85bc35133a8fb9a2233176"},
|
||||
{file = "black-22.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:cee3e11161dde1b2a33a904b850b0899e0424cc331b7295f2a9698e79f9a69a0"},
|
||||
{file = "black-22.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:5891ef8abc06576985de8fa88e95ab70641de6c1fca97e2a15820a9b69e51b20"},
|
||||
{file = "black-22.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:30d78ba6bf080eeaf0b7b875d924b15cd46fec5fd044ddfbad38c8ea9171043a"},
|
||||
{file = "black-22.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ee8f1f7228cce7dffc2b464f07ce769f478968bfb3dd1254a4c2eeed84928aad"},
|
||||
{file = "black-22.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ee227b696ca60dd1c507be80a6bc849a5a6ab57ac7352aad1ffec9e8b805f21"},
|
||||
{file = "black-22.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:9b542ced1ec0ceeff5b37d69838106a6348e60db7b8fdd245294dc1d26136265"},
|
||||
{file = "black-22.3.0-py3-none-any.whl", hash = "sha256:bc58025940a896d7e5356952228b68f793cf5fcb342be703c3a2669a1488cb72"},
|
||||
{file = "black-22.3.0.tar.gz", hash = "sha256:35020b8886c022ced9282b51b5a875b6d1ab0c387b31a065b84db7c33085ca79"},
|
||||
{file = "black-22.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ce957f1d6b78a8a231b18e0dd2d94a33d2ba738cd88a7fe64f53f659eea49fdd"},
|
||||
{file = "black-22.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5107ea36b2b61917956d018bd25129baf9ad1125e39324a9b18248d362156a27"},
|
||||
{file = "black-22.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8166b7bfe5dcb56d325385bd1d1e0f635f24aae14b3ae437102dedc0c186747"},
|
||||
{file = "black-22.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd82842bb272297503cbec1a2600b6bfb338dae017186f8f215c8958f8acf869"},
|
||||
{file = "black-22.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d839150f61d09e7217f52917259831fe2b689f5c8e5e32611736351b89bb2a90"},
|
||||
{file = "black-22.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a05da0430bd5ced89176db098567973be52ce175a55677436a271102d7eaa3fe"},
|
||||
{file = "black-22.8.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a098a69a02596e1f2a58a2a1c8d5a05d5a74461af552b371e82f9fa4ada8342"},
|
||||
{file = "black-22.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:5594efbdc35426e35a7defa1ea1a1cb97c7dbd34c0e49af7fb593a36bd45edab"},
|
||||
{file = "black-22.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a983526af1bea1e4cf6768e649990f28ee4f4137266921c2c3cee8116ae42ec3"},
|
||||
{file = "black-22.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b2c25f8dea5e8444bdc6788a2f543e1fb01494e144480bc17f806178378005e"},
|
||||
{file = "black-22.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:78dd85caaab7c3153054756b9fe8c611efa63d9e7aecfa33e533060cb14b6d16"},
|
||||
{file = "black-22.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:cea1b2542d4e2c02c332e83150e41e3ca80dc0fb8de20df3c5e98e242156222c"},
|
||||
{file = "black-22.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5b879eb439094751185d1cfdca43023bc6786bd3c60372462b6f051efa6281a5"},
|
||||
{file = "black-22.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0a12e4e1353819af41df998b02c6742643cfef58282915f781d0e4dd7a200411"},
|
||||
{file = "black-22.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3a73f66b6d5ba7288cd5d6dad9b4c9b43f4e8a4b789a94bf5abfb878c663eb3"},
|
||||
{file = "black-22.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:e981e20ec152dfb3e77418fb616077937378b322d7b26aa1ff87717fb18b4875"},
|
||||
{file = "black-22.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8ce13ffed7e66dda0da3e0b2eb1bdfc83f5812f66e09aca2b0978593ed636b6c"},
|
||||
{file = "black-22.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:32a4b17f644fc288c6ee2bafdf5e3b045f4eff84693ac069d87b1a347d861497"},
|
||||
{file = "black-22.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0ad827325a3a634bae88ae7747db1a395d5ee02cf05d9aa7a9bd77dfb10e940c"},
|
||||
{file = "black-22.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53198e28a1fb865e9fe97f88220da2e44df6da82b18833b588b1883b16bb5d41"},
|
||||
{file = "black-22.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:bc4d4123830a2d190e9cc42a2e43570f82ace35c3aeb26a512a2102bce5af7ec"},
|
||||
{file = "black-22.8.0-py3-none-any.whl", hash = "sha256:d2c21d439b2baf7aa80d6dd4e3659259be64c6f49dfd0f32091063db0e006db4"},
|
||||
{file = "black-22.8.0.tar.gz", hash = "sha256:792f7eb540ba9a17e8656538701d3eb1afcb134e3b45b71f20b25c77a8db7e6e"},
|
||||
]
|
||||
certifi = [
|
||||
{file = "certifi-2022.5.18.1-py3-none-any.whl", hash = "sha256:f1d53542ee8cbedbe2118b5686372fb33c297fcd6379b050cca0ef13a597382a"},
|
||||
{file = "certifi-2022.5.18.1.tar.gz", hash = "sha256:9c5705e395cd70084351dd8ad5c41e65655e08ce46f2ec9cf6c2c08390f71eb7"},
|
||||
{file = "certifi-2022.6.15-py3-none-any.whl", hash = "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"},
|
||||
{file = "certifi-2022.6.15.tar.gz", hash = "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"},
|
||||
]
|
||||
chardet = [
|
||||
{file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"},
|
||||
{file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"},
|
||||
{file = "chardet-5.0.0-py3-none-any.whl", hash = "sha256:d3e64f022d254183001eccc5db4040520c0f23b1a3f33d6413e099eb7f126557"},
|
||||
{file = "chardet-5.0.0.tar.gz", hash = "sha256:0368df2bfd78b5fc20572bb4e9bb7fb53e2c094f60ae9993339e8671d0afb8aa"},
|
||||
]
|
||||
charset-normalizer = [
|
||||
{file = "charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"},
|
||||
{file = "charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"},
|
||||
{file = "charset-normalizer-2.1.1.tar.gz", hash = "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"},
|
||||
{file = "charset_normalizer-2.1.1-py3-none-any.whl", hash = "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"},
|
||||
]
|
||||
click = [
|
||||
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
|
||||
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
|
||||
]
|
||||
colorama = [
|
||||
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
|
||||
{file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
|
||||
{file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
|
||||
{file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
|
||||
]
|
||||
doc8 = [
|
||||
{file = "doc8-0.8.1-py2.py3-none-any.whl", hash = "sha256:4d58a5c8c56cedd2b2c9d6e3153be5d956cf72f6051128f0f2255c66227df721"},
|
||||
@@ -579,18 +583,18 @@ idna = [
|
||||
{file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"},
|
||||
]
|
||||
imagesize = [
|
||||
{file = "imagesize-1.3.0-py2.py3-none-any.whl", hash = "sha256:1db2f82529e53c3e929e8926a1fa9235aa82d0bd0c580359c67ec31b2fddaa8c"},
|
||||
{file = "imagesize-1.3.0.tar.gz", hash = "sha256:cd1750d452385ca327479d45b64d9c7729ecf0b3969a58148298c77092261f9d"},
|
||||
{file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"},
|
||||
{file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"},
|
||||
]
|
||||
importlib-metadata = [
|
||||
{file = "importlib_metadata-4.11.4-py3-none-any.whl", hash = "sha256:c58c8eb8a762858f49e18436ff552e83914778e50e9d2f1660535ffb364552ec"},
|
||||
{file = "importlib_metadata-4.11.4.tar.gz", hash = "sha256:5d26852efe48c0a32b0509ffbc583fda1a2266545a78d104a6f4aff3db17d700"},
|
||||
{file = "importlib_metadata-4.12.0-py3-none-any.whl", hash = "sha256:7401a975809ea1fdc658c3aa4f78cc2195a0e019c5cbc4c06122884e9ae80c23"},
|
||||
{file = "importlib_metadata-4.12.0.tar.gz", hash = "sha256:637245b8bab2b6502fcbc752cc4b7a6f6243bb02b31c5c26156ad103d3d45670"},
|
||||
]
|
||||
jinja2 = [
|
||||
Jinja2 = [
|
||||
{file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"},
|
||||
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
|
||||
]
|
||||
markupsafe = [
|
||||
MarkupSafe = [
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e"},
|
||||
@@ -645,12 +649,12 @@ packaging = [
|
||||
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
|
||||
]
|
||||
pathspec = [
|
||||
{file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"},
|
||||
{file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
|
||||
{file = "pathspec-0.10.1-py3-none-any.whl", hash = "sha256:46846318467efc4556ccfd27816e004270a9eeeeb4d062ce5e6fc7a87c573f93"},
|
||||
{file = "pathspec-0.10.1.tar.gz", hash = "sha256:7ace6161b621d31e7902eb6b5ae148d12cfd23f4a249b9ffb6b9fee12084323d"},
|
||||
]
|
||||
pbr = [
|
||||
{file = "pbr-5.9.0-py2.py3-none-any.whl", hash = "sha256:e547125940bcc052856ded43be8e101f63828c2d94239ffbe2b327ba3d5ccf0a"},
|
||||
{file = "pbr-5.9.0.tar.gz", hash = "sha256:e8dca2f4b43560edef58813969f52a56cef023146cbb8931626db80e6c1c4308"},
|
||||
{file = "pbr-5.10.0-py2.py3-none-any.whl", hash = "sha256:da3e18aac0a3c003e9eea1a81bd23e5a3a75d745670dcf736317b7d966887fdf"},
|
||||
{file = "pbr-5.10.0.tar.gz", hash = "sha256:cfcc4ff8e698256fc17ea3ff796478b050852585aa5bae79ecd05b2ab7b39b9a"},
|
||||
]
|
||||
platformdirs = [
|
||||
{file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
|
||||
@@ -664,21 +668,21 @@ pyflakes = [
|
||||
{file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"},
|
||||
{file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"},
|
||||
]
|
||||
pygments = [
|
||||
{file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"},
|
||||
{file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"},
|
||||
Pygments = [
|
||||
{file = "Pygments-2.13.0-py3-none-any.whl", hash = "sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42"},
|
||||
{file = "Pygments-2.13.0.tar.gz", hash = "sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
||||
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
|
||||
]
|
||||
pytz = [
|
||||
{file = "pytz-2022.1-py2.py3-none-any.whl", hash = "sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"},
|
||||
{file = "pytz-2022.1.tar.gz", hash = "sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7"},
|
||||
{file = "pytz-2022.2.1-py2.py3-none-any.whl", hash = "sha256:220f481bdafa09c3955dfbdddb7b57780e9a94f5127e35456a48589b9e0c0197"},
|
||||
{file = "pytz-2022.2.1.tar.gz", hash = "sha256:cea221417204f2d1a2aa03ddae3e867921971d0d76f14d87abb4414415bbdcf5"},
|
||||
]
|
||||
requests = [
|
||||
{file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"},
|
||||
{file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"},
|
||||
{file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"},
|
||||
{file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"},
|
||||
]
|
||||
restructuredtext-lint = [
|
||||
{file = "restructuredtext_lint-1.4.0.tar.gz", hash = "sha256:1b235c0c922341ab6c530390892eb9e92f90b9b75046063e047cacfb0f050c45"},
|
||||
@@ -721,8 +725,8 @@ sphinxcontrib-serializinghtml = [
|
||||
{file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"},
|
||||
]
|
||||
stevedore = [
|
||||
{file = "stevedore-3.5.0-py3-none-any.whl", hash = "sha256:a547de73308fd7e90075bb4d301405bebf705292fa90a90fc3bcf9133f58616c"},
|
||||
{file = "stevedore-3.5.0.tar.gz", hash = "sha256:f40253887d8712eaa2bb0ea3830374416736dc8ec0e22f5a65092c1174c44335"},
|
||||
{file = "stevedore-4.0.0-py3-none-any.whl", hash = "sha256:87e4d27fe96d0d7e4fc24f0cbe3463baae4ec51e81d95fbe60d2474636e0c7d8"},
|
||||
{file = "stevedore-4.0.0.tar.gz", hash = "sha256:f82cc99a1ff552310d19c379827c2c64dd9f85a38bcd5559db2470161867b786"},
|
||||
]
|
||||
toml = [
|
||||
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
|
||||
@@ -733,14 +737,14 @@ tomli = [
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
typing-extensions = [
|
||||
{file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"},
|
||||
{file = "typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"},
|
||||
{file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"},
|
||||
{file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"},
|
||||
]
|
||||
urllib3 = [
|
||||
{file = "urllib3-1.26.9-py2.py3-none-any.whl", hash = "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14"},
|
||||
{file = "urllib3-1.26.9.tar.gz", hash = "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e"},
|
||||
{file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"},
|
||||
{file = "urllib3-1.26.12.tar.gz", hash = "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"},
|
||||
]
|
||||
zipp = [
|
||||
{file = "zipp-3.8.0-py3-none-any.whl", hash = "sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099"},
|
||||
{file = "zipp-3.8.0.tar.gz", hash = "sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad"},
|
||||
{file = "zipp-3.8.1-py3-none-any.whl", hash = "sha256:47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009"},
|
||||
{file = "zipp-3.8.1.tar.gz", hash = "sha256:05b45f1ee8f807d0cc928485ca40a07cb491cf092ff587c0df9cb1fd154848d2"},
|
||||
]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks"
|
||||
version = "3.2.0b1-r2"
|
||||
version = "3.2.0b1-r3"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
authors = ["The Pybricks Authors <dev@pybricks.com>"]
|
||||
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
[flake8]
|
||||
exclude = .venv/,*.pyi,jedi/
|
||||
max-line-length = 88
|
||||
ignore = E203,W503
|
||||
ignore = E203,E501,W503
|
||||
|
||||
[doc8]
|
||||
ignore-path = .venv/,doc/main/build/,doc/api/build/,pybricks.egg-info/,npm/
|
||||
|
||||
+46
-47
@@ -107,7 +107,7 @@ class DCMotor:
|
||||
is generated while the motor is still moving."""
|
||||
|
||||
@overload
|
||||
def settings(self, max_voltage: Optional[int] = None) -> None:
|
||||
def settings(self, max_voltage: Number) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
@@ -140,16 +140,16 @@ class Control:
|
||||
"""
|
||||
|
||||
@overload
|
||||
def limits(self) -> Tuple[int, int, int]:
|
||||
def limits(
|
||||
self,
|
||||
speed: Optional[Number] = None,
|
||||
acceleration: Optional[Number] = None,
|
||||
torque: Optional[Number] = None,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def limits(
|
||||
self,
|
||||
speed: Optional[int] = None,
|
||||
acceleration: Optional[int] = None,
|
||||
torque: Optional[int] = None,
|
||||
) -> None:
|
||||
def limits(self) -> Tuple[int, int, int]:
|
||||
...
|
||||
|
||||
def limits(self, *args):
|
||||
@@ -173,18 +173,18 @@ class Control:
|
||||
"""
|
||||
|
||||
@overload
|
||||
def pid(self) -> Tuple[int, int, int, None, int]:
|
||||
def pid(
|
||||
self,
|
||||
kp: Optional[Number] = None,
|
||||
ki: Optional[Number] = None,
|
||||
kd: Optional[Number] = None,
|
||||
reserved: Optional[Number] = None,
|
||||
integral_rate: Optional[Number] = None,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def pid(
|
||||
self,
|
||||
kp: Optional[int] = None,
|
||||
ki: Optional[int] = None,
|
||||
kd: Optional[int] = None,
|
||||
reserved: Optional[int] = None,
|
||||
integral_rate: Optional[int] = None,
|
||||
) -> None:
|
||||
def pid(self) -> Tuple[int, int, int, None, int]:
|
||||
...
|
||||
|
||||
def pid(self, *args):
|
||||
@@ -210,13 +210,13 @@ class Control:
|
||||
"""
|
||||
|
||||
@overload
|
||||
def target_tolerances(self) -> Tuple[int, int]:
|
||||
def target_tolerances(
|
||||
self, speed: Optional[Number] = None, position: Optional[Number] = None
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def target_tolerances(
|
||||
self, speed: Optional[int] = None, position: Optional[int] = None
|
||||
) -> None:
|
||||
def target_tolerances(self) -> Tuple[int, int]:
|
||||
...
|
||||
|
||||
def target_tolerances(self, *args):
|
||||
@@ -236,13 +236,13 @@ class Control:
|
||||
"""
|
||||
|
||||
@overload
|
||||
def stall_tolerances(self) -> Tuple[int, int]:
|
||||
def stall_tolerances(
|
||||
self, speed: Optional[Number] = None, time: Optional[Number] = None
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def stall_tolerances(
|
||||
self, speed: Optional[int] = None, time: Optional[int] = None
|
||||
) -> None:
|
||||
def stall_tolerances(self) -> Tuple[int, int]:
|
||||
...
|
||||
|
||||
def stall_tolerances(self, speed, time):
|
||||
@@ -356,7 +356,7 @@ class Motor(DCMotor):
|
||||
|
||||
"""
|
||||
|
||||
def reset_angle(self, angle: Number) -> None:
|
||||
def reset_angle(self, angle: Optional[Number]) -> None:
|
||||
"""
|
||||
reset_angle(angle)
|
||||
|
||||
@@ -485,11 +485,11 @@ class Speaker:
|
||||
"""Plays beeps and sounds using a speaker."""
|
||||
|
||||
@overload
|
||||
def volume(self) -> int:
|
||||
def volume(self, volume: Number) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def volume(self, volume: Number) -> None:
|
||||
def volume(self) -> int:
|
||||
...
|
||||
|
||||
def volume(self, *args):
|
||||
@@ -570,7 +570,7 @@ class ColorLight:
|
||||
|
||||
Turns off the light."""
|
||||
|
||||
def blink(self, color: Color, durations: Collection[int]) -> None:
|
||||
def blink(self, color: Color, durations: Collection[Number]) -> None:
|
||||
"""blink(color, durations)
|
||||
|
||||
Blinks the light at a given color by turning it on and off for given
|
||||
@@ -599,7 +599,7 @@ class ColorLight:
|
||||
keeps running. When the animation completes, it repeats.
|
||||
|
||||
Arguments:
|
||||
colors (iter): Sequence of :class:`Color <.parameters.Color>`
|
||||
colors (list): Sequence of :class:`Color <.parameters.Color>`
|
||||
values.
|
||||
interval (Number, ms): Time between color updates.
|
||||
"""
|
||||
@@ -617,7 +617,7 @@ class LightArray:
|
||||
n (int): Number of lights
|
||||
"""
|
||||
|
||||
def on(self, brightness: Union[int, Collection[int]]) -> None:
|
||||
def on(self, brightness: Union[Number, Collection[Number]]) -> None:
|
||||
"""on(brightness)
|
||||
|
||||
Turns on the lights at the specified brightness.
|
||||
@@ -688,15 +688,15 @@ class LightMatrix:
|
||||
interval (Number, ms): Time to display each image in the list.
|
||||
"""
|
||||
|
||||
def pixel(self, row: int, column: int, brightness: Number = 100) -> None:
|
||||
def pixel(self, row: Number, column: Number, brightness: Number = 100) -> None:
|
||||
"""pixel(row, column, brightness=100)
|
||||
|
||||
Turns on one pixel at the specified brightness.
|
||||
|
||||
Arguments:
|
||||
row (int): Vertical grid index, starting at 0 from the top.
|
||||
column (int): Horizontal grid index, starting at 0 from the left.
|
||||
brightness (:ref:`brightness`): Brightness of the pixel.
|
||||
row (Number): Vertical grid index, starting at 0 from the top.
|
||||
column (Number): Horizontal grid index, starting at 0 from the left.
|
||||
brightness (Number :ref:`brightness`): Brightness of the pixel.
|
||||
"""
|
||||
|
||||
def off(self) -> None:
|
||||
@@ -749,13 +749,13 @@ class Keypad:
|
||||
def __init__(self, active_buttons):
|
||||
...
|
||||
|
||||
def pressed(self) -> Tuple[Button]:
|
||||
"""pressed() -> Tuple[Button]
|
||||
def pressed(self) -> Collection[Button]:
|
||||
"""pressed() -> Collection[Button]
|
||||
|
||||
Checks which buttons are currently pressed.
|
||||
|
||||
Returns:
|
||||
Tuple of pressed buttons.
|
||||
Set of pressed buttons.
|
||||
"""
|
||||
|
||||
|
||||
@@ -846,11 +846,11 @@ class Accelerometer(SimpleAccelerometer):
|
||||
"""Get measurements from an accelerometer."""
|
||||
|
||||
@overload
|
||||
def acceleration(self) -> Matrix:
|
||||
def acceleration(self, axis: Axis) -> float:
|
||||
...
|
||||
|
||||
@overload
|
||||
def acceleration(self, axis: Axis) -> float:
|
||||
def acceleration(self) -> Matrix:
|
||||
...
|
||||
|
||||
def acceleration(self, *args):
|
||||
@@ -915,11 +915,11 @@ class IMU(Accelerometer):
|
||||
"""
|
||||
|
||||
@overload
|
||||
def angular_velocity(self) -> Matrix:
|
||||
def angular_velocity(self, axis: Axis) -> float:
|
||||
...
|
||||
|
||||
@overload
|
||||
def angular_velocity(self, axis: Axis) -> float:
|
||||
def angular_velocity(self) -> Matrix:
|
||||
...
|
||||
|
||||
def angular_velocity(self, *args):
|
||||
@@ -1003,13 +1003,13 @@ class CommonColorSensor:
|
||||
...
|
||||
|
||||
@overload
|
||||
def detectable_colors(self) -> Tuple[Color]:
|
||||
def detectable_colors(self) -> Collection[Color]:
|
||||
...
|
||||
|
||||
def detectable_colors(self, *args):
|
||||
"""
|
||||
detectable_colors(colors)
|
||||
detectable_colors() -> Tuple[Color]
|
||||
detectable_colors() -> Collection[Color]
|
||||
|
||||
Configures which colors the ``color()`` method should detect.
|
||||
|
||||
@@ -1017,11 +1017,10 @@ class CommonColorSensor:
|
||||
This way, the full-color measurements are rounded to the nearest
|
||||
desired color, and other colors are ignored. This improves reliability.
|
||||
|
||||
If you give no arguments, the currently chosen colors will be returned
|
||||
as a tuple.
|
||||
If you give no arguments, the currently chosen colors will be returned.
|
||||
|
||||
Arguments:
|
||||
colors (tuple): Tuple of :class:`Color <.parameters.Color>`
|
||||
colors (list or tuple): List of :class:`Color <.parameters.Color>`
|
||||
objects: the colors that you want to detect. You can pick
|
||||
standard colors such as ``Color.MAGENTA``, or provide your
|
||||
own colors like ``Color(h=348, s=96, v=40)`` for even
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Tuple, Collection, overload
|
||||
from typing import Sequence, Tuple, overload
|
||||
|
||||
|
||||
class Matrix:
|
||||
@@ -51,7 +51,7 @@ class Matrix:
|
||||
def __ifloordiv__(self, other) -> Matrix:
|
||||
...
|
||||
|
||||
def __init__(self, rows: Collection[Collection[int]]):
|
||||
def __init__(self, rows: Sequence[Sequence[float]]):
|
||||
"""Matrix(rows)
|
||||
|
||||
Arguments:
|
||||
@@ -60,7 +60,7 @@ class Matrix:
|
||||
"""
|
||||
|
||||
@property
|
||||
def T(self) -> Matrix:
|
||||
def T(self) -> Matrix: # noqa: N802
|
||||
"""Returns a new :class:`.Matrix` that is the transpose of the
|
||||
original."""
|
||||
|
||||
@@ -73,12 +73,31 @@ class Matrix:
|
||||
|
||||
@overload
|
||||
def vector(x: float, y: float) -> Matrix:
|
||||
...
|
||||
"""
|
||||
Convenience function to create a :class:`.Matrix` with the shape (``2``, ``1``).
|
||||
|
||||
Arguments:
|
||||
x (float): x-coordinate of the vector.
|
||||
y (float): y-coordinate of the vector.
|
||||
|
||||
Returns:
|
||||
A matrix with the shape of a column vector.
|
||||
"""
|
||||
|
||||
|
||||
@overload
|
||||
def vector(x: float, y: float, z: float) -> Matrix:
|
||||
...
|
||||
"""
|
||||
Convenience function to create a :class:`.Matrix` with the shape (``3``, ``1``).
|
||||
|
||||
Arguments:
|
||||
x (float): x-coordinate of the vector.
|
||||
y (float): y-coordinate of the vector.
|
||||
z (float): z-coordinate of the vector.
|
||||
|
||||
Returns:
|
||||
A matrix with the shape of a column vector.
|
||||
"""
|
||||
|
||||
|
||||
def vector(*args):
|
||||
|
||||
+38
-5
@@ -1,10 +1,10 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2020 The Pybricks Authors
|
||||
# Copyright (c) 2018-2022 The Pybricks Authors
|
||||
|
||||
"""LEGO® Programmable Hubs."""
|
||||
from . import _common
|
||||
from .ev3dev import _speaker
|
||||
from .geometry import Axis as _Axis
|
||||
from .geometry import Axis
|
||||
from .media.ev3dev import Image as _Image
|
||||
from .parameters import Button as _Button
|
||||
|
||||
@@ -63,7 +63,7 @@ class TechnicHub:
|
||||
system = _common.System()
|
||||
button = _common.Keypad([_Button.CENTER])
|
||||
|
||||
def __init__(self, top_side: _Axis = _Axis.Z, front_side: _Axis = _Axis.X):
|
||||
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
|
||||
"""TechnicHub(top_side=Axis.Z, front_side=Axis.X)
|
||||
|
||||
Initializes the hub. Optionally, specify how the hub is
|
||||
@@ -79,8 +79,37 @@ class TechnicHub:
|
||||
"""
|
||||
|
||||
|
||||
class EssentialHub:
|
||||
"""LEGO® SPIKE Essential Hub."""
|
||||
|
||||
# These class attributes are here for auto-documentation only.
|
||||
# In reality, they are instance attributes created by __init__.
|
||||
battery = _common.Battery()
|
||||
button = _common.Keypad([_Button.CENTER])
|
||||
charger = _common.Charger()
|
||||
light = _common.ColorLight()
|
||||
imu = _common.IMU()
|
||||
system = _common.System()
|
||||
|
||||
def __init__(self, top_side=Axis.Z, front_side=Axis.X):
|
||||
"""__init__(top_side=Axis.Z, front_side=Axis.X)
|
||||
|
||||
Initializes the hub. Optionally, specify how the hub is
|
||||
:ref:`placed in your design <robotframe>` by saying in which
|
||||
direction the top side (with the button) and the front side (with the USB
|
||||
port, and I/O ports A and B) are pointing.
|
||||
|
||||
Arguments:
|
||||
top_side (Axis): The axis that passes through the *top side* of
|
||||
the hub.
|
||||
front_side (Axis): The axis that passes through the *front side* of
|
||||
the hub.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class PrimeHub:
|
||||
"""LEGO® SPIKE Prime Hub or LEGO® MINDSTORMS Inventor Hub."""
|
||||
"""LEGO® SPIKE Prime Hub."""
|
||||
|
||||
# These class attributes are here for auto-documentation only.
|
||||
# In reality, they are instance attributes created by __init__.
|
||||
@@ -100,7 +129,7 @@ class PrimeHub:
|
||||
imu = _common.IMU()
|
||||
system = _common.System()
|
||||
|
||||
def __init__(self, top_side: _Axis = _Axis.Z, front_side: _Axis = _Axis.X):
|
||||
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
|
||||
"""PrimeHub(top_side=Axis.Z, front_side=Axis.X)
|
||||
|
||||
Initializes the hub. Optionally, specify how the hub is
|
||||
@@ -118,3 +147,7 @@ class PrimeHub:
|
||||
|
||||
class InventorHub(PrimeHub):
|
||||
"""LEGO® MINDSTORMS Inventor Hub."""
|
||||
|
||||
|
||||
# HACK: hide from jedi
|
||||
del Axis
|
||||
|
||||
@@ -11,7 +11,7 @@ import os
|
||||
|
||||
from .geometry import Matrix as _Matrix
|
||||
|
||||
if TYPE_CHECKING or os.environ["SPHINX_BUILD"] == "True":
|
||||
if TYPE_CHECKING or os.environ.get("SPHINX_BUILD") == "True":
|
||||
Number = Union[int, float]
|
||||
"""
|
||||
Numbers can be represented as integers or floating point values:
|
||||
@@ -36,6 +36,7 @@ if TYPE_CHECKING or os.environ["SPHINX_BUILD"] == "True":
|
||||
|
||||
|
||||
class _PybricksEnumMeta(type(Enum)):
|
||||
@classmethod
|
||||
def __dir__(cls):
|
||||
yield "__class__"
|
||||
yield "__name__"
|
||||
@@ -131,13 +132,13 @@ class Port(_PybricksEnum):
|
||||
class Stop(_PybricksEnum):
|
||||
"""Action after the motor stops."""
|
||||
|
||||
COAST: Port = 0
|
||||
COAST: Stop = 0
|
||||
"""Let the motor move freely."""
|
||||
|
||||
BRAKE: Port = 1
|
||||
BRAKE: Stop = 1
|
||||
"""Passively resist small external forces."""
|
||||
|
||||
HOLD: Port = 2
|
||||
HOLD: Stop = 2
|
||||
"""Keep controlling the motor to hold it at the commanded angle. This is
|
||||
only available on motors with encoders."""
|
||||
|
||||
|
||||
+127
-28
@@ -8,25 +8,63 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING, Collection, Optional, Union, overload, Tuple
|
||||
|
||||
from . import _common
|
||||
from .parameters import (
|
||||
Button as _Button,
|
||||
Color as _Color,
|
||||
Direction as _Direction,
|
||||
Port as _Port,
|
||||
)
|
||||
from .parameters import Button, Color, Direction
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .parameters import Number as _Number
|
||||
from .parameters import Number, Port
|
||||
|
||||
|
||||
class DCMotor(_common.DCMotor):
|
||||
"""LEGO® Powered Up motor without rotation sensors."""
|
||||
|
||||
# HACK: jedi can't find inherited __init__ so we have to duplicate docs
|
||||
def __init__(self, port: Port, positive_direction: Direction = Direction.CLOCKWISE):
|
||||
"""__init__(port, positive_direction=Direction.CLOCKWISE)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the motor is connected.
|
||||
positive_direction (Direction): Which direction the motor should
|
||||
turn when you give a positive duty cycle value.
|
||||
"""
|
||||
|
||||
|
||||
class Motor(_common.Motor):
|
||||
"""LEGO® Powered Up motor with rotation sensors."""
|
||||
|
||||
def reset_angle(self, angle: Optional[int]) -> None:
|
||||
# HACK: jedi can't find inherited __init__ so we have to duplicate docs
|
||||
def __init__(
|
||||
self,
|
||||
port: Port,
|
||||
positive_direction: Direction = Direction.CLOCKWISE,
|
||||
gears: Optional[Union[Collection[int], Collection[Collection[int]]]] = None,
|
||||
reset_angle: bool = True,
|
||||
):
|
||||
"""__init__(port, positive_direction=Direction.CLOCKWISE, gears=None, reset_angle=True)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the motor is connected.
|
||||
positive_direction (Direction): Which direction the motor should
|
||||
turn when you give a positive speed value or
|
||||
angle.
|
||||
gears (list):
|
||||
List of gears linked to the motor.
|
||||
|
||||
For example: ``[12, 36]`` represents a gear train with a
|
||||
12-tooth and a 36-tooth gear. Use a list of lists for multiple
|
||||
gear trains, such as ``[[12, 36], [20, 16, 40]]``.
|
||||
|
||||
When you specify a gear train, all motor commands and settings
|
||||
are automatically adjusted to account for the resulting gear
|
||||
ratio. The motor direction remains unchanged by this.
|
||||
reset_angle(bool):
|
||||
Choose ``True`` to reset the rotation sensor value to the
|
||||
absolute marker angle (between -180 and 179).
|
||||
Choose ``False`` to keep the
|
||||
current value, so your program knows where it left off last
|
||||
time.
|
||||
"""
|
||||
|
||||
def reset_angle(self, angle: Optional[Number] = None) -> None:
|
||||
"""reset_angle(angle=None)
|
||||
|
||||
Sets the accumulated rotation angle of the motor to a desired value.
|
||||
@@ -45,13 +83,13 @@ class Remote:
|
||||
light = _common.ColorLight()
|
||||
buttons = _common.Keypad(
|
||||
(
|
||||
_Button.LEFT_MINUS,
|
||||
_Button.RIGHT_MINUS,
|
||||
_Button.LEFT,
|
||||
_Button.CENTER,
|
||||
_Button.RIGHT,
|
||||
_Button.LEFT_PLUS,
|
||||
_Button.RIGHT_PLUS,
|
||||
Button.LEFT_MINUS,
|
||||
Button.RIGHT_MINUS,
|
||||
Button.LEFT,
|
||||
Button.CENTER,
|
||||
Button.RIGHT,
|
||||
Button.LEFT_PLUS,
|
||||
Button.RIGHT_PLUS,
|
||||
)
|
||||
)
|
||||
addresss: Union[str, None]
|
||||
@@ -94,7 +132,7 @@ class Remote:
|
||||
class TiltSensor:
|
||||
"""LEGO® Powered Up Tilt Sensor."""
|
||||
|
||||
def __init__(self, port: _Port):
|
||||
def __init__(self, port: Port):
|
||||
"""TiltSensor(port)
|
||||
|
||||
Arguments:
|
||||
@@ -116,6 +154,14 @@ class ColorDistanceSensor(_common.CommonColorSensor):
|
||||
|
||||
light = _common.ColorLight()
|
||||
|
||||
# HACK: jedi can't find inherited __init__ so docs have to be duplicated
|
||||
def __init__(self, port: Port):
|
||||
"""__init__(port)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
def distance(self) -> int:
|
||||
"""distance() -> int: %
|
||||
|
||||
@@ -135,8 +181,8 @@ class PFMotor(DCMotor):
|
||||
self,
|
||||
sensor: ColorDistanceSensor,
|
||||
channel: int,
|
||||
color: _Color,
|
||||
positive_direction: _Direction = _Direction.CLOCKWISE,
|
||||
color: Color,
|
||||
positive_direction: Direction = Direction.CLOCKWISE,
|
||||
):
|
||||
"""PFMotor(sensor, channel, color, positive_direction=Direction.CLOCKWISE)
|
||||
|
||||
@@ -157,15 +203,59 @@ class PFMotor(DCMotor):
|
||||
class ColorSensor(_common.AmbientColorSensor):
|
||||
"""LEGO® SPIKE Color Sensor."""
|
||||
|
||||
lights = _common.LightArray(3)
|
||||
class _LightArray(_common.LightArray):
|
||||
def __init__(self):
|
||||
super().__init__(3)
|
||||
|
||||
def on(self, brightness: Union[Number, Tuple[Number, Number, Number]]) -> None:
|
||||
"""on(brightness)
|
||||
|
||||
Turns on the lights at the specified brightness.
|
||||
|
||||
Arguments:
|
||||
brightness (Number or tuple, %):
|
||||
A single value will set the brightness of all three lights
|
||||
to the same value. A tuple of 3 values will set the
|
||||
brightness of each LED individually.
|
||||
"""
|
||||
return super().on(brightness)
|
||||
|
||||
lights = _LightArray()
|
||||
|
||||
# HACK: jedi can't find inherited __init__ so docs have to be duplicated
|
||||
def __init__(self, port: Port):
|
||||
"""__init__(port)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
|
||||
class UltrasonicSensor:
|
||||
"""LEGO® SPIKE Color Sensor."""
|
||||
|
||||
lights = _common.LightArray(3)
|
||||
class _LightArray(_common.LightArray):
|
||||
def __init__(self):
|
||||
super().__init__(4)
|
||||
|
||||
def __init__(self, port: _Port):
|
||||
def on(
|
||||
self, brightness: Union[Number, Tuple[Number, Number, Number, Number]]
|
||||
) -> None:
|
||||
"""on(brightness)
|
||||
|
||||
Turns on the lights at the specified brightness.
|
||||
|
||||
Arguments:
|
||||
brightness (Number or tuple, %):
|
||||
A single value will set the brightness of all four lights
|
||||
to the same value. A tuple of 4 values will set the
|
||||
brightness of each LED individually.
|
||||
"""
|
||||
return super().on(brightness)
|
||||
|
||||
lights = _LightArray()
|
||||
|
||||
def __init__(self, port: Port):
|
||||
"""UltrasonicSensor(port)
|
||||
|
||||
Arguments:
|
||||
@@ -199,7 +289,7 @@ class UltrasonicSensor:
|
||||
class ForceSensor:
|
||||
"""LEGO® SPIKE Force Sensor."""
|
||||
|
||||
def __init__(self, port: _Port):
|
||||
def __init__(self, port: Port):
|
||||
"""ForceSensor(port)
|
||||
|
||||
Arguments:
|
||||
@@ -224,7 +314,7 @@ class ForceSensor:
|
||||
Movement up to approximately 8.00 mm.
|
||||
"""
|
||||
|
||||
def pressed(self, force: _Number = 3) -> bool:
|
||||
def pressed(self, force: Number = 3) -> bool:
|
||||
"""pressed(force=3) -> bool
|
||||
|
||||
Checks if the sensor button is pressed.
|
||||
@@ -255,7 +345,7 @@ class ColorLightMatrix:
|
||||
LEGO® SPIKE 3x3 Color Light Matrix.
|
||||
"""
|
||||
|
||||
def __init__(self, port: _Port):
|
||||
def __init__(self, port: Port):
|
||||
"""ColorLightMatrix(port)
|
||||
|
||||
Arguments:
|
||||
@@ -264,7 +354,7 @@ class ColorLightMatrix:
|
||||
"""
|
||||
...
|
||||
|
||||
def on(self, color: Union[_Color, Collection[_Color]]) -> None:
|
||||
def on(self, color: Union[Color, Collection[Color]]) -> None:
|
||||
"""on(colors)
|
||||
|
||||
Turns the lights on.
|
||||
@@ -288,7 +378,7 @@ class ColorLightMatrix:
|
||||
class InfraredSensor:
|
||||
"""LEGO® Powered Up Infrared Sensor."""
|
||||
|
||||
def __init__(self, port: _Port):
|
||||
def __init__(self, port: Port):
|
||||
"""InfraredSensor(port)
|
||||
|
||||
Arguments:
|
||||
@@ -328,14 +418,14 @@ class InfraredSensor:
|
||||
class Light:
|
||||
"""LEGO® Powered Up Light."""
|
||||
|
||||
def __init__(self, port: _Port):
|
||||
def __init__(self, port: Port):
|
||||
"""Light(port)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the device is connected.
|
||||
"""
|
||||
|
||||
def on(self, brightness: _Number = 100) -> None:
|
||||
def on(self, brightness: Number = 100) -> None:
|
||||
"""on(brightness=100)
|
||||
|
||||
Turns on the light at the specified brightness.
|
||||
@@ -349,3 +439,12 @@ class Light:
|
||||
"""off()
|
||||
|
||||
Turns off the light."""
|
||||
|
||||
|
||||
# HACK: exclude from jedi
|
||||
if TYPE_CHECKING:
|
||||
del Button
|
||||
del Color
|
||||
del Direction
|
||||
del Number
|
||||
del Port
|
||||
|
||||
+25
-15
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2021 The Pybricks Authors
|
||||
# Copyright (c) 2018-2022 The Pybricks Authors
|
||||
|
||||
"""Robotics module for the Pybricks API."""
|
||||
|
||||
@@ -8,10 +8,11 @@ from __future__ import annotations
|
||||
from typing import Tuple, Optional, overload, TYPE_CHECKING
|
||||
|
||||
from . import _common
|
||||
from .parameters import Stop as _Stop
|
||||
from .parameters import Stop
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .parameters import Number as _Number
|
||||
from ._common import Motor
|
||||
from .parameters import Number
|
||||
|
||||
|
||||
class DriveBase:
|
||||
@@ -50,10 +51,10 @@ class DriveBase:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
left_motor: _common.Motor,
|
||||
right_motor: _common.Motor,
|
||||
wheel_diameter: _Number,
|
||||
axle_track: _Number,
|
||||
left_motor: Motor,
|
||||
right_motor: Motor,
|
||||
wheel_diameter: Number,
|
||||
axle_track: Number,
|
||||
):
|
||||
"""DriveBase(left_motor, right_motor, wheel_diameter, axle_track)
|
||||
|
||||
@@ -67,7 +68,7 @@ class DriveBase:
|
||||
both wheels touch the ground.
|
||||
"""
|
||||
|
||||
def drive(self, speed: _Number, turn_rate: _Number) -> None:
|
||||
def drive(self, speed: Number, turn_rate: Number) -> None:
|
||||
"""drive(speed, turn_rate)
|
||||
|
||||
Starts driving at the specified speed and turn rate. Both values are
|
||||
@@ -118,10 +119,10 @@ class DriveBase:
|
||||
@overload
|
||||
def settings(
|
||||
self,
|
||||
straight_speed: Optional[_Number],
|
||||
straight_acceleration: Optional[_Number],
|
||||
turn_rate: Optional[_Number],
|
||||
turn_acceleration: Optional[_Number],
|
||||
straight_speed: Optional[Number] = None,
|
||||
straight_acceleration: Optional[Number] = None,
|
||||
turn_rate: Optional[Number] = None,
|
||||
turn_acceleration: Optional[Number] = None,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@@ -147,7 +148,9 @@ class DriveBase:
|
||||
deceleration of the robot.
|
||||
"""
|
||||
|
||||
def straight(self, distance: _Number, then=_Stop.HOLD, wait=True) -> None:
|
||||
def straight(
|
||||
self, distance: Number, then: Stop = Stop.HOLD, wait: bool = True
|
||||
) -> None:
|
||||
"""straight(distance, then=Stop.HOLD, wait=True)
|
||||
|
||||
Drives straight for a given distance and then stops.
|
||||
@@ -159,7 +162,7 @@ class DriveBase:
|
||||
with the rest of the program.
|
||||
"""
|
||||
|
||||
def turn(self, angle: _Number, then=_Stop.HOLD, wait=True) -> None:
|
||||
def turn(self, angle: Number, then: Stop = Stop.HOLD, wait: bool = True) -> None:
|
||||
"""turn(angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Turns in place by a given angle and then stops.
|
||||
@@ -172,7 +175,7 @@ class DriveBase:
|
||||
"""
|
||||
|
||||
def curve(
|
||||
self, radius: _Number, angle: _Number, then=_Stop.HOLD, wait=True
|
||||
self, radius: Number, angle: Number, then: Stop = Stop.HOLD, wait: bool = True
|
||||
) -> None:
|
||||
"""curve(radius, angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
@@ -185,3 +188,10 @@ class DriveBase:
|
||||
wait (bool): Wait for the maneuver to complete before continuing
|
||||
with the rest of the program.
|
||||
"""
|
||||
|
||||
|
||||
# HACK: hide from jedi
|
||||
if TYPE_CHECKING:
|
||||
del Motor
|
||||
del Number
|
||||
del Stop
|
||||
|
||||
+13
-3
@@ -3,10 +3,15 @@
|
||||
|
||||
"""Common tools for timing and data logging."""
|
||||
|
||||
from typing import Any
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .parameters import Number
|
||||
|
||||
|
||||
def wait(time: int) -> None:
|
||||
def wait(time: Number) -> None:
|
||||
"""wait(time)
|
||||
|
||||
Pauses the user program for a specified amount of time.
|
||||
@@ -63,7 +68,7 @@ class DataLog:
|
||||
name: str = "log",
|
||||
timestamp: bool = True,
|
||||
extension: str = "csv",
|
||||
append: bool = False
|
||||
append: bool = False,
|
||||
):
|
||||
"""DataLog(*headers, name='log', timestamp=True, extension='csv', append=False)
|
||||
|
||||
@@ -90,3 +95,8 @@ class DataLog:
|
||||
Arguments:
|
||||
values (object, object, ...): One or more objects or values.
|
||||
"""
|
||||
|
||||
|
||||
# HACK: hide from jedi
|
||||
if TYPE_CHECKING:
|
||||
del Number
|
||||
|
||||
+164
-83
@@ -45,6 +45,7 @@ _bool = bool
|
||||
_bytearray = bytearray
|
||||
_bytes = bytes
|
||||
_callable = callable
|
||||
_classmethod = classmethod
|
||||
_complex = complex
|
||||
_dict = dict
|
||||
_float = float
|
||||
@@ -56,49 +57,77 @@ _type = type
|
||||
|
||||
|
||||
def abs(x: Any) -> Any:
|
||||
"""
|
||||
Returns the absolute value of a number. The argument may be an integer, a
|
||||
floating point number, or an object implementing __abs__().
|
||||
"""abs(x) -> Any
|
||||
|
||||
.. If the argument is a complex number, its magnitude is returned.
|
||||
Returns the absolute value of a number.
|
||||
|
||||
The argument may be an integer, a
|
||||
floating point number, or any object implementing ``__abs__()``.
|
||||
If the argument is a complex number, its magnitude is returned.
|
||||
|
||||
Arguments:
|
||||
x (Any): The value.
|
||||
|
||||
Returns:
|
||||
Absolute value of ``x``.
|
||||
"""
|
||||
|
||||
|
||||
def all(iterable: Iterable) -> _bool:
|
||||
"""
|
||||
Returns ``True`` if all elements of the iterable are true (or if the
|
||||
iterable is empty).
|
||||
def all(x: Iterable) -> _bool:
|
||||
"""all(x) -> bool
|
||||
|
||||
Checks if all elements of the iterable are true.
|
||||
|
||||
Equivalent to::
|
||||
|
||||
def all(iterable):
|
||||
for element in iterable:
|
||||
def all(x):
|
||||
for element in x:
|
||||
if not element:
|
||||
return False
|
||||
return True
|
||||
|
||||
Arguments:
|
||||
x (Iterable): The iterable to be checked.
|
||||
|
||||
Returns:
|
||||
``True`` if the iterable ``x`` is empty or if all elements
|
||||
are true. Otherwise ``False``.
|
||||
"""
|
||||
|
||||
|
||||
def any(iterable: Iterable) -> _bool:
|
||||
"""
|
||||
Returns ``True`` if any element of the iterable is true. If the iterable is
|
||||
empty, returns ``False``.
|
||||
def any(x: Iterable) -> _bool:
|
||||
"""any(x) -> bool
|
||||
|
||||
Checks if at least one elements of the iterable is true.
|
||||
|
||||
Equivalent to::
|
||||
|
||||
def any(iterable):
|
||||
for element in iterable:
|
||||
def any(x):
|
||||
for element in x:
|
||||
if element:
|
||||
return True
|
||||
return False
|
||||
|
||||
Arguments:
|
||||
x (Iterable): The iterable to be checked.
|
||||
|
||||
Returns:
|
||||
``True`` if at least one element in ``x`` is true. Otherwise ``False``.
|
||||
"""
|
||||
|
||||
|
||||
def bin(x: Any) -> _str:
|
||||
"""
|
||||
Converts an integer number to a binary string prefixed with “0b”. The result
|
||||
is a valid Python expression. If ``x`` is not a Python :class:`int` object,
|
||||
it has to define an ``__index__()`` method that returns an integer.
|
||||
"""bin(x) -> str
|
||||
|
||||
Converts an integer to its binary representation. The result is a
|
||||
string prefixed with ``0b``. The result is a valid Python expression.
|
||||
For example, ``bin(5)`` gives ``"0b101"``.
|
||||
|
||||
Arguments:
|
||||
x (int): Value to be converted.
|
||||
|
||||
Returns:
|
||||
A string representing the binary form of the input.
|
||||
"""
|
||||
|
||||
|
||||
@@ -113,14 +142,19 @@ class bool:
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""
|
||||
bool()
|
||||
bool(x)
|
||||
|
||||
Creates a boolean value, which is either ``True`` or ``False``.
|
||||
|
||||
The input value is converted using the standard truth testing
|
||||
procedure. If no input is given, it is assumed to be ``False``.
|
||||
|
||||
Arguments:
|
||||
x: Value that is tested for being ``True`` or ``False``. It is
|
||||
converted using the standard truth testing procedure.
|
||||
x: Value to be converted.
|
||||
|
||||
Returns:
|
||||
Result of the truth-test. If no object is given, it returns ``False``.
|
||||
Result of the truth-test.
|
||||
"""
|
||||
|
||||
|
||||
@@ -192,12 +226,18 @@ def callable(object: Any) -> _bool:
|
||||
"""
|
||||
|
||||
|
||||
def chr(i: _int) -> _str:
|
||||
"""
|
||||
Returns the string representing a character whose Unicode code point is the
|
||||
integer ``i``. For example, ``chr(97)`` returns the string ``'a'``.
|
||||
def chr(x: _int) -> _str:
|
||||
"""chr(x) -> str
|
||||
|
||||
This is the inverse of :meth:`ord`.
|
||||
Returns the string representing a character whose Unicode code is the
|
||||
integer ``x``. This is the inverse of :meth:`ord`. For
|
||||
example, ``chr(97)`` gives ``"a"``.
|
||||
|
||||
Arguments:
|
||||
x (int): Value to be converted (0-255).
|
||||
|
||||
Returns:
|
||||
A string with one character, corresponding to the given Unicode value.
|
||||
"""
|
||||
|
||||
|
||||
@@ -231,9 +271,9 @@ class complex:
|
||||
...
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""complex()
|
||||
complex(string: str)
|
||||
complex(a: Union[float, complex], b: Union[float, complex] = 0)
|
||||
"""
|
||||
complex(string)
|
||||
complex(a=0, b=0)
|
||||
|
||||
Creates a complex number from a string or from a pair of numbers.
|
||||
|
||||
@@ -242,12 +282,12 @@ class complex:
|
||||
as: ``a + b * j``.
|
||||
|
||||
Arguments:
|
||||
string: A string of the form ``'1+2j'`` .
|
||||
a: A real-valued or complex number.
|
||||
b: A real-valued or complex number.
|
||||
string (str): A string of the form ``'1+2j'`` .
|
||||
a (float or complex): A real-valued or complex number.
|
||||
b (float or complex): A real-valued or complex number.
|
||||
|
||||
Returns:
|
||||
Complex number, obtained from the string or as the result of ``a + b * j``.
|
||||
The resulting complex number.
|
||||
"""
|
||||
|
||||
|
||||
@@ -262,7 +302,14 @@ class dict:
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
"""
|
||||
Creates a new dictionary.
|
||||
dict(**kwargs)
|
||||
dict(mapping, **kwargs)
|
||||
dict(iterable, **kwargs)
|
||||
|
||||
See the standard
|
||||
`Python documentation
|
||||
<https://docs.python.org/3/library/stdtypes.html#mapping-types-dict>`_
|
||||
for a comprehensive reference with examples.
|
||||
"""
|
||||
|
||||
|
||||
@@ -388,17 +435,12 @@ class float:
|
||||
...
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""float()
|
||||
float(x: Union[int, float, str])
|
||||
"""float(x=0.0)
|
||||
|
||||
Converts the argument to a floating point number.
|
||||
If no argument is given, this returns ``0.0``.
|
||||
Creates a floating point number from a given object.
|
||||
|
||||
Arguments:
|
||||
x: Number or string that will be converted.
|
||||
|
||||
Returns:
|
||||
The input argument ``x`` converted to a floating point number.
|
||||
x (int or float or str): Number or string to be converted.
|
||||
"""
|
||||
|
||||
|
||||
@@ -454,9 +496,18 @@ def help(*args) -> None:
|
||||
"""
|
||||
|
||||
|
||||
def hex(x: _int) -> _str:
|
||||
"""
|
||||
Converts an integer number to a lowercase hexadecimal string prefixed with “0x”.
|
||||
def hex(x: int) -> _str:
|
||||
"""hex(x) -> str
|
||||
|
||||
Converts an integer to its hexadecimal representation. The result is a
|
||||
lowercase string prefixed with ``0x``. The result is a valid Python
|
||||
expression. For example, ``hex(25)`` gives ``"0x19"``.
|
||||
|
||||
Arguments:
|
||||
x (int): Value to be converted.
|
||||
|
||||
Returns:
|
||||
A string representing the hexadecimal form of the input.
|
||||
"""
|
||||
|
||||
|
||||
@@ -478,13 +529,15 @@ def input(prompt: _str) -> _str:
|
||||
|
||||
|
||||
def input(*args) -> _str:
|
||||
"""
|
||||
Gets input from the user in the terminal window. This function waits until
|
||||
the user presses :kbd:`Enter`. The input is returned as a string.
|
||||
"""input() -> str
|
||||
input(prompt) -> str
|
||||
|
||||
Gets input from the user in the terminal window. It waits until
|
||||
the user presses :kbd:`Enter`.
|
||||
|
||||
Arguments:
|
||||
prompt: If given, this is printed in the terminal window first. This
|
||||
can be used to ask a question so the user knows what to type.
|
||||
prompt (str): If given, this is printed in the terminal window first.
|
||||
This can be used to ask a question so the user knows what to type.
|
||||
|
||||
Returns:
|
||||
Everything the user typed before pressing :kbd:`Enter`.
|
||||
@@ -509,36 +562,44 @@ class int:
|
||||
...
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""int()
|
||||
int(x: Union[int, float, str])
|
||||
"""int(x=0)
|
||||
|
||||
Converts the argument to an integer. If no argument is given, this
|
||||
returns ``0``.
|
||||
Creates an integer.
|
||||
|
||||
Arguments:
|
||||
x: Number or string that will be converted.
|
||||
|
||||
Returns:
|
||||
The input argument ``x`` converted to an integer.
|
||||
x (int or float or str): Object to be converted.
|
||||
"""
|
||||
|
||||
def to_bytes(self, length: _int, byteorder: Literal["little", "big"]) -> _bytes:
|
||||
"""
|
||||
Returns a :class:`bytes` object representing the integer.
|
||||
to_bytes(length, byteorder) -> bytes
|
||||
|
||||
Get a :class:`bytes` representation of the integer.
|
||||
|
||||
Arguments:
|
||||
length: How many bytes to use.
|
||||
byteorder: Choose ``"little"`` for little-endian encoding
|
||||
or ``"big"`` for big-endian encoding.
|
||||
length (int): How many bytes to use.
|
||||
byteorder (str): Choose ``"big"`` to put the most significant byte
|
||||
first. Choose ``"little"`` to put the least significant byte
|
||||
first.
|
||||
|
||||
Returns:
|
||||
The integer represented by a sequence of bytes.
|
||||
Byte sequence that represents the integer.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@_classmethod
|
||||
def from_bytes(cls, _bytes: _bytes, byteorder: Literal["little", "big"]) -> _int:
|
||||
"""
|
||||
Returns the integer represented by the given array of bytes.
|
||||
"""from_bytes(bytes, byteorder) -> int
|
||||
|
||||
Convert a byte sequence to the number it represents.
|
||||
|
||||
Arguments:
|
||||
bytes (bytes): The bytes to convert.
|
||||
byteorder (str): Choose ``"big"`` if the most significant byte is
|
||||
the first element. Choose ``"little"`` if the least significant
|
||||
byte is the first element.
|
||||
|
||||
Returns:
|
||||
The number represented by the bytes.
|
||||
"""
|
||||
|
||||
|
||||
@@ -653,8 +714,17 @@ class object:
|
||||
|
||||
|
||||
def oct(x: _int) -> _str:
|
||||
"""
|
||||
Converts an integer number to an octal string prefixed with “0o”.
|
||||
"""oct(x) -> str
|
||||
|
||||
Converts an integer to its octal representation. The result is a
|
||||
string prefixed with ``0o``. The result is a valid Python
|
||||
expression. For example, ``oct(25)`` gives ``"0o31"``.
|
||||
|
||||
Arguments:
|
||||
x (int): Value to be converted.
|
||||
|
||||
Returns:
|
||||
A string representing the octal form of the input.
|
||||
"""
|
||||
|
||||
|
||||
@@ -662,11 +732,16 @@ def oct(x: _int) -> _str:
|
||||
|
||||
|
||||
def ord(c: _str) -> _int:
|
||||
"""
|
||||
Given a string representing one Unicode character, return an integer
|
||||
representing the Unicode code point of that character.
|
||||
"""ord(c) -> int
|
||||
|
||||
This is the inverse of :meth:`chr`.
|
||||
Converts a string consisting of one Unicode character to the
|
||||
corresponding number. This is the inverse of :meth:`chr`.
|
||||
|
||||
Arguments:
|
||||
c (str): Character to be converted.
|
||||
|
||||
Returns:
|
||||
Number that represents the character (0--255).
|
||||
"""
|
||||
|
||||
|
||||
@@ -701,20 +776,19 @@ def print(*objects, sep: _str = " ", end: _str = "\n", file: uio.FileIO = usys.s
|
||||
|
||||
|
||||
def print(*args):
|
||||
"""
|
||||
"""print(*objects, sep=" ", end="\\n", file=usys.stdin)
|
||||
|
||||
Prints text or other objects in the terminal window.
|
||||
|
||||
Arguments:
|
||||
args: One or more objects to print.
|
||||
objects: Zero or more objects to print.
|
||||
|
||||
Keyword Arguments:
|
||||
sep: This is printed between objects, if there is more than one.
|
||||
end: This is printed after the last object.
|
||||
file: By default, the result is printed in the terminal window. This
|
||||
argument lets you print it to a file instead. This argument is
|
||||
not supported on the BOOST Move hub.
|
||||
|
||||
|
||||
argument lets you print it to a file instead, if files are
|
||||
supported.
|
||||
"""
|
||||
|
||||
|
||||
@@ -737,9 +811,16 @@ class range:
|
||||
"""
|
||||
|
||||
|
||||
def repr(object: Any) -> _str:
|
||||
"""
|
||||
Returns a string containing a printable representation of an object.
|
||||
def repr(x: Any) -> _str:
|
||||
"""repr(object) -> str
|
||||
|
||||
Gets the string that represents an object.
|
||||
|
||||
Arguments:
|
||||
x (object): Object to be converted.
|
||||
|
||||
Returns:
|
||||
String representation implemented by the object's ``__repr__`` method.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
+115
-81
@@ -11,7 +11,7 @@
|
||||
Math functions.
|
||||
"""
|
||||
|
||||
from typing import Tuple as _Tuple
|
||||
from typing import Tuple as Tuple
|
||||
|
||||
|
||||
e = 2.718282
|
||||
@@ -23,305 +23,339 @@ pi = 3.141593
|
||||
|
||||
|
||||
def sin(x: float) -> float:
|
||||
"""Gets the sine of the given angle ``x``.
|
||||
"""sin(x) -> float
|
||||
|
||||
Gets the sine of an angle.
|
||||
|
||||
Arguments:
|
||||
x: Angle in radians.
|
||||
x (float): Angle in radians.
|
||||
|
||||
Returns:
|
||||
Sine of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def asin(x: float) -> float:
|
||||
"""Applies the inverse sine operation on ``x``.
|
||||
"""asin(x) -> float
|
||||
|
||||
Applies the inverse sine operation.
|
||||
|
||||
Arguments:
|
||||
x: Opposite / hypotenuse.
|
||||
x (float): Opposite / hypotenuse.
|
||||
|
||||
Returns:
|
||||
Arcsine of ``x``, in radians.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cos(x: float) -> float:
|
||||
"""Gets the cosine of the given angle ``x``.
|
||||
"""cos(x) -> float
|
||||
|
||||
Gets the cosine of an angle.
|
||||
|
||||
Arguments:
|
||||
x: Angle in radians.
|
||||
x (float): Angle in radians.
|
||||
|
||||
Returns:
|
||||
Cosine of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def acos(x: float) -> float:
|
||||
"""Applies the inverse cosine operation on ``x``.
|
||||
"""acos(x) -> float
|
||||
|
||||
Applies the inverse cosine operation.
|
||||
|
||||
Arguments:
|
||||
x: Adjacent / hypotenuse.
|
||||
x (float): Adjacent / hypotenuse.
|
||||
|
||||
Returns:
|
||||
Arccosine of ``x``, in radians.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def tan(x: float) -> float:
|
||||
"""Gets the tangent of the given angle ``x``.
|
||||
"""tan(x) -> float
|
||||
|
||||
Gets the tangent of an angle.
|
||||
|
||||
Arguments:
|
||||
x: Angle in radians.
|
||||
x (float): Angle in radians.
|
||||
|
||||
Returns:
|
||||
Tangent of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def atan(x: float) -> float:
|
||||
"""Applies the inverse tangent operation on ``x``.
|
||||
"""atan(x) -> float
|
||||
|
||||
Applies the inverse tangent operation.
|
||||
|
||||
Arguments:
|
||||
x: Opposite / adjacent.
|
||||
x (float): Opposite / adjacent.
|
||||
|
||||
Returns:
|
||||
Arctangent of ``x``, in radians.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def atan2(b: float, a: float) -> float:
|
||||
"""Applies the inverse tangent operation on ``b / a``, and accounts for
|
||||
"""atan2(b, a) -> float
|
||||
|
||||
Applies the inverse tangent operation on ``b / a``, and accounts for
|
||||
the signs of ``b`` and ``a`` to produce the expected angle.
|
||||
|
||||
Arguments:
|
||||
b: Opposite side of the triangle.
|
||||
a: Adjacent side of the triangle.
|
||||
b (float): Opposite side of the triangle.
|
||||
a (float): Adjacent side of the triangle.
|
||||
|
||||
Returns:
|
||||
Arctangent of ``b / a``, in radians.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def degrees(x: float) -> float:
|
||||
"""Converts an angle ``x`` from radians to degrees.
|
||||
"""degrees(x) -> float
|
||||
|
||||
Converts an angle from radians to degrees.
|
||||
|
||||
Arguments:
|
||||
x: Angle in radians.
|
||||
x (float): Angle in radians.
|
||||
|
||||
Returns:
|
||||
Angle in degrees.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def radians(x: float) -> float:
|
||||
"""Converts an angle ``x`` from degrees to radians.
|
||||
"""radians(x) -> float
|
||||
|
||||
Converts an angle from degrees to radians.
|
||||
|
||||
Arguments:
|
||||
x: Angle in degrees.
|
||||
x (float): Angle in degrees.
|
||||
|
||||
Returns:
|
||||
Angle in radians.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def pow(x: float, y: float) -> float:
|
||||
"""Gets ``x`` raised to the power of ``y``.
|
||||
"""pow(x, y) -> float
|
||||
|
||||
Gets ``x`` raised to the power of ``y``.
|
||||
|
||||
Arguments:
|
||||
x: The base number.
|
||||
y: The exponent.
|
||||
x (float): The base number.
|
||||
y (float): The exponent.
|
||||
|
||||
Returns:
|
||||
``x`` raised to the power of ``y``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def exp(x: float) -> float:
|
||||
"""Gets :attr:`e` raised to the power of ``x``.
|
||||
"""exp(x) -> float
|
||||
|
||||
Gets :attr:`e` raised to the power of ``x``.
|
||||
|
||||
Arguments:
|
||||
x: The exponent.
|
||||
x (float): The exponent.
|
||||
|
||||
Returns:
|
||||
:attr:`e` raised to the power of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def log(x: float) -> float:
|
||||
"""Gets the natural logarithm of ``x``.
|
||||
"""log(x) -> float
|
||||
|
||||
Gets the natural logarithm.
|
||||
|
||||
Arguments:
|
||||
x: The value ``x``.
|
||||
x (float): The value.
|
||||
|
||||
Returns:
|
||||
The natural logarithm of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def sqrt(x: float) -> float:
|
||||
"""Gets the square root of ``x``.
|
||||
"""sqrt(x) -> float
|
||||
|
||||
Gets the square root.
|
||||
|
||||
Arguments:
|
||||
x: The value ``x``.
|
||||
x (float): The value ``x``.
|
||||
|
||||
Returns:
|
||||
The square root of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def ceil(x: float) -> int:
|
||||
"""Rounds up.
|
||||
"""ceil(x) -> int
|
||||
|
||||
Rounds up.
|
||||
|
||||
Arguments:
|
||||
x: The value ``x``.
|
||||
x (float): The value to be rounded.
|
||||
|
||||
Returns:
|
||||
Value rounded towards positive infinity.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def floor(x: float) -> int:
|
||||
"""Rounds down.
|
||||
"""floor(x) -> int
|
||||
|
||||
Rounds down.
|
||||
|
||||
Arguments:
|
||||
x: The value ``x``.
|
||||
x (float): The value to be rounded.
|
||||
|
||||
Returns:
|
||||
Value rounded towards negative infinity.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def trunc(x: float) -> int:
|
||||
"""Truncates decimals to get the integer part of a value.
|
||||
"""trunc(x) -> int
|
||||
|
||||
Truncates decimals to get the integer part of a value.
|
||||
|
||||
This is the same as rounding towards ``0``.
|
||||
|
||||
Arguments:
|
||||
x: The value ``x``.
|
||||
x (float): The value to be truncated.
|
||||
|
||||
Returns:
|
||||
Integer part of the value.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def fmod(x: float, y: float) -> float:
|
||||
"""Gets the remainder of ``x / y``.
|
||||
"""fmod(x, y) -> float
|
||||
|
||||
Gets the remainder of ``x / y``.
|
||||
|
||||
Not to be confused with :func:`modf`.
|
||||
|
||||
Arguments:
|
||||
x: The numerator.
|
||||
y: The denominator.
|
||||
x (float): The numerator.
|
||||
y (float): The denominator.
|
||||
|
||||
Returns:
|
||||
Remainder after division
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def fabs(x: float) -> float:
|
||||
"""Gets the absolute value of ``x``.
|
||||
"""fabs(x) -> float
|
||||
|
||||
Gets the absolute value.
|
||||
|
||||
Arguments:
|
||||
x: The value.
|
||||
x (float): The value.
|
||||
|
||||
Returns:
|
||||
Absolute value.
|
||||
Absolute value of ``x``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def modf(x: float) -> _Tuple[float, float]:
|
||||
"""Gets the fractional and integral parts of ``x``, both with the same sign
|
||||
def modf(x: float) -> Tuple[float, float]:
|
||||
"""modf(x) -> Tuple[float, float]
|
||||
|
||||
Gets the fractional and integral parts of ``x``, both with the same sign
|
||||
as ``x``.
|
||||
|
||||
Not to be confused with :func:`fmod`.
|
||||
|
||||
Arguments:
|
||||
x: The value to be decomposed.
|
||||
x (float): The value to be decomposed.
|
||||
|
||||
Returns:
|
||||
Tuple of fractional and integral parts.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def frexp(x: float) -> _Tuple[float, int]:
|
||||
"""Decomposes a value ``x`` into a
|
||||
def frexp(x: float) -> Tuple[float, int]:
|
||||
"""frexp(x) -> Tuple[float, float]
|
||||
|
||||
Decomposes a value ``x`` into a
|
||||
tuple ``(m, p)``, such that ``x == m * (2 ** p)``.
|
||||
|
||||
Arguments:
|
||||
x: The value to be decomposed.
|
||||
x (float): The value to be decomposed.
|
||||
|
||||
Returns:
|
||||
Tuple of ``m`` and ``p``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def ldexp(m: float, p: int) -> float:
|
||||
"""Computes ``m * (2 ** p)``.
|
||||
"""ldexp(m, p) -> float
|
||||
|
||||
Computes ``m * (2 ** p)``.
|
||||
|
||||
Arguments:
|
||||
m: The value.
|
||||
p: The exponent.
|
||||
m (float): The value.
|
||||
p (float): The exponent.
|
||||
|
||||
Returns:
|
||||
Result of ``m * (2 ** p)``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def copysign(x: float, y: float) -> float:
|
||||
"""Gets ``x`` with the sign of ``y``.
|
||||
"""copysign(x, y) -> float
|
||||
|
||||
Gets ``x`` with the sign of ``y``.
|
||||
|
||||
Arguments:
|
||||
x: Determines the magnitude of the return value.
|
||||
y: Determines the sign of the return value.
|
||||
x (float): Determines the magnitude of the return value.
|
||||
y (float): Determines the sign of the return value.
|
||||
|
||||
Returns:
|
||||
``x`` with the sign of ``y``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def isfinite(x: float) -> bool:
|
||||
"""Checks if ``x`` is finite.
|
||||
"""isfinite(x) -> bool
|
||||
|
||||
Checks if a value is finite.
|
||||
|
||||
Arguments:
|
||||
x (float): The value to be checked.
|
||||
|
||||
Returns:
|
||||
``True`` if ``x`` is finite, else ``False``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def isinfinite(x: float) -> bool:
|
||||
"""Checks if ``x`` is infinite.
|
||||
"""isinfinite(x) -> bool
|
||||
|
||||
Checks if a value is infinite.
|
||||
|
||||
Arguments:
|
||||
x (float): The value to be checked.
|
||||
|
||||
Returns:
|
||||
``True`` if ``x`` is infinite, else ``False``.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def isnan(x: float) -> bool:
|
||||
"""Checks if ``x`` is not-a-number.
|
||||
"""isnan(x) -> bool
|
||||
|
||||
Checks if a value is not-a-number.
|
||||
|
||||
Arguments:
|
||||
x (float): The value to be checked.
|
||||
|
||||
Returns:
|
||||
``True`` if ``x`` is not-a-number, else ``False``.
|
||||
"""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user