mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f19fe210a | ||
|
|
463b608817 | ||
|
|
49ce1d7829 | ||
|
|
15600c8a2b | ||
|
|
f509178dab | ||
|
|
fd61866f2b | ||
|
|
91bc9a5d60 | ||
|
|
f470f1c510 | ||
|
|
d7f9723f6f | ||
|
|
0d0d479a86 | ||
|
|
252adb3e85 | ||
|
|
36ed5917e9 | ||
|
|
bec6aaa76e | ||
|
|
e7377dff31 | ||
|
|
d935841399 | ||
|
|
3335042218 | ||
|
|
209fba5c7e | ||
|
|
faf11581c0 | ||
|
|
8819446513 | ||
|
|
b97eef8152 | ||
|
|
6bbdccb25f | ||
|
|
578abab24e | ||
|
|
1a49d396d2 | ||
|
|
397663d631 | ||
|
|
821a3e4455 | ||
|
|
41b9ce71dd | ||
|
|
6d69f04fe5 | ||
|
|
00ded2e2a0 | ||
|
|
dd1d167ad9 | ||
|
|
4dc289ad61 | ||
|
|
bc592b4469 | ||
|
|
784c7ec5fc | ||
|
|
9e2bac457a | ||
|
|
61d18ebe6f | ||
|
|
ff0b767e3e | ||
|
|
3274cef849 | ||
|
|
b4ff3af36d | ||
|
|
8e5891d9e8 | ||
|
|
7de67852f7 | ||
|
|
31d3a117d6 | ||
|
|
263fe3a1cb | ||
|
|
db8de447d5 | ||
|
|
46d6189eb1 |
@@ -6,7 +6,7 @@ name: Build Python package and docs
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- "@pybricks/*"
|
||||
- '**'
|
||||
pull_request:
|
||||
paths:
|
||||
- doc/**
|
||||
@@ -20,19 +20,11 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9]
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install poetry
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
pip install poetry
|
||||
poetry run python -m pip install --upgrade pip
|
||||
poetry run python -m pip install --upgrade setuptools
|
||||
poetry install
|
||||
poetry install --only=doc
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '14.x'
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# .readthedocs.yaml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
#
|
||||
# Settings in the readthedocs online dashboard will be ignored.
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Build documentation in the doc/main directory with Sphinx
|
||||
sphinx:
|
||||
configuration: doc/main/conf.py
|
||||
|
||||
# Build your docs in additional formats such as PDF
|
||||
formats:
|
||||
- pdf
|
||||
|
||||
# Set the version of Python and requirements required to build the docs
|
||||
python:
|
||||
version: 3.8
|
||||
install:
|
||||
- requirements: rtd-requirements.txt
|
||||
@@ -0,0 +1,25 @@
|
||||
# .readthedocs.yaml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
build:
|
||||
os: "ubuntu-22.04"
|
||||
tools:
|
||||
python: "3.10"
|
||||
jobs:
|
||||
post_create_environment:
|
||||
- pip install poetry
|
||||
- poetry config virtualenvs.create false
|
||||
post_install:
|
||||
- poetry install --only=doc
|
||||
|
||||
# Build documentation in the doc/main/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: doc/main/conf.py
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF
|
||||
formats:
|
||||
- pdf
|
||||
Vendored
+2
-1
@@ -4,7 +4,8 @@
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"ms-python.python"
|
||||
"ms-python.python",
|
||||
"ms-python.black-formatter"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": [
|
||||
|
||||
Vendored
+2
-2
@@ -4,14 +4,14 @@
|
||||
},
|
||||
"python.defaultInterpreterPath": ".venv/bin/python",
|
||||
"python.autoComplete.extraPaths": ["jedi/src"],
|
||||
"python.formatting.provider": "black",
|
||||
"python.formatting.provider": "none",
|
||||
"python.linting.pylintEnabled": false,
|
||||
"python.linting.flake8Enabled": true,
|
||||
"python.linting.pycodestyleEnabled": false,
|
||||
"python.linting.enabled": true,
|
||||
"[python]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "ms-python.python"
|
||||
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||
},
|
||||
"python.languageServer": "Pylance",
|
||||
"python.testing.pytestArgs": [
|
||||
|
||||
@@ -4,6 +4,32 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 3.3.0c1 - 2023-11-20
|
||||
|
||||
## Added
|
||||
- Enabled tilt and orientation config for `MoveHub()`.
|
||||
- Documented `Motor.close()`
|
||||
|
||||
## Fixed
|
||||
- Fixed missing awaitable for `Remote.light` and LWP3 writes.
|
||||
|
||||
## 3.3.0b9 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Changed the beta feature for using the hub's gyro. Gyro control can now be
|
||||
toggled using `use_gyro` instead of using a separate `GyroDriveBase` class.
|
||||
- Documentation updates to match firmware 3.3.0b5--3.3.0b9 updates.
|
||||
|
||||
## Added
|
||||
- Added `set` to `ubuiltins` module.
|
||||
- Basic multitasking docs.
|
||||
- Awaitable keyword for awaitable methods and functions.
|
||||
|
||||
## 3.3.0b5 - 2023-05-16
|
||||
|
||||
### Added
|
||||
- Documented new `hub.ble` methods.
|
||||
|
||||
## 3.3.0b4 - 2023-04-21
|
||||
|
||||
### Added
|
||||
|
||||
+14
-13
@@ -145,13 +145,10 @@ add_module_names = False # Hide module name
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
if ON_RTD:
|
||||
html_theme = "default"
|
||||
else:
|
||||
import sphinx_rtd_theme
|
||||
import sphinx_rtd_theme
|
||||
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
html_context = {
|
||||
"disclaimer": _DISCLAIMER,
|
||||
@@ -321,10 +318,11 @@ def on_missing_reference(
|
||||
app.builder, node["refdoc"], "signaltypes", "numbers", contnode
|
||||
)
|
||||
|
||||
# References with special characters can't exist, so we have to supress
|
||||
# References with special characters can't exist, so we have to suppress
|
||||
# warnings when Sphinx tries to cross reference units like deg/s. For
|
||||
# consistency, we also treat units without special characters this way.
|
||||
for unit in [
|
||||
"dBm",
|
||||
"deg",
|
||||
"deg/s",
|
||||
"deg/s²",
|
||||
@@ -342,13 +340,16 @@ def on_missing_reference(
|
||||
"Ω",
|
||||
"N",
|
||||
]:
|
||||
try:
|
||||
# If they match on raw source, we are dealing with argument types.
|
||||
if unit == contnode.rawsource:
|
||||
# Return as-is to suppress missing cross reference warning. We
|
||||
# could make this more fancy by returning an xref node that links
|
||||
# to the signals page.
|
||||
return contnode
|
||||
|
||||
# If they match on raw source, we are dealing with argument types.
|
||||
if unit == contnode.rawsource:
|
||||
# Return as-is to suppress missing cross reference warning. We
|
||||
# could make this more fancy by returning an xref node that links
|
||||
# to the signals page.
|
||||
return contnode
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# Return types are denoted as "int: deg"
|
||||
try:
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ import sys
|
||||
|
||||
# General information about the project.
|
||||
project = "pybricks"
|
||||
copyright = "2018-2021 The Pybricks Authors"
|
||||
copyright = "2018-2023 The Pybricks Authors"
|
||||
author = ""
|
||||
|
||||
_TITLE = "Pybricks Modules and Examples"
|
||||
@@ -29,7 +29,7 @@ if os.environ.get("READTHEDOCS", None) == "True":
|
||||
# HACK: this allows Number type alias to be imported by Sphinx
|
||||
os.environ["SPHINX_BUILD"] = "True"
|
||||
|
||||
# Addtional configuration of the IDE docs
|
||||
# Additional configuration of the IDE docs
|
||||
if "ide" in tags.tags: # noqa F821
|
||||
_DISCLAIMER = ""
|
||||
html_show_copyright = False
|
||||
@@ -45,7 +45,7 @@ if "ide" in tags.tags: # noqa F821
|
||||
|
||||
exec(open(os.path.abspath("../common/conf.py")).read())
|
||||
|
||||
# Addtional configuration of the IDE docs
|
||||
# Additional configuration of the IDE docs
|
||||
if "ide" in tags.tags: # noqa F821
|
||||
|
||||
extensions.remove("sphinx.ext.mathjax") # noqa F821
|
||||
|
||||
@@ -19,6 +19,16 @@ City Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::CityHub.light.animate
|
||||
|
||||
.. rubric:: Using connectionless Bluetooth messaging
|
||||
|
||||
.. automethod:: pybricks.hubs::CityHub.ble.broadcast
|
||||
|
||||
.. automethod:: pybricks.hubs::CityHub.ble.observe
|
||||
|
||||
.. automethod:: pybricks.hubs::CityHub.ble.signal_strength
|
||||
|
||||
.. automethod:: pybricks.hubs::CityHub.ble.version
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::CityHub.battery.voltage
|
||||
@@ -70,6 +80,23 @@ Creating light animations
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/light_animate_cityhub.py
|
||||
|
||||
|
||||
Bluetooth examples
|
||||
------------------
|
||||
|
||||
Broadcasting data to other hubs
|
||||
*******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_broadcast_cityhub.py
|
||||
|
||||
Observing data from other hubs
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_observe_cityhub.py
|
||||
|
||||
|
||||
Button and system examples
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -47,6 +47,16 @@ Essential Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.imu.settings
|
||||
|
||||
.. rubric:: Using connectionless Bluetooth messaging
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.ble.broadcast
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.ble.observe
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.ble.signal_strength
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.ble.version
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::EssentialHub.battery.voltage
|
||||
@@ -136,6 +146,23 @@ Reading acceleration and angular velocity on one axis
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_read_scalar_essentialhub.py
|
||||
|
||||
|
||||
Bluetooth examples
|
||||
------------------
|
||||
|
||||
Broadcasting data to other hubs
|
||||
*******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_broadcast_essentialhub.py
|
||||
|
||||
Observing data from other hubs
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_observe_essentialhub.py
|
||||
|
||||
|
||||
System examples
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -25,12 +25,24 @@ Move Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.imu.up
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.tilt
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.imu.acceleration
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
|
||||
Changed acceleration units from m/s² to mm/s².
|
||||
|
||||
.. rubric:: Using connectionless Bluetooth messaging
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.ble.broadcast
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.ble.observe
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.ble.signal_strength
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.ble.version
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::MoveHub.battery.voltage
|
||||
@@ -85,6 +97,23 @@ Reading acceleration
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_movehub/imu_read_acceleration.py
|
||||
|
||||
|
||||
Bluetooth examples
|
||||
------------------
|
||||
|
||||
Broadcasting data to other hubs
|
||||
*******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_broadcast_movehub.py
|
||||
|
||||
Observing data from other hubs
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_observe_movehub.py
|
||||
|
||||
|
||||
Button and system examples
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -89,6 +89,16 @@ Prime Hub / Inventor Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.speaker.play_notes
|
||||
|
||||
.. rubric:: Using connectionless Bluetooth messaging
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.ble.broadcast
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.ble.observe
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.ble.signal_strength
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.ble.version
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.battery.voltage
|
||||
@@ -247,6 +257,23 @@ Reading acceleration and angular velocity on one axis
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_read_scalar_primehub.py
|
||||
|
||||
|
||||
Bluetooth examples
|
||||
------------------
|
||||
|
||||
Broadcasting data to other hubs
|
||||
*******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_broadcast_primehub.py
|
||||
|
||||
Observing data from other hubs
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_observe_primehub.py
|
||||
|
||||
|
||||
System examples
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -43,6 +43,16 @@ Technic Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.imu.settings
|
||||
|
||||
.. rubric:: Using connectionless Bluetooth messaging
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.ble.broadcast
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.ble.observe
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.ble.signal_strength
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.ble.version
|
||||
|
||||
.. rubric:: Using the battery
|
||||
|
||||
.. automethod:: pybricks.hubs::TechnicHub.battery.voltage
|
||||
@@ -128,6 +138,23 @@ Reading acceleration and angular velocity on one axis
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/imu_read_scalar_technichub.py
|
||||
|
||||
|
||||
Bluetooth examples
|
||||
------------------
|
||||
|
||||
Broadcasting data to other hubs
|
||||
*******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_broadcast_technichub.py
|
||||
|
||||
Observing data from other hubs
|
||||
******************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/hub_common/build/ble_observe_technichub.py
|
||||
|
||||
|
||||
Button and system examples
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -72,6 +72,10 @@ Sequences
|
||||
|
||||
.. pybricks-requirements:: stm32-extra
|
||||
|
||||
.. autoclass:: ubuiltins.set
|
||||
|
||||
.. pybricks-requirements:: stm32-extra
|
||||
|
||||
.. autoclass:: ubuiltins.slice
|
||||
|
||||
.. pybricks-requirements::
|
||||
|
||||
@@ -38,7 +38,7 @@ Powers and logarithms
|
||||
|
||||
.. autofunction:: umath.sqrt
|
||||
|
||||
Trigonomety
|
||||
Trigonometry
|
||||
-------------------------------
|
||||
|
||||
.. autodata:: umath.pi
|
||||
|
||||
@@ -5,3 +5,6 @@ Axis
|
||||
|
||||
.. autoclass:: pybricks.parameters.Axis
|
||||
:no-members:
|
||||
|
||||
On Move Hub, doing math with these vectors is not supported. The axes can still
|
||||
be used to set up the hub orientation.
|
||||
|
||||
@@ -62,6 +62,8 @@ Motors with rotation sensors
|
||||
|
||||
.. automethod:: pybricks.pupdevices.Motor.settings
|
||||
|
||||
.. automethod:: pybricks.pupdevices.Motor.close
|
||||
|
||||
.. rubric:: Control settings
|
||||
|
||||
.. pybricks-requirements:: pybricks-common-control
|
||||
|
||||
+29
-31
@@ -39,6 +39,8 @@
|
||||
|
||||
.. automethod:: pybricks.robotics.DriveBase.stop
|
||||
|
||||
.. automethod:: pybricks.robotics.DriveBase.brake
|
||||
|
||||
.. rubric:: Measuring
|
||||
|
||||
.. automethod:: pybricks.robotics.DriveBase.distance
|
||||
@@ -51,6 +53,33 @@
|
||||
|
||||
.. automethod:: pybricks.robotics.DriveBase.stalled
|
||||
|
||||
.. rubric:: Driving with the gyro
|
||||
|
||||
.. automethod:: pybricks.robotics.DriveBase.use_gyro
|
||||
|
||||
If your hub is not mounted flat in your robot, make sure to specify
|
||||
the ``top_side`` and ``front_side`` parameters when you initialize the
|
||||
:class:`PrimeHub() <pybricks.hubs.PrimeHub>`,
|
||||
:class:`InventorHub() <pybricks.hubs.PrimeHub>`,
|
||||
:class:`EssentialHub() <pybricks.hubs.EssentialHub>`, or
|
||||
:class:`TechnicHub() <pybricks.hubs.TechnicHub>`. This way your robot
|
||||
knows which rotation to measure when turning.
|
||||
|
||||
The gyro in each hub is a bit different, which can cause it to be a few
|
||||
degrees off for big turns, or many small turns in the same
|
||||
direction. For example, you may need to use
|
||||
:meth:`turn(357) <pybricks.robotics.DriveBase.turn>` or
|
||||
:meth:`turn(362) <pybricks.robotics.DriveBase.turn>`
|
||||
on your robot to make a full turn.
|
||||
|
||||
By default, this class tries to maintain the robot's position after a move
|
||||
completes. This means the wheels will spin if you pick the robot up, in an
|
||||
effort to maintain its heading angle. To avoid this, you can choose
|
||||
``then=Stop.COAST`` in your last
|
||||
:meth:`straight <pybricks.robotics.DriveBase.straight>`,
|
||||
:meth:`turn <pybricks.robotics.DriveBase.turn>`, or
|
||||
:meth:`curve <pybricks.robotics.DriveBase.curve>` command.
|
||||
|
||||
.. _measuring:
|
||||
|
||||
.. rubric:: Measuring and validating the robot dimensions
|
||||
@@ -115,34 +144,6 @@
|
||||
|
||||
.. pybricks-requirements:: gyro
|
||||
|
||||
.. class:: GyroDriveBase
|
||||
|
||||
This class works just like the :class:`DriveBase`, but it uses the hub's
|
||||
built-in gyroscope to drive straight and turn more accurately.
|
||||
|
||||
If your hub is not mounted flat in your robot, make sure to specify
|
||||
the ``top_side`` and ``front_side`` parameters when you initialize the
|
||||
:class:`PrimeHub() <pybricks.hubs.PrimeHub>`,
|
||||
:class:`InventorHub() <pybricks.hubs.PrimeHub>`,
|
||||
:class:`EssentialHub() <pybricks.hubs.EssentialHub>`, or
|
||||
:class:`TechnicHub() <pybricks.hubs.TechnicHub>`. This way your robot
|
||||
knows which rotation to measure when turning.
|
||||
|
||||
The gyro in each hub is a bit different, which can cause it to be a few
|
||||
degrees off for big turns, or many small turns in the same
|
||||
direction. For example, you may need to use
|
||||
:meth:`turn(357) <pybricks.robotics.DriveBase.turn>` or
|
||||
:meth:`turn(362) <pybricks.robotics.DriveBase.turn>`
|
||||
on your robot to make a full turn.
|
||||
|
||||
By default, this class tries to maintain the robot's position after a move
|
||||
completes. This means the wheels will spin if you pick the robot up, in an
|
||||
effort to maintain its heading angle. To avoid this, you can choose
|
||||
``then=Stop.COAST`` in your last
|
||||
:meth:`straight <pybricks.robotics.DriveBase.straight>`,
|
||||
:meth:`turn <pybricks.robotics.DriveBase.turn>`, or
|
||||
:meth:`curve <pybricks.robotics.DriveBase.curve>` command.
|
||||
|
||||
Examples
|
||||
-------------------
|
||||
|
||||
@@ -151,8 +152,5 @@ Driving straight and turning in place
|
||||
|
||||
The following program shows the basics of driving and turning.
|
||||
|
||||
To use the built-in gyro, just replace the two occurences of
|
||||
:class:`DriveBase` with :class:`GyroDriveBase`.
|
||||
|
||||
.. literalinclude::
|
||||
../../examples/pup/robotics/drivebase_basics.py
|
||||
|
||||
@@ -248,7 +248,7 @@ For example, you can choose the frequency of a beep to change the pitch.
|
||||
temperature: °C
|
||||
---------------
|
||||
|
||||
Temperature is measured in degrees Celcius (°C). To convert to degrees
|
||||
Temperature is measured in degrees Celsius (°C). To convert to degrees
|
||||
Fahrenheit (°F) or Kelvin (K), you can use the following conversion formulas:
|
||||
|
||||
:math:`^{\circ}\kern1pt\!F =\kern1pt^{\circ}\kern1pt\!C \cdot \frac{9}{5} + 32`.
|
||||
|
||||
@@ -22,6 +22,18 @@ Timing tools
|
||||
|
||||
.. automethod:: pybricks.tools.StopWatch.reset
|
||||
|
||||
Input tools
|
||||
-----------
|
||||
|
||||
.. autofunction:: pybricks.tools.read_input_byte
|
||||
|
||||
.. pybricks-requirements:: light-matrix
|
||||
|
||||
.. autofunction:: pybricks.tools.hub_menu
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/tools/hub_menu.py
|
||||
|
||||
Linear algebra tools
|
||||
--------------------
|
||||
|
||||
@@ -43,3 +55,35 @@ Linear algebra tools
|
||||
.. autofunction:: pybricks.tools.vector
|
||||
|
||||
.. autofunction:: pybricks.tools.cross
|
||||
|
||||
Multitasking
|
||||
--------------------
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
Pybricks supports cooperative multitasking using the ``async`` and ``await``
|
||||
keywords. This allows operations that normally take some time to complete to
|
||||
run in parallel with other operations.
|
||||
|
||||
.. autofunction:: pybricks.tools.multitask
|
||||
|
||||
.. autofunction:: pybricks.tools.run_task
|
||||
|
||||
The following example shows how to use multitasking to make a robot drive
|
||||
forward, then turn and move a gripper at the same time, and then drive
|
||||
backward.
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/robotics/drivebase_async.py
|
||||
|
||||
.. class:: coroutine
|
||||
|
||||
.. class:: await
|
||||
|
||||
Whenever you see a function or method prefixed by ``await``, this means that
|
||||
it supports multitasking. When running a coroutine with ``run_task``, all
|
||||
methods and functions prefixed by ``await`` will act as coroutines.
|
||||
|
||||
If you don't use multitasking, you can ignore the ``await`` keyword and write
|
||||
programs as usual. Specifically, when ``run_task`` is not used, functions
|
||||
prefixed by ``await`` will act as normal functions.
|
||||
|
||||
@@ -71,6 +71,7 @@ class ThreadingRFCOMMServer(ThreadingMixIn, RFCOMMServer):
|
||||
"""
|
||||
Version of :class:`RFCOMMServer` that handles connections in a new thread.
|
||||
"""
|
||||
|
||||
daemon_threads = True
|
||||
|
||||
|
||||
@@ -103,4 +104,5 @@ class ThreadingRFCOMMClient(ThreadingMixIn, RFCOMMClient):
|
||||
"""
|
||||
Version of :class:`RFCOMMClient` that handles connections in a new thread.
|
||||
"""
|
||||
|
||||
daemon_threads = True
|
||||
|
||||
@@ -261,7 +261,7 @@ class BluetoothMailboxServer(MailboxHandlerMixIn, ThreadingRFCOMMServer):
|
||||
EV3.
|
||||
|
||||
The remote EV3 can either be running MicroPython or the standard EV3
|
||||
firmare.
|
||||
firmware.
|
||||
"""
|
||||
super().__init__()
|
||||
super(ThreadingRFCOMMServer, self).__init__(
|
||||
@@ -304,7 +304,7 @@ class BluetoothMailboxClient(MailboxHandlerMixIn):
|
||||
remote EV3s.
|
||||
|
||||
The remote EV3s can either be running MicroPython or the standard EV3
|
||||
firmare.
|
||||
firmware.
|
||||
"""
|
||||
|
||||
def __enter__(self):
|
||||
|
||||
@@ -36,7 +36,7 @@ def scale(val, src, dst):
|
||||
|
||||
|
||||
# Create a loop to react to events
|
||||
# This loop reacte to all main PS4 button and stick events. I have left out
|
||||
# This loop reacts to all main PS4 button and stick events. I have left out
|
||||
# buttons like share and options, but can easily be added in by referring
|
||||
# to the table at: https://github.com/codeadamca/python-connect-ps4
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.pupdevices import Motor
|
||||
from pybricks.parameters import Port
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ThisHub(broadcast_channel=1)
|
||||
|
||||
# Initialize the motors.
|
||||
left_motor = Motor(Port.A)
|
||||
right_motor = Motor(Port.B)
|
||||
|
||||
while True:
|
||||
# Read the motor angles to be sent to the other hub.
|
||||
left_angle = left_motor.angle()
|
||||
right_angle = right_motor.angle()
|
||||
|
||||
# Set the broadcast data and start broadcasting if not already doing so.
|
||||
data = (left_angle, right_angle)
|
||||
hub.ble.broadcast(data)
|
||||
|
||||
# Broadcasts are only sent every 100 milliseconds, so there is no reason
|
||||
# to call the broadcast() method more often than that.
|
||||
wait(100)
|
||||
@@ -0,0 +1,38 @@
|
||||
# ThisHub = MoveHub CityHub TechnicHub PrimeHub EssentialHub
|
||||
from pybricks.hubs import ThisHub
|
||||
from pybricks.pupdevices import Motor
|
||||
from pybricks.parameters import Color, Port
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the hub.
|
||||
hub = ThisHub(observe_channels=[1])
|
||||
|
||||
# Initialize the motors.
|
||||
left_motor = Motor(Port.A)
|
||||
right_motor = Motor(Port.B)
|
||||
|
||||
while True:
|
||||
# Receive broadcast from the other hub.
|
||||
|
||||
data = hub.ble.observe(1)
|
||||
|
||||
if data is None:
|
||||
# No data has been received in the last 1 second.
|
||||
hub.light.on(Color.RED)
|
||||
else:
|
||||
# Data was received and is less that one second old.
|
||||
hub.light.on(Color.GREEN)
|
||||
|
||||
# *data* contains the same values in the same order
|
||||
# that were passed to hub.ble.broadcast() on the
|
||||
# other hub.
|
||||
left_angle, right_angle = data
|
||||
|
||||
# Make the motors on this hub mirror the position of the
|
||||
# motors on the other hub.
|
||||
left_motor.track_target(left_angle)
|
||||
right_motor.track_target(right_angle)
|
||||
|
||||
# Broadcasts are only sent every 100 milliseconds, so there is
|
||||
# no reason to call the observe() method more often than that.
|
||||
wait(100)
|
||||
@@ -0,0 +1,27 @@
|
||||
from pybricks.pupdevices import Motor
|
||||
from pybricks.parameters import Direction, Port
|
||||
from pybricks.robotics import DriveBase
|
||||
from pybricks.tools import multitask, run_task
|
||||
|
||||
# Set up all devices.
|
||||
left = Motor(Port.A, Direction.COUNTERCLOCKWISE)
|
||||
right = Motor(Port.B)
|
||||
gripper = Motor(Port.C)
|
||||
drive_base = DriveBase(left, right, 56, 114)
|
||||
|
||||
|
||||
# Move the gripper up and down.
|
||||
async def move_gripper():
|
||||
await gripper.run_angle(500, -90)
|
||||
await gripper.run_angle(500, 90)
|
||||
|
||||
|
||||
# Drive forward, turn move gripper at the same time, and drive backward.
|
||||
async def main():
|
||||
await drive_base.straight(250)
|
||||
await multitask(drive_base.turn(90), move_gripper())
|
||||
await drive_base.straight(-250)
|
||||
|
||||
|
||||
# Runs the main program from start to finish.
|
||||
run_task(main())
|
||||
@@ -11,6 +11,9 @@ right_motor = Motor(Port.B)
|
||||
# The distance between the two wheel-ground contact points is 112mm.
|
||||
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112)
|
||||
|
||||
# Optionally, uncomment the line below to use the gyro for improved accuracy.
|
||||
# drive_base.use_gyro(True)
|
||||
|
||||
# Drive forward by 500mm (half a meter).
|
||||
drive_base.straight(500)
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from pybricks.tools import hub_menu
|
||||
|
||||
# This example assumes that you have three other programs in Pybricks Code,
|
||||
# called "fly_mission", "drive_mission", and "zigzag". This example creates a
|
||||
# menu that lets you pick which one to run.
|
||||
|
||||
# Choose a letter.
|
||||
selected = hub_menu("F", "D", "Z")
|
||||
|
||||
# Based on the selection, run a program.
|
||||
if selected == "F":
|
||||
import fly_mission
|
||||
elif selected == "D":
|
||||
import drive_mission
|
||||
elif selected == "Z":
|
||||
import zigzag
|
||||
@@ -4,6 +4,26 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 1.11.0 - 2023-11-20
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks` package to v3.3.0c1.
|
||||
|
||||
## 1.10.0 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks` package to v3.3.0b9.
|
||||
|
||||
## 1.9.0 - 2023-05-16
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks` package to v3.3.0b5.
|
||||
|
||||
## 1.8.0 - 2023-04-21
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks` package to v3.3.0b4.
|
||||
|
||||
## 1.7.0 - 2022-12-28
|
||||
|
||||
### Added
|
||||
|
||||
Generated
+114
-160
@@ -1,24 +1,26 @@
|
||||
[[package]]
|
||||
name = "attrs"
|
||||
version = "22.1.0"
|
||||
description = "Classes Without Boilerplate"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"]
|
||||
docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"]
|
||||
tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"]
|
||||
tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
|
||||
# This file is automatically @generated by Poetry and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "black"
|
||||
version = "22.10.0"
|
||||
version = "22.12.0"
|
||||
description = "The uncompromising code formatter."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"},
|
||||
{file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"},
|
||||
{file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"},
|
||||
{file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"},
|
||||
{file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"},
|
||||
{file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"},
|
||||
{file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"},
|
||||
{file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"},
|
||||
{file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"},
|
||||
{file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"},
|
||||
{file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"},
|
||||
{file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
click = ">=8.0.0"
|
||||
@@ -35,11 +37,15 @@ uvloop = ["uvloop (>=0.15.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "click"
|
||||
version = "8.1.3"
|
||||
version = "8.1.7"
|
||||
description = "Composable command line interface toolkit"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
|
||||
{file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
||||
@@ -51,6 +57,10 @@ description = "Cross-platform colored terminal text."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||
files = [
|
||||
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
||||
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "docstring-parser"
|
||||
@@ -59,14 +69,22 @@ description = "Parse Python docstrings in reST, Google and Numpydoc format"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6,<4.0"
|
||||
files = [
|
||||
{file = "docstring_parser-0.14.1-py3-none-any.whl", hash = "sha256:14ac6ec1f1ba6905c4d8cb90fd0bc55394f5678183752c90e44812bf28d7a515"},
|
||||
{file = "docstring_parser-0.14.1.tar.gz", hash = "sha256:2c77522e31b7c88b1ab457a1f3c9ae38947ad719732260ba77ee8a3deb58622a"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "exceptiongroup"
|
||||
version = "1.0.4"
|
||||
version = "1.1.3"
|
||||
description = "Backport of PEP 654 (exception groups)"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "exceptiongroup-1.1.3-py3-none-any.whl", hash = "sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3"},
|
||||
{file = "exceptiongroup-1.1.3.tar.gz", hash = "sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
test = ["pytest (>=6)"]
|
||||
@@ -78,6 +96,10 @@ description = "the modular source code checker: pep8 pyflakes and co"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
|
||||
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
mccabe = ">=0.6.0,<0.7.0"
|
||||
@@ -86,11 +108,15 @@ pyflakes = ">=2.4.0,<2.5.0"
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "1.1.1"
|
||||
description = "iniconfig: brain-dead simple config-ini parsing"
|
||||
version = "2.0.0"
|
||||
description = "brain-dead simple config-ini parsing"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"},
|
||||
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jedi"
|
||||
@@ -99,6 +125,10 @@ description = "An autocompletion tool for Python that can be used for text edito
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "jedi-0.18.1-py2.py3-none-any.whl", hash = "sha256:637c9635fcf47945ceb91cd7f320234a7be540ded6f3e99a50cb6febdfd1ba8d"},
|
||||
{file = "jedi-0.18.1.tar.gz", hash = "sha256:74137626a64a99c8eb6ae5832d99b3bdd7d29a3850fe2aa80a4126b2a7d949ab"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
parso = ">=0.8.0,<0.9.0"
|
||||
@@ -114,25 +144,34 @@ description = "McCabe checker, plugin for flake8"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
|
||||
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mypy-extensions"
|
||||
version = "0.4.3"
|
||||
description = "Experimental type system extensions for programs checked with the mypy typechecker."
|
||||
version = "1.0.0"
|
||||
description = "Type system extensions for programs checked with the mypy type checker."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
python-versions = ">=3.5"
|
||||
files = [
|
||||
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
|
||||
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "21.3"
|
||||
version = "23.2"
|
||||
description = "Core utilities for Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"},
|
||||
{file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parso"
|
||||
@@ -141,6 +180,10 @@ description = "A Python Parser"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "parso-0.8.3-py2.py3-none-any.whl", hash = "sha256:c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75"},
|
||||
{file = "parso-0.8.3.tar.gz", hash = "sha256:8c07be290bb59f03588915921e29e8a50002acaf2cdc5fa0e0114f91709fafa0"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
qa = ["flake8 (==3.8.3)", "mypy (==0.782)"]
|
||||
@@ -148,31 +191,43 @@ testing = ["docopt", "pytest (<6.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pathspec"
|
||||
version = "0.10.2"
|
||||
version = "0.11.2"
|
||||
description = "Utility library for gitignore style pattern matching of file paths."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"},
|
||||
{file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "2.5.4"
|
||||
version = "4.0.0"
|
||||
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "platformdirs-4.0.0-py3-none-any.whl", hash = "sha256:118c954d7e949b35437270383a3f2531e99dd93cf7ce4dc8340d3356d30f173b"},
|
||||
{file = "platformdirs-4.0.0.tar.gz", hash = "sha256:cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2022.9.29)", "proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-autodoc-typehints (>=1.19.4)"]
|
||||
test = ["appdirs (==1.4.4)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
|
||||
docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"]
|
||||
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"]
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.0.0"
|
||||
version = "1.3.0"
|
||||
description = "plugin and hook calling mechanisms for python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"},
|
||||
{file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
dev = ["pre-commit", "tox"]
|
||||
@@ -180,11 +235,12 @@ testing = ["pytest", "pytest-benchmark"]
|
||||
|
||||
[[package]]
|
||||
name = "pybricks"
|
||||
version = "3.2.0c1"
|
||||
version = "3.3.0c1"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "^3.8"
|
||||
files = []
|
||||
develop = true
|
||||
|
||||
[package.source]
|
||||
@@ -198,6 +254,10 @@ description = "Python style guide checker"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
files = [
|
||||
{file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"},
|
||||
{file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyflakes"
|
||||
@@ -206,28 +266,24 @@ description = "passive checker of Python programs"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
|
||||
[[package]]
|
||||
name = "pyparsing"
|
||||
version = "3.0.9"
|
||||
description = "pyparsing module - Classes and methods to define and execute parsing grammars"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6.8"
|
||||
|
||||
[package.extras]
|
||||
diagrams = ["jinja2", "railroad-diagrams"]
|
||||
files = [
|
||||
{file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"},
|
||||
{file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "7.2.0"
|
||||
version = "7.4.3"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"},
|
||||
{file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
attrs = ">=19.2.0"
|
||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
|
||||
iniconfig = "*"
|
||||
@@ -236,7 +292,7 @@ pluggy = ">=0.12,<2.0"
|
||||
tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
|
||||
|
||||
[package.extras]
|
||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
|
||||
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
@@ -245,6 +301,10 @@ description = "A lil' TOML parser"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
@@ -253,118 +313,12 @@ description = "Backported and Experimental Type Hints for Python 3.7+"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">= 3.10, < 3.11"
|
||||
content-hash = "971c6d0dddd9bb8e33a942e2360905a7d80a1a9d33015c0defc08345df5c1019"
|
||||
|
||||
[metadata.files]
|
||||
attrs = [
|
||||
{file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"},
|
||||
{file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"},
|
||||
]
|
||||
black = [
|
||||
{file = "black-22.10.0-1fixedarch-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:5cc42ca67989e9c3cf859e84c2bf014f6633db63d1cbdf8fdb666dcd9e77e3fa"},
|
||||
{file = "black-22.10.0-1fixedarch-cp311-cp311-macosx_11_0_x86_64.whl", hash = "sha256:5d8f74030e67087b219b032aa33a919fae8806d49c867846bfacde57f43972ef"},
|
||||
{file = "black-22.10.0-1fixedarch-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:197df8509263b0b8614e1df1756b1dd41be6738eed2ba9e9769f3880c2b9d7b6"},
|
||||
{file = "black-22.10.0-1fixedarch-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:2644b5d63633702bc2c5f3754b1b475378fbbfb481f62319388235d0cd104c2d"},
|
||||
{file = "black-22.10.0-1fixedarch-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:e41a86c6c650bcecc6633ee3180d80a025db041a8e2398dcc059b3afa8382cd4"},
|
||||
{file = "black-22.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2039230db3c6c639bd84efe3292ec7b06e9214a2992cd9beb293d639c6402edb"},
|
||||
{file = "black-22.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14ff67aec0a47c424bc99b71005202045dc09270da44a27848d534600ac64fc7"},
|
||||
{file = "black-22.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:819dc789f4498ecc91438a7de64427c73b45035e2e3680c92e18795a839ebb66"},
|
||||
{file = "black-22.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5b9b29da4f564ba8787c119f37d174f2b69cdfdf9015b7d8c5c16121ddc054ae"},
|
||||
{file = "black-22.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8b49776299fece66bffaafe357d929ca9451450f5466e997a7285ab0fe28e3b"},
|
||||
{file = "black-22.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:21199526696b8f09c3997e2b4db8d0b108d801a348414264d2eb8eb2532e540d"},
|
||||
{file = "black-22.10.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e464456d24e23d11fced2bc8c47ef66d471f845c7b7a42f3bd77bf3d1789650"},
|
||||
{file = "black-22.10.0-cp37-cp37m-win_amd64.whl", hash = "sha256:9311e99228ae10023300ecac05be5a296f60d2fd10fff31cf5c1fa4ca4b1988d"},
|
||||
{file = "black-22.10.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:fba8a281e570adafb79f7755ac8721b6cf1bbf691186a287e990c7929c7692ff"},
|
||||
{file = "black-22.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:915ace4ff03fdfff953962fa672d44be269deb2eaf88499a0f8805221bc68c87"},
|
||||
{file = "black-22.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:444ebfb4e441254e87bad00c661fe32df9969b2bf224373a448d8aca2132b395"},
|
||||
{file = "black-22.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:974308c58d057a651d182208a484ce80a26dac0caef2895836a92dd6ebd725e0"},
|
||||
{file = "black-22.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72ef3925f30e12a184889aac03d77d031056860ccae8a1e519f6cbb742736383"},
|
||||
{file = "black-22.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:432247333090c8c5366e69627ccb363bc58514ae3e63f7fc75c54b1ea80fa7de"},
|
||||
{file = "black-22.10.0-py3-none-any.whl", hash = "sha256:c957b2b4ea88587b46cf49d1dc17681c1e672864fd7af32fc1e9664d572b3458"},
|
||||
{file = "black-22.10.0.tar.gz", hash = "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1"},
|
||||
]
|
||||
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.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
||||
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
||||
]
|
||||
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"},
|
||||
]
|
||||
exceptiongroup = [
|
||||
{file = "exceptiongroup-1.0.4-py3-none-any.whl", hash = "sha256:542adf9dea4055530d6e1279602fa5cb11dab2395fa650b8674eaec35fc4a828"},
|
||||
{file = "exceptiongroup-1.0.4.tar.gz", hash = "sha256:bd14967b79cd9bdb54d97323216f8fdf533e278df937aa2a90089e7d6e06e5ec"},
|
||||
]
|
||||
flake8 = [
|
||||
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
|
||||
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
|
||||
]
|
||||
iniconfig = [
|
||||
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
|
||||
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
|
||||
]
|
||||
jedi = [
|
||||
{file = "jedi-0.18.1-py2.py3-none-any.whl", hash = "sha256:637c9635fcf47945ceb91cd7f320234a7be540ded6f3e99a50cb6febdfd1ba8d"},
|
||||
{file = "jedi-0.18.1.tar.gz", hash = "sha256:74137626a64a99c8eb6ae5832d99b3bdd7d29a3850fe2aa80a4126b2a7d949ab"},
|
||||
]
|
||||
mccabe = [
|
||||
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
|
||||
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
|
||||
]
|
||||
mypy-extensions = [
|
||||
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
|
||||
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
|
||||
]
|
||||
packaging = [
|
||||
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
|
||||
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
|
||||
]
|
||||
parso = [
|
||||
{file = "parso-0.8.3-py2.py3-none-any.whl", hash = "sha256:c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75"},
|
||||
{file = "parso-0.8.3.tar.gz", hash = "sha256:8c07be290bb59f03588915921e29e8a50002acaf2cdc5fa0e0114f91709fafa0"},
|
||||
]
|
||||
pathspec = [
|
||||
{file = "pathspec-0.10.2-py3-none-any.whl", hash = "sha256:88c2606f2c1e818b978540f73ecc908e13999c6c3a383daf3705652ae79807a5"},
|
||||
{file = "pathspec-0.10.2.tar.gz", hash = "sha256:8f6bf73e5758fd365ef5d58ce09ac7c27d2833a8d7da51712eac6e27e35141b0"},
|
||||
]
|
||||
platformdirs = [
|
||||
{file = "platformdirs-2.5.4-py3-none-any.whl", hash = "sha256:af0276409f9a02373d540bf8480021a048711d572745aef4b7842dad245eba10"},
|
||||
{file = "platformdirs-2.5.4.tar.gz", hash = "sha256:1006647646d80f16130f052404c6b901e80ee4ed6bef6792e1f238a8969106f7"},
|
||||
]
|
||||
pluggy = [
|
||||
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
|
||||
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
|
||||
]
|
||||
pybricks = []
|
||||
pycodestyle = [
|
||||
{file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"},
|
||||
{file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"},
|
||||
]
|
||||
pyflakes = [
|
||||
{file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"},
|
||||
{file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
||||
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
|
||||
]
|
||||
pytest = [
|
||||
{file = "pytest-7.2.0-py3-none-any.whl", hash = "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71"},
|
||||
{file = "pytest-7.2.0.tar.gz", hash = "sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59"},
|
||||
]
|
||||
tomli = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
typing-extensions = [
|
||||
files = [
|
||||
{file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"},
|
||||
{file = "typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"},
|
||||
]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">= 3.10, < 3.12"
|
||||
content-hash = "f5918513eac0de09516e7509b8fe6f27d407f805c2013907447d71c3699e63bd"
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks_jedi"
|
||||
version = "1.7.0"
|
||||
version = "1.11.0"
|
||||
description = "Code completion for Pybricks."
|
||||
authors = ["The Pybricks Authors <team@pybricks.com>"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">= 3.10, < 3.11"
|
||||
pybricks = "3.2.0c1"
|
||||
python = ">= 3.10, < 3.12"
|
||||
pybricks = "3.3.0c1"
|
||||
jedi = "0.18.1"
|
||||
typing-extensions = "4.2.0"
|
||||
docstring-parser = "0.14.1"
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"light",
|
||||
"system",
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"charger",
|
||||
"imu",
|
||||
|
||||
@@ -148,7 +148,7 @@ def test_from_pybricks_pupdevices_import():
|
||||
def test_from_pybricks_robotics_import():
|
||||
code = "from pybricks.robotics import "
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
|
||||
assert [c["insertText"] for c in completions] == ["DriveBase", "GyroDriveBase"]
|
||||
assert [c["insertText"] for c in completions] == ["DriveBase"]
|
||||
|
||||
|
||||
def test_from_pybricks_tools_import():
|
||||
@@ -157,7 +157,11 @@ def test_from_pybricks_tools_import():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"cross",
|
||||
"DataLog",
|
||||
"hub_menu",
|
||||
"Matrix",
|
||||
"multitask",
|
||||
"read_input_byte",
|
||||
"run_task",
|
||||
"StopWatch",
|
||||
"vector",
|
||||
"wait",
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"imu",
|
||||
"light",
|
||||
@@ -65,6 +66,7 @@ def test_hub_dot_imu_dot():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"acceleration",
|
||||
"tilt",
|
||||
"up",
|
||||
]
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"buttons",
|
||||
"charger",
|
||||
"display",
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_hub_dot():
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"imu",
|
||||
"light",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2022 The Pybricks Authors
|
||||
# Copyright (c) 2022-2023 The Pybricks Authors
|
||||
|
||||
"""
|
||||
Tests for correct signatures of the pupdevices.Motor class.
|
||||
@@ -29,7 +29,8 @@ def _get_function_signature(module: str, function: str) -> SignatureHelp:
|
||||
|
||||
|
||||
FUNCTION_PARAMS = [
|
||||
pytest.param("pybricks.tools", "wait", [(["time: Number"], "None")]),
|
||||
pytest.param("pybricks.tools", "read_input_byte", [([], "Optional[int]")]),
|
||||
pytest.param("pybricks.tools", "wait", [(["time: Number"], "MaybeAwaitable")]),
|
||||
pytest.param(
|
||||
"pybricks.tools",
|
||||
"vector",
|
||||
@@ -78,17 +79,51 @@ def _get_constructor_signature(module: str, type: str) -> SignatureHelp:
|
||||
|
||||
|
||||
CONSTRUCTOR_PARAMS = [
|
||||
pytest.param("pybricks.hubs", "MoveHub", [[]]),
|
||||
pytest.param("pybricks.hubs", "CityHub", [[]]),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"MoveHub",
|
||||
[["broadcast_channel: int=0", "observe_channels: Sequence[int]=[]"]],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"CityHub",
|
||||
[["broadcast_channel: int=0", "observe_channels: Sequence[int]=[]"]],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"TechnicHub",
|
||||
[["top_side: Axis=Axis.Z", "front_side: Axis=Axis.X"]],
|
||||
[
|
||||
[
|
||||
"top_side: Axis=Axis.Z",
|
||||
"front_side: Axis=Axis.X",
|
||||
"broadcast_channel: int=0",
|
||||
"observe_channels: Sequence[int]=[]",
|
||||
]
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
[["top_side: Axis=Axis.Z", "front_side: Axis=Axis.X"]],
|
||||
[
|
||||
[
|
||||
"top_side: Axis=Axis.Z",
|
||||
"front_side: Axis=Axis.X",
|
||||
"broadcast_channel: int=0",
|
||||
"observe_channels: Sequence[int]=[]",
|
||||
]
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"EssentialHub",
|
||||
[
|
||||
[
|
||||
"top_side: Axis=Axis.Z",
|
||||
"front_side: Axis=Axis.X",
|
||||
"broadcast_channel: int=0",
|
||||
"observe_channels: Sequence[int]=[]",
|
||||
]
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
@@ -429,13 +464,13 @@ METHOD_PARAMS = [
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"speaker.beep",
|
||||
[(["frequency: Number=500", "duration: Number=100"], "None")],
|
||||
[(["frequency: Number=500", "duration: Number=100"], "MaybeAwaitable")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
"PrimeHub",
|
||||
"speaker.play_notes",
|
||||
[(["notes: Iterable[str]", "tempo: Number=120"], "None")],
|
||||
[(["notes: Iterable[str]", "tempo: Number=120"], "MaybeAwaitable")],
|
||||
),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "battery.voltage", [([], "int")]),
|
||||
pytest.param("pybricks.hubs", "PrimeHub", "battery.current", [([], "int")]),
|
||||
@@ -571,7 +606,7 @@ METHOD_PARAMS = [
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -587,7 +622,7 @@ METHOD_PARAMS = [
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -603,7 +638,7 @@ METHOD_PARAMS = [
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -624,7 +659,7 @@ METHOD_PARAMS = [
|
||||
"then: Stop=Stop.COAST",
|
||||
"duty_limit: Optional[Number]=None",
|
||||
],
|
||||
"int",
|
||||
"MaybeAwaitableInt",
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -703,24 +738,53 @@ METHOD_PARAMS = [
|
||||
],
|
||||
),
|
||||
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")]
|
||||
"pybricks.pupdevices",
|
||||
"TiltSensor",
|
||||
"tilt",
|
||||
[([], "MaybeAwaitableTuple[int, int]")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "reflection", [([], "int")]
|
||||
"pybricks.pupdevices", "InfraredSensor", "distance", [([], "MaybeAwaitableInt")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "ambient", [([], "int")]
|
||||
"pybricks.pupdevices",
|
||||
"InfraredSensor",
|
||||
"reflection",
|
||||
[([], "MaybeAwaitableInt")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "distance", [([], "int")]
|
||||
"pybricks.pupdevices", "InfraredSensor", "count", [([], "MaybeAwaitableInt")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"color",
|
||||
[([], "MaybeAwaitableColor")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"reflection",
|
||||
[([], "MaybeAwaitableInt")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"ambient",
|
||||
[([], "MaybeAwaitableInt")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"distance",
|
||||
[([], "MaybeAwaitableInt")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"hsv",
|
||||
[([], "MaybeAwaitableColor")],
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorDistanceSensor", "hsv", [([], "Color")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
@@ -731,27 +795,36 @@ METHOD_PARAMS = [
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"light.on",
|
||||
[(["color: Color"], "None")],
|
||||
[(["color: Color"], "MaybeAwaitable")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorDistanceSensor", "light.off", [([], "None")]
|
||||
"pybricks.pupdevices",
|
||||
"ColorDistanceSensor",
|
||||
"light.off",
|
||||
[([], "MaybeAwaitable")],
|
||||
),
|
||||
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", "PFMotor", "dc", [(["duty: Number"], "MaybeAwaitable")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "PFMotor", "stop", [([], "MaybeAwaitable")]),
|
||||
pytest.param("pybricks.pupdevices", "PFMotor", "brake", [([], "MaybeAwaitable")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"color",
|
||||
[(["surface: bool=True"], "Optional[Color]")],
|
||||
[(["surface: bool=True"], "MaybeAwaitableColor")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorSensor", "reflection", [([], "MaybeAwaitableInt")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorSensor", "ambient", [([], "MaybeAwaitableInt")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorSensor", "reflection", [([], "int")]),
|
||||
pytest.param("pybricks.pupdevices", "ColorSensor", "ambient", [([], "int")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"hsv",
|
||||
[(["surface: bool=True"], "Color")],
|
||||
[(["surface: bool=True"], "MaybeAwaitableColor")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
@@ -763,11 +836,28 @@ METHOD_PARAMS = [
|
||||
"pybricks.pupdevices",
|
||||
"ColorSensor",
|
||||
"lights.on",
|
||||
[(["brightness: Union[Number, Tuple[Number, Number, Number]]"], "None")],
|
||||
[
|
||||
(
|
||||
["brightness: Union[Number, Tuple[Number, Number, Number]]"],
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorSensor", "lights.off", [([], "MaybeAwaitable")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"UltrasonicSensor",
|
||||
"distance",
|
||||
[([], "MaybeAwaitableInt")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"UltrasonicSensor",
|
||||
"presence",
|
||||
[([], "MaybeAwaitableBool")],
|
||||
),
|
||||
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",
|
||||
@@ -775,29 +865,40 @@ METHOD_PARAMS = [
|
||||
[
|
||||
(
|
||||
["brightness: Union[Number, Tuple[Number, Number, Number, Number]]"],
|
||||
"None",
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "UltrasonicSensor", "lights.off", [([], "None")]
|
||||
"pybricks.pupdevices",
|
||||
"UltrasonicSensor",
|
||||
"lights.off",
|
||||
[([], "MaybeAwaitable")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ForceSensor", "force", [([], "MaybeAwaitableFloat")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ForceSensor", "distance", [([], "MaybeAwaitableFloat")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", "force", [([], "float")]),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", "distance", [([], "float")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ForceSensor",
|
||||
"pressed",
|
||||
[(["force: Number=3"], "bool")],
|
||||
[(["force: Number=3"], "MaybeAwaitableBool")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ForceSensor", "touched", [([], "MaybeAwaitableBool")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ForceSensor", "touched", [([], "bool")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"ColorLightMatrix",
|
||||
"on",
|
||||
[(["color: Union[Color, Collection[Color]]"], "None")],
|
||||
[(["color: Union[Color, Collection[Color]]"], "MaybeAwaitable")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "ColorLightMatrix", "off", [([], "MaybeAwaitable")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "ColorLightMatrix", "off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "Light", "on", [(["brightness: Number=100"], "None")]
|
||||
),
|
||||
@@ -809,9 +910,14 @@ METHOD_PARAMS = [
|
||||
[(["name: str"], "None"), ([], "str")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "Remote", "light.on", [(["color: Color"], "None")]
|
||||
"pybricks.pupdevices",
|
||||
"Remote",
|
||||
"light.on",
|
||||
[(["color: Color"], "MaybeAwaitable")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices", "Remote", "light.off", [([], "MaybeAwaitable")]
|
||||
),
|
||||
pytest.param("pybricks.pupdevices", "Remote", "light.off", [([], "None")]),
|
||||
pytest.param(
|
||||
"pybricks.pupdevices",
|
||||
"Remote",
|
||||
@@ -826,13 +932,23 @@ METHOD_PARAMS = [
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"straight",
|
||||
[(["distance: Number", "then: Stop=Stop.HOLD", "wait: bool=True"], "None")],
|
||||
[
|
||||
(
|
||||
["distance: Number", "then: Stop=Stop.HOLD", "wait: bool=True"],
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
"DriveBase",
|
||||
"turn",
|
||||
[(["angle: Number", "then: Stop=Stop.HOLD", "wait: bool=True"], "None")],
|
||||
[
|
||||
(
|
||||
["angle: Number", "then: Stop=Stop.HOLD", "wait: bool=True"],
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.robotics",
|
||||
@@ -846,7 +962,7 @@ METHOD_PARAMS = [
|
||||
"then: Stop=Stop.HOLD",
|
||||
"wait: bool=True",
|
||||
],
|
||||
"None",
|
||||
"MaybeAwaitable",
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -874,6 +990,7 @@ METHOD_PARAMS = [
|
||||
[(["speed: Number", "turn_rate: Number"], "None")],
|
||||
),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "stop", [([], "None")]),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "brake", [([], "None")]),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "distance", [([], "int")]),
|
||||
pytest.param("pybricks.robotics", "DriveBase", "angle", [([], "int")]),
|
||||
pytest.param(
|
||||
|
||||
@@ -2,6 +2,21 @@
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## 2.11.0 - 2023-11-20
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0c1.
|
||||
|
||||
## 2.10.0 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0b9.
|
||||
|
||||
## 2.9.0 - 2023-05-16
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.3.0b5.
|
||||
|
||||
## 2.8.0 - 2023-04-21
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2021 The Pybricks Authors
|
||||
Copyright (c) 2018-2023 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pybricks/ide-docs",
|
||||
"version": "2.8.0",
|
||||
"version": "2.11.0",
|
||||
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -4,6 +4,26 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 1.11.0 - 2023-11-20
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.11.0.
|
||||
|
||||
## 1.10.0 - 2023-10-26
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.10.0.
|
||||
|
||||
## 1.9.0 - 2023-05-16
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.9.0.
|
||||
|
||||
## 1.8.0 - 2023-04-21
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks_jedi` Python package to v1.8.0.
|
||||
|
||||
## 1.7.0 - 2022-12-28
|
||||
|
||||
### Changed
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ BUILD_DIR = (pathlib.Path(__file__).parent / "build").resolve()
|
||||
|
||||
package_json = {
|
||||
"name": "@pybricks/jedi",
|
||||
"version": "1.7.0",
|
||||
"version": "1.11.0",
|
||||
"description": "Binary distribution of pybricks-jedi Python package and dependencies for use with Pyodide.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -30,7 +30,7 @@ whl_map: dict[str, str] = {}
|
||||
shutil.rmtree(BUILD_DIR, True)
|
||||
BUILD_DIR.mkdir()
|
||||
|
||||
# download package and depedencies (*.whl files)
|
||||
# download package and dependencies (*.whl files)
|
||||
subprocess.check_call(
|
||||
[
|
||||
sys.executable,
|
||||
@@ -38,7 +38,7 @@ subprocess.check_call(
|
||||
"pip",
|
||||
"download",
|
||||
"--only-binary=any",
|
||||
"pybricks-jedi==1.7.0",
|
||||
"pybricks-jedi==1.11.0",
|
||||
],
|
||||
cwd=BUILD_DIR,
|
||||
)
|
||||
|
||||
Generated
+424
-336
File diff suppressed because it is too large
Load Diff
+6
-5
@@ -1,8 +1,8 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks"
|
||||
version = "3.3.0a4"
|
||||
version = "3.3.0c1"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
authors = ["The Pybricks Authors <dev@pybricks.com>"]
|
||||
authors = ["The Pybricks Authors <team@pybricks.com>"]
|
||||
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
||||
license = "MIT"
|
||||
readme = "README.rst"
|
||||
@@ -10,7 +10,6 @@ homepage = "https://pybricks.com"
|
||||
repository = "https://github.com/pybricks/pybricks-api"
|
||||
documentation = "https://docs.pybricks.com"
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Programming Language :: Python :: Implementation :: MicroPython",
|
||||
]
|
||||
packages = [
|
||||
@@ -29,11 +28,13 @@ packages = [
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
[tool.poetry.group.lint.dependencies]
|
||||
black = "^22.3.0"
|
||||
doc8 = "^0.8.1"
|
||||
flake8 = "^4.0"
|
||||
Sphinx = { git = "https://github.com/pybricks/sphinx.git", rev = "b00124cb" }
|
||||
|
||||
[tool.poetry.group.doc.dependencies]
|
||||
Sphinx = { git = "https://github.com/pybricks/sphinx.git", rev = "cd277d09" }
|
||||
sphinx-rtd-theme = "^1.0.0"
|
||||
toml = "^0.10.0"
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# This file is strictly for building docs on readthedocs.org
|
||||
# See pyproject.toml for local development
|
||||
git+https://github.com/pybricks/sphinx@b00124c#egg=Sphinx
|
||||
sphinx-rtd-theme==1.0.0
|
||||
toml
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
[flake8]
|
||||
exclude = .venv/,*.pyi,jedi/
|
||||
exclude = .venv/,*.pyi,jedi/,examples/pup/tools/hub_menu.py
|
||||
max-line-length = 88
|
||||
ignore = E203,E501,W503
|
||||
|
||||
|
||||
+168
-37
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2021 The Pybricks Authors
|
||||
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||
|
||||
"""Generic cross-platform module for typical devices like lights, displays,
|
||||
speakers, and batteries."""
|
||||
@@ -12,8 +12,31 @@ from .tools import Matrix
|
||||
from .parameters import Axis, Direction, Stop, Button, Port, Color, Side
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Awaitable, TypeVar
|
||||
|
||||
from .parameters import Number
|
||||
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
|
||||
class MaybeAwaitable(None, Awaitable[None]):
|
||||
...
|
||||
|
||||
# HACK: Cannot subclass bool, so using Any instead.
|
||||
class MaybeAwaitableBool(Any, Awaitable[bool]):
|
||||
...
|
||||
|
||||
class MaybeAwaitableFloat(float, Awaitable[float]):
|
||||
...
|
||||
|
||||
class MaybeAwaitableInt(int, Awaitable[int]):
|
||||
...
|
||||
|
||||
class MaybeAwaitableTuple(Tuple[_T_co], Awaitable[Tuple[_T_co]]):
|
||||
...
|
||||
|
||||
class MaybeAwaitableColor(Color, Awaitable[Color]):
|
||||
...
|
||||
|
||||
|
||||
class System:
|
||||
"""System control actions for a hub."""
|
||||
@@ -78,8 +101,8 @@ class System:
|
||||
|
||||
def storage(self, offset, read=None, write=None):
|
||||
"""
|
||||
storage(self, offset, write=)
|
||||
storage(self, offset, read=) -> bytes
|
||||
storage(offset, write=)
|
||||
storage(offset, read=) -> bytes
|
||||
|
||||
Reads or writes binary data to persistent storage.
|
||||
|
||||
@@ -393,10 +416,12 @@ class Motor(DCMotor):
|
||||
Choose ``False`` to keep the
|
||||
current value, so your program knows where it left off last
|
||||
time.
|
||||
profile (Number, deg): Precision profile. A lower value
|
||||
means more precise movement; a larger value means
|
||||
smoother movement. If no value is given, a suitable profile for
|
||||
this motor type will be selected automatically.
|
||||
profile (Number, deg): Precision profile. This is the approximate
|
||||
position tolerance in degrees that is acceptable in your
|
||||
application. A lower value gives more precise but more erratic
|
||||
movement; a higher value gives less precise but smoother
|
||||
movement. If no value is given, a suitable profile for this
|
||||
motor type will be selected automatically (about 11 degrees).
|
||||
"""
|
||||
|
||||
def angle(self) -> int:
|
||||
@@ -476,7 +501,7 @@ class Motor(DCMotor):
|
||||
|
||||
def run_time(
|
||||
self, speed: Number, time: Number, then: Stop = Stop.HOLD, wait: bool = True
|
||||
) -> None:
|
||||
) -> MaybeAwaitable:
|
||||
"""run_time(speed, time, then=Stop.HOLD, wait=True)
|
||||
|
||||
Runs the motor at a constant speed for a given amount of time.
|
||||
@@ -499,7 +524,7 @@ class Motor(DCMotor):
|
||||
rotation_angle: Number,
|
||||
then: Stop = Stop.HOLD,
|
||||
wait: bool = True,
|
||||
) -> None:
|
||||
) -> MaybeAwaitable:
|
||||
"""run_angle(speed, rotation_angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Runs the motor at a constant speed by a given angle.
|
||||
@@ -519,7 +544,7 @@ class Motor(DCMotor):
|
||||
target_angle: Number,
|
||||
then: Stop = Stop.HOLD,
|
||||
wait: bool = True,
|
||||
) -> None:
|
||||
) -> MaybeAwaitable:
|
||||
"""run_target(speed, target_angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Runs the motor at a constant speed towards a given target angle.
|
||||
@@ -540,7 +565,7 @@ class Motor(DCMotor):
|
||||
speed: Number,
|
||||
then: Stop = Stop.COAST,
|
||||
duty_limit: Optional[Number] = None,
|
||||
) -> int:
|
||||
) -> MaybeAwaitableInt:
|
||||
"""
|
||||
run_until_stalled(speed, then=Stop.COAST, duty_limit=None) -> int: deg
|
||||
|
||||
@@ -580,6 +605,16 @@ class Motor(DCMotor):
|
||||
rotate to.
|
||||
"""
|
||||
|
||||
def close(self) -> None:
|
||||
"""close()
|
||||
|
||||
Closes the motor object so you can call ``Motor`` again to initialize
|
||||
a new object.
|
||||
|
||||
This allows advanced users to change properties such as gearing in the
|
||||
middle of the program, which can be useful for removeable attachments.
|
||||
"""
|
||||
|
||||
|
||||
class Speaker:
|
||||
"""Plays beeps and sounds using a speaker."""
|
||||
@@ -604,7 +639,7 @@ class Speaker:
|
||||
volume (Number, %): Volume of the speaker in the 0-100 range.
|
||||
"""
|
||||
|
||||
def beep(self, frequency: Number = 500, duration: Number = 100) -> None:
|
||||
def beep(self, frequency: Number = 500, duration: Number = 100) -> MaybeAwaitable:
|
||||
"""beep(frequency=500, duration=100)
|
||||
|
||||
Play a beep/tone.
|
||||
@@ -618,7 +653,7 @@ class Speaker:
|
||||
play continues to play indefinitely.
|
||||
"""
|
||||
|
||||
def play_notes(self, notes: Iterable[str], tempo: Number = 120) -> None:
|
||||
def play_notes(self, notes: Iterable[str], tempo: Number = 120) -> MaybeAwaitable:
|
||||
"""play_notes(notes, tempo=120)
|
||||
|
||||
Plays a sequence of musical notes. For example:
|
||||
@@ -705,10 +740,31 @@ class ColorLight:
|
||||
"""
|
||||
|
||||
|
||||
class ExternalColorLight:
|
||||
"""Control a multi-color light."""
|
||||
|
||||
def on(self, color: Color) -> MaybeAwaitable:
|
||||
"""on(color)
|
||||
|
||||
Turns on the light at the specified color.
|
||||
|
||||
Arguments:
|
||||
color (Color): Color of the light.
|
||||
"""
|
||||
|
||||
def off(self) -> MaybeAwaitable:
|
||||
"""off()
|
||||
|
||||
Turns off the light.
|
||||
"""
|
||||
|
||||
|
||||
class LightArray3:
|
||||
"""Control an array of three single-color lights."""
|
||||
|
||||
def on(self, brightness: Union[Number, Tuple[Number, Number, Number]]) -> None:
|
||||
def on(
|
||||
self, brightness: Union[Number, Tuple[Number, Number, Number]]
|
||||
) -> MaybeAwaitable:
|
||||
"""on(brightness)
|
||||
|
||||
Turns on the lights at the specified brightness.
|
||||
@@ -720,10 +776,11 @@ class LightArray3:
|
||||
of each light individually.
|
||||
"""
|
||||
|
||||
def off(self) -> None:
|
||||
def off(self) -> MaybeAwaitable:
|
||||
"""off()
|
||||
|
||||
Turns off all the lights."""
|
||||
Turns off all the lights.
|
||||
"""
|
||||
|
||||
|
||||
class LightArray4(LightArray3):
|
||||
@@ -731,7 +788,7 @@ class LightArray4(LightArray3):
|
||||
|
||||
def on(
|
||||
self, brightness: Union[Number, Tuple[Number, Number, Number, Number]]
|
||||
) -> None:
|
||||
) -> MaybeAwaitable:
|
||||
"""on(brightness)
|
||||
|
||||
Turns on the lights at the specified brightness.
|
||||
@@ -951,6 +1008,20 @@ class SimpleAccelerometer:
|
||||
``Side.FRONT`` or ``Side.BACK``.
|
||||
"""
|
||||
|
||||
def tilt(self) -> Tuple[int, int]:
|
||||
"""tilt() -> Tuple[int, int]
|
||||
|
||||
Gets the pitch and roll angles. This is relative to the
|
||||
:ref:`user-specified neutral orientation <robotframe>`.
|
||||
|
||||
The order of rotation is pitch-then-roll. This is equivalent to a
|
||||
positive rotation along the robot y-axis and then a positive rotation
|
||||
along the x-axis.
|
||||
|
||||
Returns:
|
||||
Tuple of pitch and roll angles in degrees.
|
||||
"""
|
||||
|
||||
|
||||
class Accelerometer(SimpleAccelerometer):
|
||||
"""Get measurements from an accelerometer."""
|
||||
@@ -980,20 +1051,6 @@ class Accelerometer(SimpleAccelerometer):
|
||||
this returns a vector of accelerations along all axes.
|
||||
"""
|
||||
|
||||
def tilt(self) -> Tuple[int, int]:
|
||||
"""tilt() -> Tuple[int, int]
|
||||
|
||||
Gets the pitch and roll angles. This is relative to the
|
||||
:ref:`user-specified neutral orientation <robotframe>`.
|
||||
|
||||
The order of rotation is pitch-then-roll. This is equivalent to a
|
||||
positive rotation along the robot y-axis and then a positive rotation
|
||||
along the x-axis.
|
||||
|
||||
Returns:
|
||||
Tuple of pitch and roll angles in degrees.
|
||||
"""
|
||||
|
||||
|
||||
class IMU(Accelerometer):
|
||||
def ready(self) -> bool:
|
||||
@@ -1164,7 +1221,7 @@ class CommonColorSensor:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
def color(self) -> Color:
|
||||
def color(self) -> MaybeAwaitableColor:
|
||||
"""color() -> Color
|
||||
|
||||
Scans the color of a surface.
|
||||
@@ -1178,7 +1235,7 @@ class CommonColorSensor:
|
||||
Detected color.
|
||||
"""
|
||||
|
||||
def hsv(self) -> Color:
|
||||
def hsv(self) -> MaybeAwaitableColor:
|
||||
"""hsv() -> Color
|
||||
|
||||
Scans the color of a surface.
|
||||
@@ -1192,7 +1249,7 @@ class CommonColorSensor:
|
||||
saturation (0--100), and a brightness value (0--100).
|
||||
"""
|
||||
|
||||
def ambient(self) -> int:
|
||||
def ambient(self) -> MaybeAwaitableInt:
|
||||
"""ambient() -> int: %
|
||||
|
||||
Measures the ambient light intensity.
|
||||
@@ -1202,7 +1259,7 @@ class CommonColorSensor:
|
||||
to 100% (bright).
|
||||
"""
|
||||
|
||||
def reflection(self) -> int:
|
||||
def reflection(self) -> MaybeAwaitableInt:
|
||||
"""reflection() -> int: %
|
||||
|
||||
Measures how much a surface reflects the light emitted by the
|
||||
@@ -1248,7 +1305,7 @@ class AmbientColorSensor(CommonColorSensor):
|
||||
"""Like CommonColorSensor, but also detects ambient colors when the sensor
|
||||
light is turned off"""
|
||||
|
||||
def color(self, surface: bool = True) -> Optional[Color]:
|
||||
def color(self, surface: bool = True) -> MaybeAwaitableColor:
|
||||
"""color(surface=True) -> Color
|
||||
|
||||
Scans the color of a surface or an external light source.
|
||||
@@ -1267,7 +1324,7 @@ class AmbientColorSensor(CommonColorSensor):
|
||||
Detected color.`
|
||||
"""
|
||||
|
||||
def hsv(self, surface: bool = True) -> Color:
|
||||
def hsv(self, surface: bool = True) -> MaybeAwaitableColor:
|
||||
"""hsv(surface=True) -> Color
|
||||
|
||||
Scans the color of a surface or an external light source.
|
||||
@@ -1285,3 +1342,77 @@ class AmbientColorSensor(CommonColorSensor):
|
||||
Measured color. The color is described by a hue (0--359), a
|
||||
saturation (0--100), and a brightness value (0--100).
|
||||
"""
|
||||
|
||||
|
||||
class BLE:
|
||||
"""
|
||||
Bluetooth Low Energy.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
"""
|
||||
|
||||
def broadcast(self, data: Union[bool, int, float, str, bytes]) -> None:
|
||||
"""broadcast(data)
|
||||
|
||||
Starts broadcasting the given data on
|
||||
the *broadcast_channel* you selected when initializing the hub.
|
||||
|
||||
Data may be of type ``int``, ``float``, ``str``, ``bytes``,
|
||||
``True``, or ``False``, or a tuple thereof.
|
||||
|
||||
The total data size is quite limited (26 bytes). ``True`` and
|
||||
``False`` take 1 byte each. ``float`` takes 5 bytes. ``int`` takes 2 to
|
||||
5 bytes depending on how big the number is. ``str`` and ``bytes`` take
|
||||
the number of bytes in the object plus one extra byte.
|
||||
|
||||
Args:
|
||||
data: The value or values to be broadcast.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
"""
|
||||
|
||||
def observe(
|
||||
self, channel: int
|
||||
) -> Optional[Tuple[Union[bool, int, float, str, bytes], ...]]:
|
||||
"""observe(channel) -> bool | int | float | str | bytes | tuple | None
|
||||
|
||||
Retrieves the last observed data for a given channel.
|
||||
|
||||
Receiving data is more reliable when the hub is not connected
|
||||
to a computer or other devices at the same time.
|
||||
|
||||
Args:
|
||||
channel (int): The channel to observe (0 to 255).
|
||||
|
||||
Returns:
|
||||
The received data in the same format as it was sent, or ``None``
|
||||
if no recent data is available.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
"""
|
||||
|
||||
def signal_strength(self, channel: int) -> int:
|
||||
"""signal_strength(channel) -> int: dBm
|
||||
|
||||
Gets the average signal strength in dBm for the given channel.
|
||||
|
||||
This indicates how near the broadcasting device is. Nearby devices
|
||||
may have a signal strength around -40 dBm, while far away devices
|
||||
might have a signal strength around -70 dBm.
|
||||
|
||||
Args:
|
||||
channel (int): The channel number (0 to 255).
|
||||
|
||||
Returns:
|
||||
The signal strength or ``-128`` if there is no recent observed data.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
"""
|
||||
|
||||
def version(self) -> str:
|
||||
"""version() -> str
|
||||
|
||||
Gets the firmware version from the Bluetooth chip.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
"""
|
||||
|
||||
+103
-7
@@ -1,7 +1,10 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2022 The Pybricks Authors
|
||||
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||
|
||||
"""LEGO® Programmable Hubs."""
|
||||
|
||||
from typing import Sequence
|
||||
|
||||
from . import _common
|
||||
from .ev3dev import _speaker
|
||||
from .media.ev3dev import Image as _Image
|
||||
@@ -38,6 +41,29 @@ class MoveHub:
|
||||
imu = _common.SimpleAccelerometer()
|
||||
system = _common.System()
|
||||
button = _common.Keypad([_Button.CENTER])
|
||||
ble = _common.BLE()
|
||||
|
||||
def __init__(
|
||||
self, broadcast_channel: int = 0, observe_channels: Sequence[int] = []
|
||||
):
|
||||
"""MoveHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||
|
||||
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.
|
||||
broadcast_channel:
|
||||
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||
will use. Default is channel 0.
|
||||
observe_channels:
|
||||
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||
called. Listening to more channels requires more memory.
|
||||
Default is an empty list (no channels).
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added *broadcast_channel* and *observe_channels* arguments.
|
||||
"""
|
||||
|
||||
|
||||
class CityHub:
|
||||
@@ -49,6 +75,25 @@ class CityHub:
|
||||
light = _common.ColorLight()
|
||||
system = _common.System()
|
||||
button = _common.Keypad([_Button.CENTER])
|
||||
ble = _common.BLE()
|
||||
|
||||
def __init__(
|
||||
self, broadcast_channel: int = 0, observe_channels: Sequence[int] = []
|
||||
):
|
||||
"""CityHub(broadcast_channel=0, observe_channels=[])
|
||||
|
||||
Arguments:
|
||||
broadcast_channel:
|
||||
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||
will use. Default is channel 0.
|
||||
observe_channels:
|
||||
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||
called. Listening to more channels requires more memory.
|
||||
Default is an empty list (no channels).
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added *broadcast_channel* and *observe_channels* arguments.
|
||||
"""
|
||||
|
||||
|
||||
class TechnicHub:
|
||||
@@ -61,9 +106,16 @@ class TechnicHub:
|
||||
imu = _common.IMU()
|
||||
system = _common.System()
|
||||
button = _common.Keypad([_Button.CENTER])
|
||||
ble = _common.BLE()
|
||||
|
||||
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
|
||||
"""TechnicHub(top_side=Axis.Z, front_side=Axis.X)
|
||||
def __init__(
|
||||
self,
|
||||
top_side: Axis = Axis.Z,
|
||||
front_side: Axis = Axis.X,
|
||||
broadcast_channel: int = 0,
|
||||
observe_channels: Sequence[int] = [],
|
||||
):
|
||||
"""TechnicHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||
|
||||
Initializes the hub. Optionally, specify how the hub is
|
||||
:ref:`placed in your design <robotframe>` by saying in which
|
||||
@@ -75,6 +127,16 @@ class TechnicHub:
|
||||
the hub.
|
||||
front_side (Axis): The axis that passes through the *front side* of
|
||||
the hub.
|
||||
broadcast_channel:
|
||||
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||
will use. Default is channel 0.
|
||||
observe_channels:
|
||||
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||
called. Listening to more channels requires more memory.
|
||||
Default is an empty list (no channels).
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added *broadcast_channel* and *observe_channels* arguments.
|
||||
"""
|
||||
|
||||
|
||||
@@ -89,9 +151,16 @@ class EssentialHub:
|
||||
light = _common.ColorLight()
|
||||
imu = _common.IMU()
|
||||
system = _common.System()
|
||||
ble = _common.BLE()
|
||||
|
||||
def __init__(self, top_side=Axis.Z, front_side=Axis.X):
|
||||
"""__init__(top_side=Axis.Z, front_side=Axis.X)
|
||||
def __init__(
|
||||
self,
|
||||
top_side: Axis = Axis.Z,
|
||||
front_side: Axis = Axis.X,
|
||||
broadcast_channel: int = 0,
|
||||
observe_channels: Sequence[int] = [],
|
||||
):
|
||||
"""EssentialHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||
|
||||
Initializes the hub. Optionally, specify how the hub is
|
||||
:ref:`placed in your design <robotframe>` by saying in which
|
||||
@@ -103,6 +172,16 @@ class EssentialHub:
|
||||
the hub.
|
||||
front_side (Axis): The axis that passes through the *front side* of
|
||||
the hub.
|
||||
broadcast_channel:
|
||||
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||
will use. Default is channel 0.
|
||||
observe_channels:
|
||||
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||
called. Listening to more channels requires more memory.
|
||||
Default is an empty list (no channels).
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added *broadcast_channel* and *observe_channels* arguments.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -127,9 +206,16 @@ class PrimeHub:
|
||||
speaker = _common.Speaker()
|
||||
imu = _common.IMU()
|
||||
system = _common.System()
|
||||
ble = _common.BLE()
|
||||
|
||||
def __init__(self, top_side: Axis = Axis.Z, front_side: Axis = Axis.X):
|
||||
"""PrimeHub(top_side=Axis.Z, front_side=Axis.X)
|
||||
def __init__(
|
||||
self,
|
||||
top_side: Axis = Axis.Z,
|
||||
front_side: Axis = Axis.X,
|
||||
broadcast_channel: int = 0,
|
||||
observe_channels: Sequence[int] = [],
|
||||
):
|
||||
"""PrimeHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[])
|
||||
|
||||
Initializes the hub. Optionally, specify how the hub is
|
||||
:ref:`placed in your design <robotframe>` by saying in which
|
||||
@@ -141,6 +227,16 @@ class PrimeHub:
|
||||
the hub.
|
||||
front_side (Axis): The axis that passes through the *front side* of
|
||||
the hub.
|
||||
broadcast_channel:
|
||||
A value from 0 to 255 indicating which channel ``hub.ble.broadcast()``
|
||||
will use. Default is channel 0.
|
||||
observe_channels:
|
||||
A list of channels to listen to when ``hub.ble.observe()`` is
|
||||
called. Listening to more channels requires more memory.
|
||||
Default is an empty list (no channels).
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added *broadcast_channel* and *observe_channels* arguments.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2020 The Pybricks Authors
|
||||
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||
|
||||
"""Generic input/output devices."""
|
||||
|
||||
from typing import Dict, Tuple, Optional, overload
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, Tuple, Optional, overload, TYPE_CHECKING
|
||||
|
||||
from . import _common
|
||||
from .parameters import Port as _Port
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._common import MaybeAwaitable, MaybeAwaitableTuple
|
||||
|
||||
|
||||
class PUPDevice:
|
||||
"""Powered Up motor or sensor."""
|
||||
@@ -28,7 +33,7 @@ class PUPDevice:
|
||||
Dictionary with information, such as the device ``id``.
|
||||
"""
|
||||
|
||||
def read(self, mode: int) -> Tuple:
|
||||
def read(self, mode: int) -> MaybeAwaitableTuple:
|
||||
"""read(mode) -> Tuple
|
||||
|
||||
Reads values from a given mode.
|
||||
@@ -40,7 +45,7 @@ class PUPDevice:
|
||||
Values read from the sensor.
|
||||
"""
|
||||
|
||||
def write(self, mode: int, data: Tuple) -> None:
|
||||
def write(self, mode: int, data: Tuple) -> MaybeAwaitable:
|
||||
"""write(mode, data)
|
||||
|
||||
Writes values to the sensor. Only selected sensors and modes support
|
||||
@@ -62,7 +67,7 @@ class LUMPDevice:
|
||||
port (Port): Port to which the device is connected.
|
||||
"""
|
||||
|
||||
def read(self, mode: int) -> Tuple:
|
||||
def read(self, mode: int) -> MaybeAwaitableTuple:
|
||||
"""read(mode) -> Tuple
|
||||
|
||||
Reads values from a given mode.
|
||||
@@ -95,7 +100,7 @@ class Ev3devSensor:
|
||||
port (Port): Port to which the device is connected.
|
||||
"""
|
||||
|
||||
def read(self, mode: str) -> Tuple:
|
||||
def read(self, mode: str) -> MaybeAwaitableTuple:
|
||||
"""read(mode) -> Tuple
|
||||
|
||||
Reads values at a given mode.
|
||||
@@ -311,7 +316,7 @@ class LWP3Device:
|
||||
this method returns the current name.
|
||||
"""
|
||||
|
||||
def write(self, buf: bytes) -> None:
|
||||
def write(self, buf: bytes) -> MaybeAwaitable:
|
||||
"""write(buf)
|
||||
|
||||
Sends a message to the remote hub.
|
||||
@@ -331,3 +336,9 @@ class LWP3Device:
|
||||
Returns:
|
||||
The raw binary message.
|
||||
"""
|
||||
|
||||
|
||||
# hide from jedi
|
||||
if TYPE_CHECKING:
|
||||
del MaybeAwaitable
|
||||
del MaybeAwaitableTuple
|
||||
|
||||
+63
-23
@@ -1,16 +1,23 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2022 The Pybricks Authors
|
||||
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||
|
||||
"""LEGO® Powered Up motor, sensors, and lights."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Collection, Optional, Union, overload, Tuple
|
||||
from typing import TYPE_CHECKING, Collection, Optional, Union, overload
|
||||
|
||||
from . import _common
|
||||
from .parameters import Button, Color, Direction
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._common import (
|
||||
MaybeAwaitable,
|
||||
MaybeAwaitableBool,
|
||||
MaybeAwaitableFloat,
|
||||
MaybeAwaitableInt,
|
||||
MaybeAwaitableTuple,
|
||||
)
|
||||
from .parameters import Number, Port
|
||||
|
||||
|
||||
@@ -63,10 +70,12 @@ class Motor(_common.Motor):
|
||||
Choose ``False`` to keep the
|
||||
current value, so your program knows where it left off last
|
||||
time.
|
||||
profile (Number, deg): Precision profile. A lower value
|
||||
means more precise movement; a larger value means
|
||||
smoother movement. If no value is given, a suitable profile for
|
||||
this motor type will be selected automatically.
|
||||
profile (Number, deg): Precision profile. This is the approximate
|
||||
position tolerance in degrees that is acceptable in your
|
||||
application. A lower value gives more precise but more erratic
|
||||
movement; a higher value gives less precise but smoother
|
||||
movement. If no value is given, a suitable profile for this
|
||||
motor type will be selected automatically (about 11 degrees).
|
||||
"""
|
||||
|
||||
def reset_angle(self, angle: Optional[Number] = None) -> None:
|
||||
@@ -85,7 +94,7 @@ class Motor(_common.Motor):
|
||||
class Remote:
|
||||
"""LEGO® Powered Up Bluetooth Remote Control."""
|
||||
|
||||
light = _common.ColorLight()
|
||||
light = _common.ExternalColorLight()
|
||||
buttons = _common.Keypad(
|
||||
(
|
||||
Button.LEFT_MINUS,
|
||||
@@ -97,7 +106,7 @@ class Remote:
|
||||
Button.RIGHT_PLUS,
|
||||
)
|
||||
)
|
||||
addresss: Union[str, None]
|
||||
address: Union[str, None]
|
||||
|
||||
def __init__(self, name: Optional[str] = None, timeout: int = 10000):
|
||||
"""Remote(name=None, timeout=10000)
|
||||
@@ -144,7 +153,7 @@ class TiltSensor:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
def tilt(self) -> Tuple[int, int]:
|
||||
def tilt(self) -> MaybeAwaitableTuple[int, int]:
|
||||
"""tilt() -> Tuple[int, int]: deg
|
||||
|
||||
Measures the tilt relative to the horizontal plane.
|
||||
@@ -157,7 +166,7 @@ class TiltSensor:
|
||||
class ColorDistanceSensor(_common.CommonColorSensor):
|
||||
"""LEGO® Powered Up Color and Distance Sensor."""
|
||||
|
||||
light = _common.ColorLight()
|
||||
light = _common.ExternalColorLight()
|
||||
|
||||
# HACK: jedi can't find inherited __init__ so docs have to be duplicated
|
||||
def __init__(self, port: Port):
|
||||
@@ -167,7 +176,7 @@ class ColorDistanceSensor(_common.CommonColorSensor):
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
def distance(self) -> int:
|
||||
def distance(self) -> MaybeAwaitableInt:
|
||||
"""distance() -> int: %
|
||||
|
||||
Measures the relative distance between the sensor and an object
|
||||
@@ -178,7 +187,7 @@ class ColorDistanceSensor(_common.CommonColorSensor):
|
||||
"""
|
||||
|
||||
|
||||
class PFMotor(DCMotor):
|
||||
class PFMotor:
|
||||
"""Control Power Functions motors with the infrared functionality of the
|
||||
:class:`ColorDistanceSensor <pybricks.pupdevices.ColorDistanceSensor>`."""
|
||||
|
||||
@@ -204,6 +213,32 @@ class PFMotor(DCMotor):
|
||||
turn when you give a positive duty cycle value.
|
||||
"""
|
||||
|
||||
def dc(self, duty: Number) -> MaybeAwaitable:
|
||||
"""dc(duty)
|
||||
|
||||
Rotates the motor at a given duty cycle (also known as "power").
|
||||
|
||||
Arguments:
|
||||
duty (Number, %): The duty cycle (-100.0 to 100).
|
||||
"""
|
||||
|
||||
def stop(self) -> MaybeAwaitable:
|
||||
"""stop()
|
||||
|
||||
Stops the motor and lets it spin freely.
|
||||
|
||||
The motor gradually stops due to friction.
|
||||
"""
|
||||
|
||||
def brake(self) -> MaybeAwaitable:
|
||||
"""brake()
|
||||
|
||||
Passively brakes the motor.
|
||||
|
||||
The motor stops due to friction, plus the voltage that
|
||||
is generated while the motor is still moving.
|
||||
"""
|
||||
|
||||
|
||||
class ColorSensor(_common.AmbientColorSensor):
|
||||
"""LEGO® SPIKE Color Sensor."""
|
||||
@@ -232,7 +267,7 @@ class UltrasonicSensor:
|
||||
|
||||
"""
|
||||
|
||||
def distance(self) -> int:
|
||||
def distance(self) -> MaybeAwaitableInt:
|
||||
"""distance() -> int: mm
|
||||
|
||||
Measures the distance between the sensor and an object using
|
||||
@@ -244,7 +279,7 @@ class UltrasonicSensor:
|
||||
|
||||
"""
|
||||
|
||||
def presence(self) -> bool:
|
||||
def presence(self) -> MaybeAwaitableBool:
|
||||
"""presence() -> bool
|
||||
|
||||
Checks for the presence of other ultrasonic sensors by detecting
|
||||
@@ -265,7 +300,7 @@ class ForceSensor:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
def force(self) -> float:
|
||||
def force(self) -> MaybeAwaitableFloat:
|
||||
"""force() -> float: N
|
||||
|
||||
Measures the force exerted on the sensor.
|
||||
@@ -274,7 +309,7 @@ class ForceSensor:
|
||||
Measured force (up to approximately 10.00 N).
|
||||
"""
|
||||
|
||||
def distance(self) -> float:
|
||||
def distance(self) -> MaybeAwaitableFloat:
|
||||
"""distance() -> float: mm
|
||||
|
||||
Measures by how much the sensor button has moved.
|
||||
@@ -283,7 +318,7 @@ class ForceSensor:
|
||||
Movement up to approximately 8.00 mm.
|
||||
"""
|
||||
|
||||
def pressed(self, force: Number = 3) -> bool:
|
||||
def pressed(self, force: Number = 3) -> MaybeAwaitableBool:
|
||||
"""pressed(force=3) -> bool
|
||||
|
||||
Checks if the sensor button is pressed.
|
||||
@@ -295,7 +330,7 @@ class ForceSensor:
|
||||
``True`` if the sensor is pressed, ``False`` if it is not.
|
||||
"""
|
||||
|
||||
def touched(self) -> bool:
|
||||
def touched(self) -> MaybeAwaitableBool:
|
||||
"""touched() -> bool
|
||||
|
||||
Checks if the sensor is touched.
|
||||
@@ -323,7 +358,7 @@ class ColorLightMatrix:
|
||||
"""
|
||||
...
|
||||
|
||||
def on(self, color: Union[Color, Collection[Color]]) -> None:
|
||||
def on(self, color: Union[Color, Collection[Color]]) -> MaybeAwaitable:
|
||||
"""on(colors)
|
||||
|
||||
Turns the lights on.
|
||||
@@ -336,7 +371,7 @@ class ColorLightMatrix:
|
||||
"""
|
||||
...
|
||||
|
||||
def off(self) -> None:
|
||||
def off(self) -> MaybeAwaitable:
|
||||
"""off()
|
||||
|
||||
Turns all lights off.
|
||||
@@ -354,7 +389,7 @@ class InfraredSensor:
|
||||
port (Port): Port to which the sensor is connected.
|
||||
"""
|
||||
|
||||
def reflection(self) -> int:
|
||||
def reflection(self) -> MaybeAwaitableInt:
|
||||
"""reflection() -> int: %
|
||||
|
||||
Measures the reflection of a surface using an infrared light.
|
||||
@@ -364,7 +399,7 @@ class InfraredSensor:
|
||||
100% (high reflection).
|
||||
"""
|
||||
|
||||
def distance(self) -> int:
|
||||
def distance(self) -> MaybeAwaitableInt:
|
||||
"""distance() -> int: %
|
||||
|
||||
Measures the relative distance between the sensor and an object
|
||||
@@ -374,7 +409,7 @@ class InfraredSensor:
|
||||
Distance ranging from 0% (closest) to 100% (farthest).
|
||||
"""
|
||||
|
||||
def count(self) -> int:
|
||||
def count(self) -> MaybeAwaitableInt:
|
||||
"""count() -> int
|
||||
|
||||
Counts the number of objects that have passed by the sensor.
|
||||
@@ -415,5 +450,10 @@ if TYPE_CHECKING:
|
||||
del Button
|
||||
del Color
|
||||
del Direction
|
||||
del MaybeAwaitable
|
||||
del MaybeAwaitableBool
|
||||
del MaybeAwaitableFloat
|
||||
del MaybeAwaitableInt
|
||||
del MaybeAwaitableTuple
|
||||
del Number
|
||||
del Port
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2022 The Pybricks Authors
|
||||
# Copyright (c) 2018-2023 The Pybricks Authors
|
||||
|
||||
"""Robotics module for the Pybricks API."""
|
||||
|
||||
@@ -11,7 +11,7 @@ from . import _common
|
||||
from .parameters import Stop
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._common import Motor
|
||||
from ._common import Motor, MaybeAwaitable
|
||||
from .parameters import Number
|
||||
|
||||
|
||||
@@ -86,6 +86,12 @@ class DriveBase:
|
||||
|
||||
Stops the robot by letting the motors spin freely."""
|
||||
|
||||
def brake(self) -> None:
|
||||
"""brake()
|
||||
|
||||
Stops the robot by passively braking the motors.
|
||||
"""
|
||||
|
||||
def distance(self) -> int:
|
||||
"""distance() -> int: mm
|
||||
|
||||
@@ -161,7 +167,7 @@ class DriveBase:
|
||||
|
||||
def straight(
|
||||
self, distance: Number, then: Stop = Stop.HOLD, wait: bool = True
|
||||
) -> None:
|
||||
) -> MaybeAwaitable:
|
||||
"""straight(distance, then=Stop.HOLD, wait=True)
|
||||
|
||||
Drives straight for a given distance and then stops.
|
||||
@@ -173,7 +179,9 @@ class DriveBase:
|
||||
with the rest of the program.
|
||||
"""
|
||||
|
||||
def turn(self, angle: Number, then: Stop = Stop.HOLD, wait: bool = True) -> None:
|
||||
def turn(
|
||||
self, angle: Number, then: Stop = Stop.HOLD, wait: bool = True
|
||||
) -> MaybeAwaitable:
|
||||
"""turn(angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Turns in place by a given angle and then stops.
|
||||
@@ -187,7 +195,7 @@ class DriveBase:
|
||||
|
||||
def curve(
|
||||
self, radius: Number, angle: Number, then: Stop = Stop.HOLD, wait: bool = True
|
||||
) -> None:
|
||||
) -> MaybeAwaitable:
|
||||
"""curve(radius, angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Drives an arc along a circle of a given radius, by a given angle.
|
||||
@@ -221,15 +229,21 @@ class DriveBase:
|
||||
``True`` if the drivebase is stalled, ``False`` if not.
|
||||
"""
|
||||
|
||||
def use_gyro(self, use_gyro: bool) -> None:
|
||||
"""use_gyro(use_gyro)
|
||||
|
||||
class GyroDriveBase(DriveBase):
|
||||
"""A robotic vehicle with two powered wheels and an optional support
|
||||
wheel or caster. It measures the heading using the hub's built-in gyroscope,
|
||||
which can make turning and driving straight more accurate."""
|
||||
Choose ``True`` to use the gyro sensor for turning and driving
|
||||
straight. Choose ``False`` to rely only on the motor's built-in
|
||||
rotation sensors.
|
||||
|
||||
Arguments:
|
||||
use_gyro (bool): ``True`` to enable, ``False`` to disable.
|
||||
"""
|
||||
|
||||
|
||||
# HACK: hide from jedi
|
||||
if TYPE_CHECKING:
|
||||
del Motor
|
||||
del Number
|
||||
del MaybeAwaitable
|
||||
del Stop
|
||||
|
||||
+69
-2
@@ -5,13 +5,14 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Sequence, Tuple, overload
|
||||
from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple, overload, Coroutine
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._common import MaybeAwaitable, MaybeAwaitableTuple
|
||||
from .parameters import Number
|
||||
|
||||
|
||||
def wait(time: Number) -> None:
|
||||
def wait(time: Number) -> MaybeAwaitable:
|
||||
"""wait(time)
|
||||
|
||||
Pauses the user program for a specified amount of time.
|
||||
@@ -222,6 +223,72 @@ def cross(a: Matrix, b: Matrix) -> Matrix:
|
||||
"""
|
||||
|
||||
|
||||
def read_input_byte() -> Optional[int]:
|
||||
"""
|
||||
read_input_byte() -> int | None
|
||||
|
||||
Reads one byte from standard input without blocking.
|
||||
|
||||
Returns:
|
||||
The numeric value of the byte read or ``None`` if no data is available.
|
||||
"""
|
||||
|
||||
|
||||
def hub_menu(*symbols: int | str) -> int | str:
|
||||
"""
|
||||
hub_menu(symbol1, symbol2, ...) -> int | str
|
||||
|
||||
Shows a menu on the hub display and waits for the user to select an item
|
||||
using the buttons. Can be used in your own menu-program that lets you
|
||||
choose which of your other programs to run.
|
||||
|
||||
Note that this is just a convenience function that combines the display,
|
||||
buttons, and waits to make a simple menu. This means that it can be used
|
||||
anywhere in a program, not just at the start.
|
||||
|
||||
Arguments:
|
||||
symbol1 (int or str): The first symbol to show in the menu.
|
||||
symbol2 (int or str): The second symbol, and so on...
|
||||
|
||||
Returns:
|
||||
The selected symbol.
|
||||
"""
|
||||
|
||||
|
||||
def multitask(*coroutines: Coroutine, race=False) -> MaybeAwaitableTuple:
|
||||
"""
|
||||
multitask(coroutine1, coroutine2, ...) -> Tuple
|
||||
|
||||
Runs multiple coroutines concurrently. This creates a new coroutine that
|
||||
can be used like any other, including in another ``multitask`` statement.
|
||||
|
||||
Arguments:
|
||||
coroutines (coroutine, coroutine, ...): One or more coroutines to run
|
||||
in parallel.
|
||||
race (bool): Choose ``False`` to wait for all coroutines to finish.
|
||||
Choose ``True`` to wait for one coroutine to finish and then
|
||||
cancel the others, as if it's a "race".
|
||||
|
||||
Returns:
|
||||
Tuple of the return values of each coroutine. Unfinished coroutines
|
||||
will have ``None`` as their return value.
|
||||
"""
|
||||
|
||||
|
||||
def run_task(coroutine: Coroutine):
|
||||
"""
|
||||
run_task(coroutine)
|
||||
|
||||
Runs a coroutine from start to finish while blocking the rest of the
|
||||
program. This is used primarily to run the main coroutine of a program.
|
||||
|
||||
Arguments:
|
||||
coroutine (coroutine): The main coroutine to run.
|
||||
"""
|
||||
|
||||
|
||||
# HACK: hide from jedi
|
||||
if TYPE_CHECKING:
|
||||
del Number
|
||||
del MaybeAwaitable
|
||||
del MaybeAwaitableTuple
|
||||
|
||||
+206
-1
@@ -23,6 +23,7 @@ from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Hashable,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
@@ -33,6 +34,7 @@ from typing import (
|
||||
SupportsFloat,
|
||||
SupportsInt,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
@@ -55,6 +57,8 @@ _int = int
|
||||
_str = str
|
||||
_type = type
|
||||
|
||||
_Self = TypeVar("_Self")
|
||||
|
||||
# Functions and types
|
||||
|
||||
|
||||
@@ -1084,6 +1088,207 @@ def round(*args):
|
||||
"""
|
||||
|
||||
|
||||
class set:
|
||||
@overload
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, iterable: Iterable[Hashable]) -> None:
|
||||
...
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""
|
||||
set()
|
||||
set(iterable)
|
||||
|
||||
Creates a new set.
|
||||
|
||||
With no arguments, creates a new empty set, otherwise creates a set
|
||||
containing unique items of *iterable*.
|
||||
|
||||
Sets can also be created using a set literal::
|
||||
|
||||
my_set = {1, 2, 3}
|
||||
|
||||
Elements of a set must be hashable. There are only a few types, like
|
||||
:class:`list` that aren't hashable.
|
||||
|
||||
Args:
|
||||
iterable: An iterable of hashable objects.
|
||||
"""
|
||||
|
||||
def copy(self: _Self) -> _Self:
|
||||
"""
|
||||
copy() -> set
|
||||
|
||||
Returns a shallow copy of the set.
|
||||
|
||||
Returns:
|
||||
A new set.
|
||||
"""
|
||||
|
||||
def difference(self: _Self, *others: set) -> _Self:
|
||||
"""
|
||||
difference(other1, other2, ...) -> set
|
||||
|
||||
Returns a new set with elements that are not in any of the other sets.
|
||||
|
||||
The difference can also be computed using the ``-`` operator::
|
||||
|
||||
diff = s - other
|
||||
|
||||
Args:
|
||||
others: 1 or more other sets.
|
||||
|
||||
Returns:
|
||||
A new set.
|
||||
"""
|
||||
|
||||
def intersection(self: _Self, *others: set) -> _Self:
|
||||
"""
|
||||
intersection(other1, other2, ...) -> set
|
||||
|
||||
Returns a new set with elements that are common between this set and
|
||||
all other sets.
|
||||
|
||||
The intersection can also be computed using the ``&`` operator::
|
||||
|
||||
intersect = s & other
|
||||
|
||||
Args:
|
||||
others: 1 or more other sets.
|
||||
|
||||
Returns:
|
||||
A new set.
|
||||
"""
|
||||
|
||||
def isdisjoint(self, other: set) -> bool:
|
||||
"""
|
||||
isdisjoint(other) -> bool
|
||||
|
||||
Tests if a set and *other* have no elements in common.
|
||||
|
||||
Args:
|
||||
other: Another set.
|
||||
|
||||
Returns:
|
||||
``True`` if this set has no elements in common with *other*,
|
||||
otherwise ``False``.
|
||||
"""
|
||||
|
||||
def issubset(self, other: set) -> bool:
|
||||
"""
|
||||
issubset(other) -> bool
|
||||
|
||||
Tests if a set is a subset of *other*.
|
||||
|
||||
The test can also be performed using using the ``<=`` operator::
|
||||
|
||||
if s <= other:
|
||||
# s is subset of other
|
||||
...
|
||||
|
||||
Args:
|
||||
other: Another set.
|
||||
|
||||
Returns:
|
||||
``True`` if this set is a subset of *other*, otherwise ``False``.
|
||||
"""
|
||||
|
||||
def issuperset(self, other: set) -> bool:
|
||||
"""
|
||||
issuperset(other) -> bool
|
||||
|
||||
Tests if a set is a superset of *other*.
|
||||
|
||||
The test can also be performed using using the ``>=`` operator::
|
||||
|
||||
if s >= other:
|
||||
# s is superset of other
|
||||
...
|
||||
|
||||
Args:
|
||||
other: Another set.
|
||||
|
||||
Returns:
|
||||
``True`` if this set is a superset of *other*, otherwise ``False``.
|
||||
"""
|
||||
|
||||
def symmetric_difference(self: _Self, other: set) -> _Self:
|
||||
"""
|
||||
symmetric_difference(other) -> bool
|
||||
|
||||
Returns a new set with elements in one set or the other but not in both.
|
||||
|
||||
The symmetric difference can also be computed using the ``^`` operator::
|
||||
|
||||
diff = s ^ other
|
||||
|
||||
Args:
|
||||
other: Another set.
|
||||
|
||||
Returns:
|
||||
A new set.
|
||||
"""
|
||||
|
||||
def union(self: _Self, *others: set) -> _Self:
|
||||
"""
|
||||
union(other1, other2, ...) -> set
|
||||
|
||||
Returns a new set with elements from this set and all other sets.
|
||||
|
||||
The union can also be computed using the ``|`` operator::
|
||||
|
||||
u = s | other
|
||||
|
||||
Args:
|
||||
others: 1 or more other sets.
|
||||
|
||||
Returns:
|
||||
A new set.
|
||||
"""
|
||||
|
||||
def __contains__(self, item: Hashable) -> bool:
|
||||
...
|
||||
|
||||
def __len__(self) -> int:
|
||||
...
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
...
|
||||
|
||||
def __gt__(self, other: set) -> bool:
|
||||
...
|
||||
|
||||
def __lt__(self, other: set) -> bool:
|
||||
...
|
||||
|
||||
def __ge__(self, other: set) -> bool:
|
||||
...
|
||||
|
||||
def __le__(self, other: set) -> bool:
|
||||
...
|
||||
|
||||
def __eq__(self, other: set) -> bool:
|
||||
...
|
||||
|
||||
def __ne__(self, other: set) -> bool:
|
||||
...
|
||||
|
||||
def __sub__(self: _Self, other: set) -> _Self:
|
||||
...
|
||||
|
||||
def __and__(self: _Self, other: set) -> _Self:
|
||||
...
|
||||
|
||||
def __or__(self: _Self, other: set) -> _Self:
|
||||
...
|
||||
|
||||
def __xor__(self: _Self, other: set) -> _Self:
|
||||
...
|
||||
|
||||
|
||||
def setattr(object: Any, name: _str, value: Any) -> None:
|
||||
"""
|
||||
setattr(object, name, value)
|
||||
@@ -1170,7 +1375,7 @@ class str:
|
||||
If no argument is given, this creates an empty ``str`` object.
|
||||
|
||||
Arguments:
|
||||
object: If only this argument is given, this returns the stirng
|
||||
object: If only this argument is given, this returns the string
|
||||
representation of the object.
|
||||
encoding (str): If the first argument is a ``bytearray`` or ``bytes``
|
||||
object and the encoding argument is ``"utf-8"``, this will decode
|
||||
|
||||
Reference in New Issue
Block a user