mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
pybricks: Drop underscores on imports.
Fixes https://github.com/pybricks/pybricks-api/issues/101
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
- Moved remaining type hints from `.pyi` files to the python stub modules, and
|
||||
fixed numerous errors in the type hints throughout.
|
||||
|
||||
## 3.2.0b1-r1 - 2022-06-09
|
||||
|
||||
## Added
|
||||
|
||||
@@ -9,12 +9,12 @@ EV3 DC Motor
|
||||
.. figure:: ../../main/images/rcxmotor.png
|
||||
:width: 40 %
|
||||
|
||||
.. autoclass:: pybricks._common.DCMotor
|
||||
.. autoclass:: pybricks.iodevices.DCMotor
|
||||
:noindex:
|
||||
:no-members:
|
||||
|
||||
.. automethod:: pybricks._common.DCMotor.dc
|
||||
.. automethod:: pybricks.iodevices.DCMotor.dc
|
||||
:noindex:
|
||||
|
||||
.. automethod:: pybricks._common.DCMotor.stop
|
||||
.. automethod:: pybricks.iodevices.DCMotor.stop
|
||||
:noindex:
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
"""Generic cross-platform module for typical devices like lights, displays,
|
||||
speakers, and batteries."""
|
||||
|
||||
from .parameters import Direction, Stop, Button, Port, Color, Side, Number
|
||||
from typing import Union, Iterable, overload, Optional, Tuple, Collection
|
||||
|
||||
from .geometry import Matrix, Axis
|
||||
|
||||
from typing import Union, Iterable, overload, Optional, Tuple, Collection
|
||||
from .parameters import Direction, Stop, Button, Port, Color, Side, Number
|
||||
|
||||
|
||||
class System:
|
||||
@@ -63,12 +62,12 @@ class System:
|
||||
"""
|
||||
|
||||
|
||||
class DCMotor:
|
||||
class CommonDCMotor:
|
||||
"""Generic class to control simple motors without rotation sensors, such
|
||||
as train motors."""
|
||||
|
||||
def __init__(self, port: Port, positive_direction: Direction = Direction.CLOCKWISE):
|
||||
"""DCMotor(port, positive_direction=Direction.CLOCKWISE)
|
||||
"""__init__(port, positive_direction=Direction.CLOCKWISE)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the motor is connected.
|
||||
@@ -290,7 +289,7 @@ class Control:
|
||||
"""
|
||||
|
||||
|
||||
class Motor(DCMotor):
|
||||
class CommonMotor(CommonDCMotor):
|
||||
"""Generic class to control motors with built-in rotation sensors."""
|
||||
|
||||
control = Control()
|
||||
@@ -306,7 +305,7 @@ class Motor(DCMotor):
|
||||
gears: Optional[Union[Collection[int], Collection[Collection[int]]]] = None,
|
||||
reset_angle: bool = True,
|
||||
):
|
||||
"""Motor(port, positive_direction=Direction.CLOCKWISE, gears=None, reset_angle=True)
|
||||
"""__init__(port, positive_direction=Direction.CLOCKWISE, gears=None, reset_angle=True)
|
||||
|
||||
Arguments:
|
||||
port (Port): Port to which the motor is connected.
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
"""LEGO® MINDSTORMS® EV3 motors and sensors."""
|
||||
|
||||
from .parameters import Direction, Port, Color, Button
|
||||
from ._common import Motor as _Motor
|
||||
|
||||
from typing import Optional, Tuple, List
|
||||
|
||||
from ._common import CommonMotor
|
||||
from .parameters import Direction, Port, Color, Button
|
||||
|
||||
class Motor(_Motor):
|
||||
pass
|
||||
|
||||
class Motor(CommonMotor):
|
||||
"""LEGO® MINDSTORMS® EV3 Motor."""
|
||||
|
||||
|
||||
class TouchSensor:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
from typing import Dict, Tuple, Optional, overload
|
||||
|
||||
from ._common import CommonDCMotor
|
||||
from .parameters import Port
|
||||
|
||||
|
||||
@@ -74,6 +75,10 @@ class LUMPDevice:
|
||||
"""
|
||||
|
||||
|
||||
class DCMotor(CommonDCMotor):
|
||||
"""DC Motor for LEGO® MINDSTORMS EV3."""
|
||||
|
||||
|
||||
class Ev3devSensor:
|
||||
"""Read values of an ev3dev-compatible sensor."""
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ..parameters import Color
|
||||
|
||||
from typing import Union, Literal, overload, Optional, Any
|
||||
|
||||
from ..parameters import Color
|
||||
|
||||
|
||||
class Image:
|
||||
"""Object representing a graphics image. This can either be an in-memory
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
from .parameters import Port
|
||||
|
||||
from .iodevices import AnalogSensor
|
||||
from ._common import ColorLight, CommonColorSensor
|
||||
from .iodevices import AnalogSensor
|
||||
|
||||
|
||||
from typing import Callable, Optional, Tuple
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
from typing import Union
|
||||
from enum import Enum as _Enum
|
||||
|
||||
|
||||
from .geometry import Matrix
|
||||
|
||||
Number = Union[int, float]
|
||||
|
||||
|
||||
class _PybricksEnumMeta(type(_Enum)):
|
||||
class _PybricksEnumMeta(type(Enum)):
|
||||
def __dir__(cls):
|
||||
yield "__class__"
|
||||
yield "__name__"
|
||||
@@ -21,7 +22,7 @@ class _PybricksEnumMeta(type(_Enum)):
|
||||
yield member.name
|
||||
|
||||
|
||||
class _PybricksEnum(_Enum, metaclass=_PybricksEnumMeta):
|
||||
class _PybricksEnum(Enum, metaclass=_PybricksEnumMeta):
|
||||
def __dir__(self):
|
||||
yield "__class__"
|
||||
for member in type(self):
|
||||
|
||||
+23
-24
@@ -6,24 +6,23 @@
|
||||
from typing import Collection, Optional, Union, overload, Tuple
|
||||
|
||||
from ._common import (
|
||||
Keypad as _Keypad,
|
||||
DCMotor as _DCMotor,
|
||||
ColorLight as _ColorLight,
|
||||
Motor as _Motor,
|
||||
LightArray as _LightArray,
|
||||
CommonColorSensor,
|
||||
AmbientColorSensor,
|
||||
ColorLight,
|
||||
CommonColorSensor,
|
||||
CommonDCMotor,
|
||||
CommonMotor,
|
||||
Keypad,
|
||||
LightArray,
|
||||
)
|
||||
|
||||
from .parameters import Button as _Button, Color, Direction, Port
|
||||
from .parameters import Button, Color, Direction, Port
|
||||
|
||||
|
||||
class DCMotor(_DCMotor):
|
||||
pass
|
||||
class DCMotor(CommonDCMotor):
|
||||
"""LEGO® Powered Up motor without rotation sensors."""
|
||||
|
||||
|
||||
class Motor(_Motor):
|
||||
"""Generic class to control motors with built-in rotation sensors."""
|
||||
class Motor(CommonMotor):
|
||||
"""LEGO® Powered Up motor with rotation sensors."""
|
||||
|
||||
def reset_angle(self, angle: Optional[int]) -> None:
|
||||
"""reset_angle(angle=None)
|
||||
@@ -41,16 +40,16 @@ class Motor(_Motor):
|
||||
class Remote:
|
||||
"""LEGO® Powered Up Bluetooth Remote Control."""
|
||||
|
||||
light = _ColorLight()
|
||||
buttons = _Keypad(
|
||||
light = ColorLight()
|
||||
buttons = Keypad(
|
||||
(
|
||||
_Button.LEFT_MINUS,
|
||||
_Button.RIGHT_MINUS,
|
||||
_Button.LEFT,
|
||||
_Button.CENTER,
|
||||
_Button.RIGHT,
|
||||
_Button.LEFT_PLUS,
|
||||
_Button.RIGHT_PLUS,
|
||||
Button.LEFT_MINUS,
|
||||
Button.RIGHT_MINUS,
|
||||
Button.LEFT,
|
||||
Button.CENTER,
|
||||
Button.RIGHT,
|
||||
Button.LEFT_PLUS,
|
||||
Button.RIGHT_PLUS,
|
||||
)
|
||||
)
|
||||
addresss: Union[str, None]
|
||||
@@ -113,7 +112,7 @@ class TiltSensor:
|
||||
class ColorDistanceSensor(CommonColorSensor):
|
||||
"""LEGO® Powered Up Color and Distance Sensor."""
|
||||
|
||||
light = _ColorLight()
|
||||
light = ColorLight()
|
||||
|
||||
def distance(self) -> int:
|
||||
"""distance() -> int: %
|
||||
@@ -156,13 +155,13 @@ class PFMotor(DCMotor):
|
||||
class ColorSensor(AmbientColorSensor):
|
||||
"""LEGO® SPIKE Color Sensor."""
|
||||
|
||||
lights = _LightArray(3)
|
||||
lights = LightArray(3)
|
||||
|
||||
|
||||
class UltrasonicSensor:
|
||||
"""LEGO® SPIKE Color Sensor."""
|
||||
|
||||
lights = _LightArray(3)
|
||||
lights = LightArray(3)
|
||||
|
||||
def __init__(self, port: Port):
|
||||
"""UltrasonicSensor(port)
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
|
||||
"""Robotics module for the Pybricks API."""
|
||||
|
||||
from ._common import Control, Motor
|
||||
|
||||
from .parameters import Stop as _Stop, Number
|
||||
|
||||
from typing import Tuple, Optional, overload
|
||||
|
||||
from ._common import Control, CommonMotor as Motor
|
||||
from .parameters import Stop, Number
|
||||
|
||||
|
||||
class DriveBase:
|
||||
"""A robotic vehicle with two powered wheels and an optional support
|
||||
@@ -143,7 +142,7 @@ class DriveBase:
|
||||
deceleration of the robot.
|
||||
"""
|
||||
|
||||
def straight(self, distance, then=_Stop.HOLD, wait=True) -> None:
|
||||
def straight(self, distance, then=Stop.HOLD, wait=True) -> None:
|
||||
"""straight(distance, then=Stop.HOLD, wait=True)
|
||||
|
||||
Drives straight for a given distance and then stops.
|
||||
@@ -155,7 +154,7 @@ class DriveBase:
|
||||
with the rest of the program.
|
||||
"""
|
||||
|
||||
def turn(self, angle, then=_Stop.HOLD, wait=True) -> None:
|
||||
def turn(self, angle, then=Stop.HOLD, wait=True) -> None:
|
||||
"""turn(angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Turns in place by a given angle and then stops.
|
||||
@@ -167,7 +166,7 @@ class DriveBase:
|
||||
with the rest of the program.
|
||||
"""
|
||||
|
||||
def curve(self, radius, angle, then=_Stop.HOLD, wait=True) -> None:
|
||||
def curve(self, radius, angle, then=Stop.HOLD, wait=True) -> None:
|
||||
"""curve(radius, angle, then=Stop.HOLD, wait=True)
|
||||
|
||||
Drives an arc along a circle of a given radius, by a given angle.
|
||||
|
||||
Reference in New Issue
Block a user