From dca851857550cbea25020a3f431308825fef8e81 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 28 Dec 2020 16:21:56 -0600 Subject: [PATCH] pybricks: add type hints for v2 This adds PEP 561 style type hints for Pybricks v2 (just EV3). --- .vscode/settings.json | 2 + poetry.lock | 439 ++++++++++++++++++++++++++------------ pybricks/_common.pyi | 111 ++++++++++ pybricks/ev3devices.pyi | 38 ++++ pybricks/hubs.pyi | 12 ++ pybricks/iodevices.pyi | 37 ++++ pybricks/media/ev3dev.pyi | 232 ++++++++++++++++++++ pybricks/media/py.typed | 0 pybricks/messaging.pyi | 49 +++++ pybricks/nxtdevices.pyi | 51 +++++ pybricks/parameters.pyi | 44 ++++ pybricks/py.typed | 0 pybricks/robotics.pyi | 34 +++ pybricks/tools.pyi | 23 ++ pyproject.toml | 8 +- setup.cfg | 2 +- 16 files changed, 942 insertions(+), 140 deletions(-) create mode 100644 pybricks/_common.pyi create mode 100644 pybricks/ev3devices.pyi create mode 100644 pybricks/hubs.pyi create mode 100644 pybricks/iodevices.pyi create mode 100644 pybricks/media/ev3dev.pyi create mode 100644 pybricks/media/py.typed create mode 100644 pybricks/messaging.pyi create mode 100644 pybricks/nxtdevices.pyi create mode 100644 pybricks/parameters.pyi create mode 100644 pybricks/py.typed create mode 100644 pybricks/robotics.pyi create mode 100644 pybricks/tools.pyi diff --git a/.vscode/settings.json b/.vscode/settings.json index 83a945a..402390a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,10 @@ { "python.pythonPath": "${workspaceFolder}/.venv", + "python.formatting.provider": "black", "python.linting.pycodestyleEnabled": false, "python.linting.flake8Enabled": true, "python.linting.enabled": true, + "python.languageServer": "Pylance", "files.associations": {"*.inc": "restructuredtext"}, "restructuredtext.confPath": "${workspaceFolder}/doc/api", "spellright.language": [ diff --git a/poetry.lock b/poetry.lock index 9b9791f..4e15922 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,54 +1,91 @@ [[package]] -category = "dev" -description = "A configurable sidebar-enabled Sphinx theme" name = "alabaster" +version = "0.7.12" +description = "A configurable sidebar-enabled Sphinx theme" +category = "dev" optional = false python-versions = "*" -version = "0.7.12" [[package]] +name = "appdirs" +version = "1.4.4" +description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" -description = "Internationalization utilities" +optional = false +python-versions = "*" + +[[package]] name = "babel" +version = "2.8.0" +description = "Internationalization utilities" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "2.8.0" [package.dependencies] pytz = ">=2015.7" [[package]] +name = "black" +version = "20.8b1" +description = "The uncompromising code formatter." category = "dev" -description = "Python package for providing Mozilla's CA Bundle." +optional = false +python-versions = ">=3.6" + +[package.dependencies] +appdirs = "*" +click = ">=7.1.2" +mypy-extensions = ">=0.4.3" +pathspec = ">=0.6,<1" +regex = ">=2020.1.8" +toml = ">=0.10.1" +typed-ast = ">=1.4.0" +typing-extensions = ">=3.7.4" + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] + +[[package]] name = "certifi" -optional = false -python-versions = "*" version = "2019.11.28" - -[[package]] +description = "Python package for providing Mozilla's CA Bundle." category = "dev" -description = "Universal encoding detector for Python 2 and 3" -name = "chardet" optional = false python-versions = "*" -version = "3.0.4" [[package]] +name = "chardet" +version = "3.0.4" +description = "Universal encoding detector for Python 2 and 3" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "click" +version = "7.1.2" +description = "Composable command line interface toolkit" category = "dev" -description = "Cross-platform colored terminal text." -marker = "sys_platform == \"win32\"" -name = "colorama" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "0.4.3" [[package]] +name = "colorama" +version = "0.4.3" +description = "Cross-platform colored terminal text." category = "dev" -description = "Style checker for Sphinx (or other) RST documentation" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] name = "doc8" +version = "0.8.0" +description = "Style checker for Sphinx (or other) RST documentation" +category = "dev" optional = false python-versions = "*" -version = "0.8.0" [package.dependencies] chardet = "*" @@ -58,28 +95,28 @@ six = "*" stevedore = "*" [[package]] -category = "dev" -description = "Docutils -- Python Documentation Utilities" name = "docutils" +version = "0.16" +description = "Docutils -- Python Documentation Utilities" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "0.16" [[package]] -category = "dev" -description = "Discover and load entry points from installed packages." name = "entrypoints" +version = "0.3" +description = "Discover and load entry points from installed packages." +category = "dev" optional = false python-versions = ">=2.7" -version = "0.3" [[package]] -category = "dev" -description = "the modular source code checker: pep8, pyflakes and co" name = "flake8" +version = "3.7.9" +description = "the modular source code checker: pep8, pyflakes and co" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "3.7.9" [package.dependencies] entrypoints = ">=0.3.0,<0.4.0" @@ -88,28 +125,28 @@ pycodestyle = ">=2.5.0,<2.6.0" pyflakes = ">=2.1.0,<2.2.0" [[package]] -category = "dev" -description = "Internationalized Domain Names in Applications (IDNA)" name = "idna" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.9" - -[[package]] +description = "Internationalized Domain Names in Applications (IDNA)" category = "dev" -description = "Getting image size from png/jpeg/jpeg2000/gif file" -name = "imagesize" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "1.2.0" [[package]] +name = "imagesize" +version = "1.2.0" +description = "Getting image size from png/jpeg/jpeg2000/gif file" category = "dev" -description = "A very fast and expressive template engine." +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] name = "jinja2" +version = "2.11.1" +description = "A very fast and expressive template engine." +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "2.11.1" [package.dependencies] MarkupSafe = ">=0.23" @@ -118,88 +155,112 @@ MarkupSafe = ">=0.23" i18n = ["Babel (>=0.8)"] [[package]] -category = "dev" -description = "Safely add untrusted strings to HTML/XML markup." name = "markupsafe" +version = "1.1.1" +description = "Safely add untrusted strings to HTML/XML markup." +category = "dev" optional = false python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" -version = "1.1.1" [[package]] -category = "dev" -description = "McCabe checker, plugin for flake8" name = "mccabe" +version = "0.6.1" +description = "McCabe checker, plugin for flake8" +category = "dev" optional = false python-versions = "*" -version = "0.6.1" [[package]] +name = "mypy-extensions" +version = "0.4.3" +description = "Experimental type system extensions for programs checked with the mypy typechecker." category = "dev" -description = "Core utilities for Python packages" +optional = false +python-versions = "*" + +[[package]] name = "packaging" +version = "20.3" +description = "Core utilities for Python packages" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "20.3" [package.dependencies] pyparsing = ">=2.0.2" six = "*" [[package]] +name = "pathspec" +version = "0.8.1" +description = "Utility library for gitignore style pattern matching of file paths." category = "dev" -description = "Python Build Reasonableness" -name = "pbr" -optional = false -python-versions = "*" -version = "5.4.4" - -[[package]] -category = "dev" -description = "Python style guide checker" -name = "pycodestyle" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "2.5.0" - -[[package]] -category = "dev" -description = "passive checker of Python programs" -name = "pyflakes" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "2.1.1" - -[[package]] -category = "dev" -description = "Pygments is a syntax highlighting package written in Python." -name = "pygments" -optional = false -python-versions = ">=3.5" -version = "2.6.1" - -[[package]] -category = "dev" -description = "Python parsing module" -name = "pyparsing" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -version = "2.4.6" - -[[package]] -category = "dev" -description = "World timezone definitions, modern and historical" -name = "pytz" -optional = false -python-versions = "*" -version = "2019.3" - -[[package]] -category = "dev" -description = "Python HTTP for Humans." -name = "requests" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "pbr" +version = "5.4.4" +description = "Python Build Reasonableness" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "pycodestyle" +version = "2.5.0" +description = "Python style guide checker" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "pyflakes" +version = "2.1.1" +description = "passive checker of Python programs" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "pygments" +version = "2.6.1" +description = "Pygments is a syntax highlighting package written in Python." +category = "dev" +optional = false +python-versions = ">=3.5" + +[[package]] +name = "pyparsing" +version = "2.4.6" +description = "Python parsing module" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "pytz" +version = "2019.3" +description = "World timezone definitions, modern and historical" +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "regex" +version = "2020.11.13" +description = "Alternative regular expression module, to replace re." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "requests" version = "2.23.0" +description = "Python HTTP for Humans." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.dependencies] certifi = ">=2017.4.17" @@ -212,51 +273,50 @@ security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"] socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"] [[package]] -category = "dev" -description = "reStructuredText linter" name = "restructuredtext-lint" +version = "1.3.0" +description = "reStructuredText linter" +category = "dev" optional = false python-versions = "*" -version = "1.3.0" [package.dependencies] docutils = ">=0.11,<1.0" [[package]] -category = "dev" -description = "Python 2 and 3 compatibility utilities" name = "six" +version = "1.14.0" +description = "Python 2 and 3 compatibility utilities" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -version = "1.14.0" [[package]] -category = "dev" -description = "This package provides 26 stemmers for 25 languages generated from Snowball algorithms." name = "snowballstemmer" +version = "2.0.0" +description = "This package provides 26 stemmers for 25 languages generated from Snowball algorithms." +category = "dev" optional = false python-versions = "*" -version = "2.0.0" [[package]] -category = "dev" -description = "Python documentation generator" name = "sphinx" +version = "1.7.9" +description = "Python documentation generator" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "1.7.9" [package.dependencies] -Jinja2 = ">=2.3" -Pygments = ">=2.0" alabaster = ">=0.7,<0.8" babel = ">=1.3,<2.0 || >2.0" -colorama = ">=0.3.5" +colorama = {version = ">=0.3.5", markers = "sys_platform == \"win32\""} docutils = ">=0.11" imagesize = "*" +Jinja2 = ">=2.3" packaging = "*" +Pygments = ">=2.0" requests = ">=2.0.0" -setuptools = "*" six = ">=1.5" snowballstemmer = ">=1.1" sphinxcontrib-websupport = "*" @@ -266,66 +326,82 @@ test = ["mock", "pytest", "pytest-cov", "html5lib", "flake8 (>=3.5.0)", "flake8- websupport = ["sqlalchemy (>=0.9)", "whoosh (>=2.0)"] [[package]] -category = "dev" -description = "Read the Docs theme for Sphinx" name = "sphinx-rtd-theme" +version = "0.4.3" +description = "Read the Docs theme for Sphinx" +category = "dev" optional = false python-versions = "*" -version = "0.4.3" [package.dependencies] sphinx = "*" [[package]] -category = "dev" -description = "Sphinx \"contentui\" extension" name = "sphinxcontrib-contentui" +version = "0.2.2" +description = "Sphinx \"contentui\" extension" +category = "dev" optional = false python-versions = "*" -version = "0.2.2" [package.dependencies] Sphinx = ">=1.0" [[package]] -category = "dev" -description = "Sphinx API for Web Apps" name = "sphinxcontrib-websupport" +version = "1.2.0" +description = "Sphinx API for Web Apps" +category = "dev" optional = false python-versions = ">=3.5" -version = "1.2.0" [package.extras] lint = ["flake8"] test = ["pytest", "sqlalchemy", "whoosh", "sphinx"] [[package]] -category = "dev" -description = "Manage dynamic plugins for Python applications" name = "stevedore" +version = "1.32.0" +description = "Manage dynamic plugins for Python applications" +category = "dev" optional = false python-versions = "*" -version = "1.32.0" [package.dependencies] pbr = ">=2.0.0,<2.1.0 || >2.1.0" six = ">=1.10.0" [[package]] -category = "dev" -description = "Python Library for Tom's Obvious, Minimal Language" name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "dev" optional = false -python-versions = "*" -version = "0.10.0" +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] +name = "typed-ast" +version = "1.4.1" +description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" -description = "HTTP library with thread-safe connection pooling, file post, and more." +optional = false +python-versions = "*" + +[[package]] +name = "typing-extensions" +version = "3.7.4.3" +description = "Backported and Experimental Type Hints for Python 3.5+" +category = "dev" +optional = false +python-versions = "*" + +[[package]] name = "urllib3" +version = "1.25.8" +description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" -version = "1.25.8" [package.extras] brotli = ["brotlipy (>=0.6.0)"] @@ -333,18 +409,27 @@ secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "cer socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"] [metadata] -content-hash = "4bb3b4633264fced6ec76a562fef02081becb8d883b5f81f63d5e125a33eaa12" -python-versions = "^3.5" +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "8f38e4f82e091b428f68f7b905366d3a0cccbff71f12c10026e2eec7eb8a4774" [metadata.files] alabaster = [ {file = "alabaster-0.7.12-py2.py3-none-any.whl", hash = "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359"}, {file = "alabaster-0.7.12.tar.gz", hash = "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02"}, ] +appdirs = [ + {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, + {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, +] babel = [ {file = "Babel-2.8.0-py2.py3-none-any.whl", hash = "sha256:d670ea0b10f8b723672d3a6abeb87b565b244da220d76b4dba1b66269ec152d4"}, {file = "Babel-2.8.0.tar.gz", hash = "sha256:1aac2ae2d0d8ea368fa90906567f5c08463d98ade155c0c4bfedd6a0f7160e38"}, ] +black = [ + {file = "black-20.8b1-py3-none-any.whl", hash = "sha256:70b62ef1527c950db59062cda342ea224d772abdf6adc58b86a45421bab20a6b"}, + {file = "black-20.8b1.tar.gz", hash = "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"}, +] certifi = [ {file = "certifi-2019.11.28-py2.py3-none-any.whl", hash = "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3"}, {file = "certifi-2019.11.28.tar.gz", hash = "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"}, @@ -353,6 +438,10 @@ chardet = [ {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"}, {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"}, ] +click = [ + {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, + {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, +] colorama = [ {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, @@ -424,10 +513,18 @@ 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-20.3-py2.py3-none-any.whl", hash = "sha256:82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752"}, {file = "packaging-20.3.tar.gz", hash = "sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"}, ] +pathspec = [ + {file = "pathspec-0.8.1-py2.py3-none-any.whl", hash = "sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d"}, + {file = "pathspec-0.8.1.tar.gz", hash = "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd"}, +] pbr = [ {file = "pbr-5.4.4-py2.py3-none-any.whl", hash = "sha256:61aa52a0f18b71c5cc58232d2cf8f8d09cd67fcad60b742a60124cb8d6951488"}, {file = "pbr-5.4.4.tar.gz", hash = "sha256:139d2625547dbfa5fb0b81daebb39601c478c21956dc57e2e07b74450a8c506b"}, @@ -452,6 +549,49 @@ pytz = [ {file = "pytz-2019.3-py2.py3-none-any.whl", hash = "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d"}, {file = "pytz-2019.3.tar.gz", hash = "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"}, ] +regex = [ + {file = "regex-2020.11.13-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:8b882a78c320478b12ff024e81dc7d43c1462aa4a3341c754ee65d857a521f85"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:a63f1a07932c9686d2d416fb295ec2c01ab246e89b4d58e5fa468089cab44b70"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:6e4b08c6f8daca7d8f07c8d24e4331ae7953333dbd09c648ed6ebd24db5a10ee"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:bba349276b126947b014e50ab3316c027cac1495992f10e5682dc677b3dfa0c5"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:56e01daca75eae420bce184edd8bb341c8eebb19dd3bce7266332258f9fb9dd7"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:6a8ce43923c518c24a2579fda49f093f1397dad5d18346211e46f134fc624e31"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:1ab79fcb02b930de09c76d024d279686ec5d532eb814fd0ed1e0051eb8bd2daa"}, + {file = "regex-2020.11.13-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:9801c4c1d9ae6a70aeb2128e5b4b68c45d4f0af0d1535500884d644fa9b768c6"}, + {file = "regex-2020.11.13-cp36-cp36m-win32.whl", hash = "sha256:49cae022fa13f09be91b2c880e58e14b6da5d10639ed45ca69b85faf039f7a4e"}, + {file = "regex-2020.11.13-cp36-cp36m-win_amd64.whl", hash = "sha256:749078d1eb89484db5f34b4012092ad14b327944ee7f1c4f74d6279a6e4d1884"}, + {file = "regex-2020.11.13-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b2f4007bff007c96a173e24dcda236e5e83bde4358a557f9ccf5e014439eae4b"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:38c8fd190db64f513fe4e1baa59fed086ae71fa45083b6936b52d34df8f86a88"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5862975b45d451b6db51c2e654990c1820523a5b07100fc6903e9c86575202a0"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:262c6825b309e6485ec2493ffc7e62a13cf13fb2a8b6d212f72bd53ad34118f1"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:bafb01b4688833e099d79e7efd23f99172f501a15c44f21ea2118681473fdba0"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:e32f5f3d1b1c663af7f9c4c1e72e6ffe9a78c03a31e149259f531e0fed826512"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:3bddc701bdd1efa0d5264d2649588cbfda549b2899dc8d50417e47a82e1387ba"}, + {file = "regex-2020.11.13-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:02951b7dacb123d8ea6da44fe45ddd084aa6777d4b2454fa0da61d569c6fa538"}, + {file = "regex-2020.11.13-cp37-cp37m-win32.whl", hash = "sha256:0d08e71e70c0237883d0bef12cad5145b84c3705e9c6a588b2a9c7080e5af2a4"}, + {file = "regex-2020.11.13-cp37-cp37m-win_amd64.whl", hash = "sha256:1fa7ee9c2a0e30405e21031d07d7ba8617bc590d391adfc2b7f1e8b99f46f444"}, + {file = "regex-2020.11.13-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:baf378ba6151f6e272824b86a774326f692bc2ef4cc5ce8d5bc76e38c813a55f"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e3faaf10a0d1e8e23a9b51d1900b72e1635c2d5b0e1bea1c18022486a8e2e52d"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:2a11a3e90bd9901d70a5b31d7dd85114755a581a5da3fc996abfefa48aee78af"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d1ebb090a426db66dd80df8ca85adc4abfcbad8a7c2e9a5ec7513ede522e0a8f"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:b2b1a5ddae3677d89b686e5c625fc5547c6e492bd755b520de5332773a8af06b"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:2c99e97d388cd0a8d30f7c514d67887d8021541b875baf09791a3baad48bb4f8"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:c084582d4215593f2f1d28b65d2a2f3aceff8342aa85afd7be23a9cad74a0de5"}, + {file = "regex-2020.11.13-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:a3d748383762e56337c39ab35c6ed4deb88df5326f97a38946ddd19028ecce6b"}, + {file = "regex-2020.11.13-cp38-cp38-win32.whl", hash = "sha256:7913bd25f4ab274ba37bc97ad0e21c31004224ccb02765ad984eef43e04acc6c"}, + {file = "regex-2020.11.13-cp38-cp38-win_amd64.whl", hash = "sha256:6c54ce4b5d61a7129bad5c5dc279e222afd00e721bf92f9ef09e4fae28755683"}, + {file = "regex-2020.11.13-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1862a9d9194fae76a7aaf0150d5f2a8ec1da89e8b55890b1786b8f88a0f619dc"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux1_i686.whl", hash = "sha256:4902e6aa086cbb224241adbc2f06235927d5cdacffb2425c73e6570e8d862364"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:7a25fcbeae08f96a754b45bdc050e1fb94b95cab046bf56b016c25e9ab127b3e"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:d2d8ce12b7c12c87e41123997ebaf1a5767a5be3ec545f64675388970f415e2e"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:f7d29a6fc4760300f86ae329e3b6ca28ea9c20823df123a2ea8693e967b29917"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:717881211f46de3ab130b58ec0908267961fadc06e44f974466d1887f865bd5b"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:3128e30d83f2e70b0bed9b2a34e92707d0877e460b402faca908c6667092ada9"}, + {file = "regex-2020.11.13-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:8f6a2229e8ad946e36815f2a03386bb8353d4bde368fdf8ca5f0cb97264d3b5c"}, + {file = "regex-2020.11.13-cp39-cp39-win32.whl", hash = "sha256:f8f295db00ef5f8bae530fc39af0b40486ca6068733fb860b42115052206466f"}, + {file = "regex-2020.11.13-cp39-cp39-win_amd64.whl", hash = "sha256:a15f64ae3a027b64496a71ab1f722355e570c3fac5ba2801cafce846bf5af01d"}, + {file = "regex-2020.11.13.tar.gz", hash = "sha256:83d6b356e116ca119db8e7c6fc2983289d87b27b3fac238cfe5dca529d884562"}, +] requests = [ {file = "requests-2.23.0-py2.py3-none-any.whl", hash = "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee"}, {file = "requests-2.23.0.tar.gz", hash = "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6"}, @@ -487,9 +627,36 @@ stevedore = [ {file = "stevedore-1.32.0.tar.gz", hash = "sha256:18afaf1d623af5950cc0f7e75e70f917784c73b652a34a12d90b309451b5500b"}, ] toml = [ - {file = "toml-0.10.0-py2.7.egg", hash = "sha256:f1db651f9657708513243e61e6cc67d101a39bad662eaa9b5546f789338e07a3"}, - {file = "toml-0.10.0-py2.py3-none-any.whl", hash = "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"}, - {file = "toml-0.10.0.tar.gz", hash = "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c"}, + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, +] +typed-ast = [ + {file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3"}, + {file = "typed_ast-1.4.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb"}, + {file = "typed_ast-1.4.1-cp35-cp35m-win32.whl", hash = "sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919"}, + {file = "typed_ast-1.4.1-cp35-cp35m-win_amd64.whl", hash = "sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01"}, + {file = "typed_ast-1.4.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75"}, + {file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652"}, + {file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7"}, + {file = "typed_ast-1.4.1-cp36-cp36m-win32.whl", hash = "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1"}, + {file = "typed_ast-1.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa"}, + {file = "typed_ast-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614"}, + {file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41"}, + {file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b"}, + {file = "typed_ast-1.4.1-cp37-cp37m-win32.whl", hash = "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe"}, + {file = "typed_ast-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355"}, + {file = "typed_ast-1.4.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6"}, + {file = "typed_ast-1.4.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907"}, + {file = "typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d"}, + {file = "typed_ast-1.4.1-cp38-cp38-win32.whl", hash = "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c"}, + {file = "typed_ast-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4"}, + {file = "typed_ast-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34"}, + {file = "typed_ast-1.4.1.tar.gz", hash = "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b"}, +] +typing-extensions = [ + {file = "typing_extensions-3.7.4.3-py2-none-any.whl", hash = "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"}, + {file = "typing_extensions-3.7.4.3-py3-none-any.whl", hash = "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918"}, + {file = "typing_extensions-3.7.4.3.tar.gz", hash = "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c"}, ] urllib3 = [ {file = "urllib3-1.25.8-py2.py3-none-any.whl", hash = "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc"}, diff --git a/pybricks/_common.pyi b/pybricks/_common.pyi new file mode 100644 index 0000000..db0ee0b --- /dev/null +++ b/pybricks/_common.pyi @@ -0,0 +1,111 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import Iterable, List, Optional, Tuple, Union, overload + +from .parameters import Button, Color, Direction, Stop, Port +from .media.ev3dev import SoundFile + +class DCMotor: + def __init__( + self, port: Port, positive_direction: Direction = Direction.CLOCKWISE + ): ... + def dc(self, duty: int) -> None: ... + def stop(self) -> None: ... + def brake(self) -> None: ... + +class Control: + @overload + def limits(self) -> Tuple[int, int, int]: ... + @overload + def limits( + self, + speed: Optional[int] = None, + acceleration: Optional[int] = None, + actuation: Optional[int] = None, + ) -> None: ... + def pid(self) -> Tuple[int, int, int, int, int, int]: ... + @overload + def pid( + self, + kp: Optional[int] = None, + ki: Optional[int] = None, + kd: Optional[int] = None, + integral_range: Optional[int] = None, + integral_rate: Optional[int] = None, + feed_forward: Optional[int] = None, + ) -> None: ... + @overload + def target_tolerances(self) -> Tuple[int, int]: ... + @overload + def target_tolerances( + self, speed: Optional[int] = None, position: Optional[int] = None + ) -> None: ... + @overload + def stall_tolerances(self) -> Tuple[int, int]: ... + @overload + def stall_tolerances( + self, speed: Optional[int] = None, time: Optional[int] = None + ) -> None: ... + def trajectory( + self, + ) -> Tuple[int, int, int, int, int, int, int, int, int, int, int, int]: ... + def stalled(self) -> bool: ... + def done(self) -> bool: ... + +class Motor(DCMotor): + control: Control + def __init__( + self, + port: Port, + positive_direction: Direction = Direction.CLOCKWISE, + gears: Optional[Union[List[int], List[List[int]]]] = None, + ): ... + def angle(self) -> int: ... + def speed(self) -> int: ... + def reset_angle(self, angle: int) -> None: ... + def hold(self) -> None: ... + def run(self, speed: int) -> None: ... + def run_time( + self, speed: int, time: int, then: Stop = Stop.HOLD, wait: bool = True + ) -> None: ... + def run_angle( + self, speed: int, rotation_angle: int, then: Stop = Stop.HOLD, wait: bool = True + ) -> None: ... + def run_target( + self, speed: int, target_angle: int, then: Stop = Stop.HOLD, wait: bool = True + ) -> None: ... + def run_until_stalled( + self, speed: int, then: Stop = Stop.COAST, duty_limit: Optional[int] = None + ) -> int: ... + def track_target(self, target_angle: int) -> None: ... + +class Speaker: + def beep(self, frequency: int = 500, duration: int = 100) -> None: ... + def play_notes(self, notes: Iterable[str], tempo: int = 120) -> None: ... + def play_file(self, file_name: Union[SoundFile, str]) -> None: ... + def say(self, text: str) -> None: ... + def set_speech_options( + self, + language: Optional[str] = None, + voice: Optional[str] = None, + speed: Optional[int] = None, + pitch: Optional[int] = None, + ): ... + def set_volume(self, volume: int, which: str = "_all_") -> None: ... + +class Light: + def on(self, brightness: int = 100) -> None: ... + def off(self) -> None: ... + +class ColorLight: + def on(self, color: Optional[Color]) -> None: ... + def off(self) -> None: ... + def rgb(self, red: int, green: int, blue: int) -> None: ... + +class KeyPad: + def pressed(self) -> List[Button]:... + +class Battery: + def voltage(self) -> int: ... + def current(self) -> int: ... diff --git a/pybricks/ev3devices.pyi b/pybricks/ev3devices.pyi new file mode 100644 index 0000000..157fd86 --- /dev/null +++ b/pybricks/ev3devices.pyi @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import List, Optional, Tuple + +from .parameters import Color, Direction, Port, Button +from ._common import Motor # noqa E402 + +class TouchSensor: + def __init__(self, port: Port): ... + def pressed(self) -> bool: ... + +class ColorSensor: + def __init__(self, port: Port): ... + def color(self) -> Optional[Color]: ... + def ambient(self) -> int: ... + def reflection(self) -> int: ... + def rgb(self) -> Tuple[int, int, int]: ... + +class InfraredSensor: + def __init__(self, port: Port): ... + def distance(self) -> int: ... + def beacon(self, channel: int) -> Tuple[Optional[int], Optional[int]]: ... + def buttons(self, channel: int) -> List[Button]: ... + def keypad(self) -> List[Button]: ... + +class GyroSensor: + def __init__( + self, port: Port, positive_direction: Direction = Direction.CLOCKWISE + ): ... + def speed(self) -> int: ... + def angle(self) -> int: ... + def reset_angle(self, angle: int) -> None: ... + +class UltrasonicSensor: + def __init__(self, port: Port): ... + def distance(self, silent: bool = False) -> int: ... + def presence(self) -> bool: ... diff --git a/pybricks/hubs.pyi b/pybricks/hubs.pyi new file mode 100644 index 0000000..744936b --- /dev/null +++ b/pybricks/hubs.pyi @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from ._common import Speaker, Battery, ColorLight, KeyPad +from .media.ev3dev import Image + +class EV3Brick: + screen: Image + speaker: Speaker + battery: Battery + light: ColorLight + buttons = KeyPad diff --git a/pybricks/iodevices.pyi b/pybricks/iodevices.pyi new file mode 100644 index 0000000..3badad3 --- /dev/null +++ b/pybricks/iodevices.pyi @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import Optional, Tuple + +from .parameters import Port + +class LUMPDevice: + def __init__(self, port: Port): ... + def read(self, mode: int) -> Tuple: ... + def write(self, mode: int, values: Tuple): ... + +class Ev3devSensor: + sensor_index: int + port_index: int + def __init__(self, port: Port): ... + def read(self, mode: int) -> Tuple: ... + +class AnalogSensor: + def __init__(self, port: Port): ... + def voltage(self) -> int: ... + def resistance(self) -> int: ... + def active(self) -> None: ... + def passive(self) -> None: ... + +class I2CDevice: + def __init__(self, port: Port, address: int): ... + def read(self, reg: Optional[int], length: Optional[int] = 1) -> bytes: ... + def write(self, reg: Optional[int], data: Optional[bytes] = None) -> None: ... + +class UARTDevice: + def __init__(self, port: Port, baudrate: int, timeout: Optional[int] = None): ... + def read(self, length: int = 1) -> bytes: ... + def read_all(self) -> bytes: ... + def write(self, data: bytes) -> None: ... + def waiting(self) -> int: ... + def clear(self) -> None: ... diff --git a/pybricks/media/ev3dev.pyi b/pybricks/media/ev3dev.pyi new file mode 100644 index 0000000..2dc5157 --- /dev/null +++ b/pybricks/media/ev3dev.pyi @@ -0,0 +1,232 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import Any, Literal, Optional, Union, overload + +from ..parameters import Color + +class Image: + @overload + def __init__(self, /, source: Union[Image, ImageFile, str]): ... + @overload + def __init__( + self, /, source: Image, sub: Literal[True], x1: int, y1: int, x2: int, y2: int + ): ... + @property + def width(self) -> int: ... + @property + def height(self) -> int: ... + def clear(self) -> None: ... + def draw_pixel(self, x: int, y: int, color: Color = Color.BLACK) -> None: ... + def draw_line( + self, + x1: int, + y1: int, + x2: int, + y2: int, + width: int = 1, + color: Color = Color.BLACK, + ) -> None: ... + def draw_box( + self, + x1: int, + y1: int, + x2: int, + y2: int, + r: int = 0, + fill: bool = False, + color: Color = Color.BLACK, + ) -> None: ... + def draw_circle( + self, x: int, y: int, r: int, fill: bool = False, color: Color = Color.BLACK + ) -> None: ... + def draw_image( + self, + x: int, + y: int, + source: Union[Image, ImageFile, str], + transparent: Optional[Color] = None, + ) -> None: ... + def load_image(self, source: Union[Image, ImageFile, str]) -> None: ... + def draw_text( + self, + x: int, + y: int, + text: str, + text_color: Color = Color.BLACK, + background_color: Optional[Color] = None, + ) -> None: ... + def print(self, *args: Any, sep: str = " ", end: str = "\n") -> None: ... + def set_font(self, font: Font) -> None: ... + @staticmethod + def empty(width: int = 178, height: int = 128) -> Image: ... + def save(self, filename: str) -> None: ... + +class Font: + DEFAULT: Font + def __init__( + self, + family: Optional[str] = None, + size: int = 12, + bold: bool = False, + monospace: bool = False, + lang: Optional[str] = None, + script: Optional[str] = None, + ): ... + @property + def family(self) -> str: ... + @property + def style(self) -> str: ... + @property + def width(self) -> int: ... + @property + def height(self) -> int: ... + def text_width(self, text: str) -> int: ... + def text_height(self, text: str) -> int: ... + +class SoundFile: + SHOUTING: SoundFile + CHEERING: SoundFile + CRYING: SoundFile + OUCH: SoundFile + LAUGHING_2: SoundFile + SNEEZING: SoundFile + SMACK: SoundFile + BOING: SoundFile + BOO: SoundFile + UH_OH: SoundFile + SNORING: SoundFile + KUNG_FU: SoundFile + FANFARE: SoundFile + CRUNCHING: SoundFile + MAGIC_WAND: SoundFile + LAUGHING_1: SoundFile + LEFT: SoundFile + BACKWARDS: SoundFile + RIGHT: SoundFile + OBJECT: SoundFile + COLOR: SoundFile + FLASHING: SoundFile + ERROR: SoundFile + ERROR_ALARM: SoundFile + DOWN: SoundFile + FORWARD: SoundFile + ACTIVATE: SoundFile + SEARCHING: SoundFile + TOUCH: SoundFile + UP: SoundFile + ANALYZE: SoundFile + STOP: SoundFile + DETECTED: SoundFile + TURN: SoundFile + START: SoundFile + MORNING: SoundFile + EV3: SoundFile + GO: SoundFile + GOOD_JOB: SoundFile + OKEY_DOKEY: SoundFile + GOOD: SoundFile + NO: SoundFile + THANK_YOU: SoundFile + YES: SoundFile + GAME_OVER: SoundFile + OKAY: SoundFile + SORRY: SoundFile + BRAVO: SoundFile + GOODBYE: SoundFile + HI: SoundFile + HELLO: SoundFile + MINDSTORMS: SoundFile + LEGO: SoundFile + FANTASTIC: SoundFile + SPEED_IDLE: SoundFile + SPEED_DOWN: SoundFile + SPEED_UP: SoundFile + BROWN: SoundFile + GREEN: SoundFile + BLACK: SoundFile + WHITE: SoundFile + RED: SoundFile + BLUE: SoundFile + YELLOW: SoundFile + TICK_TACK: SoundFile + HORN_1: SoundFile + BACKING_ALERT: SoundFile + MOTOR_IDLE: SoundFile + AIR_RELEASE: SoundFile + AIRBRAKE: SoundFile + RATCHET: SoundFile + MOTOR_STOP: SoundFile + HORN_2: SoundFile + LASER: SoundFile + SONAR: SoundFile + MOTOR_START: SoundFile + INSECT_BUZZ_2: SoundFile + ELEPHANT_CALL: SoundFile + SNAKE_HISS: SoundFile + DOG_BARK_2: SoundFile + DOG_WHINE: SoundFile + INSECT_BUZZ_1: SoundFile + DOG_SNIFF: SoundFile + T_REX_ROAR: SoundFile + INSECT_CHIRP: SoundFile + DOG_GROWL: SoundFile + SNAKE_RATTLE: SoundFile + DOG_BARK_1: SoundFile + CAT_PURR: SoundFile + EIGHT: SoundFile + SEVEN: SoundFile + SIX: SoundFile + FOUR: SoundFile + TEN: SoundFile + ONE: SoundFile + TWO: SoundFile + THREE: SoundFile + ZERO: SoundFile + FIVE: SoundFile + NINE: SoundFile + READY: SoundFile + CONFIRM: SoundFile + GENERAL_ALERT: SoundFile + CLICK: SoundFile + OVERPOWER: SoundFile + +class ImageFile: + RIGHT: ImageFile + FORWARD: ImageFile + ACCEPT: ImageFile + QUESTION_MARK: ImageFile + STOP_1: ImageFile + LEFT: ImageFile + DECLINE: ImageFile + THUMBS_DOWN: ImageFile + BACKWARD: ImageFile + NO_GO: ImageFile + WARNING: ImageFile + STOP_2: ImageFile + THUMBS_UP: ImageFile + EV3: ImageFile + EV3_ICON: ImageFile + TARGET: ImageFile + BOTTOM_RIGHT: ImageFile + BOTTOM_LEFT: ImageFile + EVIL: ImageFile + CRAZY_2: ImageFile + KNOCKED_OUT: ImageFile + PINCHED_RIGHT: ImageFile + WINKING: ImageFile + DIZZY: ImageFile + DOWN: ImageFile + TIRED_MIDDLE: ImageFile + MIDDLE_RIGHT: ImageFile + SLEEPING: ImageFile + MIDDLE_LEFT: ImageFile + TIRED_RIGHT: ImageFile + PINCHED_LEFT: ImageFile + PINCHED_MIDDLE: ImageFile + CRAZY_1: ImageFile + NEUTRAL: ImageFile + AWAKE: ImageFile + UP: ImageFile + TIRED_LEFT: ImageFile + ANGRY: ImageFile diff --git a/pybricks/media/py.typed b/pybricks/media/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pybricks/messaging.pyi b/pybricks/messaging.pyi new file mode 100644 index 0000000..5b8712a --- /dev/null +++ b/pybricks/messaging.pyi @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from abc import abstractmethod +from typing import Callable, Generic, Optional, TypeVar + +T = TypeVar("T") + +class Connection: + @abstractmethod + def read_from_mailbox(self, name: str) -> bytes: ... + @abstractmethod + def send_to_mailbox(self, name: str, data: bytes) -> None: ... + @abstractmethod + def wait_for_mailbox_update(self, name: str) -> None: ... + +class Mailbox(Generic[T]): + def __init__( + self, + name: str, + connection: Connection, + encode: Optional[Callable[[T], bytes]] = None, + decode: Optional[Callable[[bytes], T]] = None, + ): ... + def read(self) -> T: ... + def send(self, value: T, brick: Optional[str] = None) -> None: ... + def wait(self) -> None: ... + def wait_new(self) -> T: ... + +class LogicMailbox(Mailbox[bool]): + def __init__(self, name, connection: Connection): ... + +class NumericMailbox(Mailbox[float]): + def __init__(self, name, connection: Connection): ... + +class TextMailbox(Mailbox[str]): + def __init__(self, name, connection: Connection): ... + +class BluetoothMailboxServer(Connection): + def __enter__(self) -> BluetoothMailboxServer: ... + def __exit__(self, type, value, traceback) -> None: ... + def wait_for_connection(self, count: int = 1) -> None: ... + def close(self) -> None: ... + +class BluetoothMailboxClient(Connection): + def __enter__(self) -> BluetoothMailboxClient: ... + def __exit__(self, type, value, traceback) -> None: ... + def connect(self, brick: str) -> None: ... + def close(self) -> None: ... diff --git a/pybricks/nxtdevices.pyi b/pybricks/nxtdevices.pyi new file mode 100644 index 0000000..9bc9670 --- /dev/null +++ b/pybricks/nxtdevices.pyi @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import Callable, Optional, Tuple + +from ._common import ColorLight +from .iodevices import AnalogSensor +from .parameters import Color, Port + +class TouchSensor: + def __init__(self, port: Port): ... + def pressed(self) -> bool: ... + +class LightSensor: + def __init__(self, port: Port): ... + def ambient(self) -> int: ... + def reflection(self) -> int: ... + +class ColorSensor: + light: ColorLight + def __init__(self, port: Port): ... + def color(self) -> Optional[Color]: ... + def ambient(self) -> int: ... + def reflection(self) -> int: ... + def rgb(self) -> Tuple[int, int, int]: ... + +class UltrasonicSensor: + def __init__(self, port: Port): ... + def distance(self) -> int: ... + +class SoundSensor: + def __init__(self, port: Port): ... + def intensity(self, audible_only: bool = True) -> int: ... + +class TemperatureSensor: + def __init__(self, port: Port): ... + def temperature(self) -> int: ... + +class EnergyMeter: + def __init__(self, port: Port): ... + def storage(self) -> int: ... + def input(self) -> Tuple[int, int, int]: ... + def output(self) -> Tuple[int, int, int]: ... + +class VernierAdapter(AnalogSensor): + def __init__( + self, port: Port, conversion: Optional[Callable[[int], float]] = None + ): ... + def voltage(self) -> int: ... + def conversion(self, voltage: int) -> float: ... + def value(self) -> float: ... diff --git a/pybricks/parameters.pyi b/pybricks/parameters.pyi new file mode 100644 index 0000000..ca9665b --- /dev/null +++ b/pybricks/parameters.pyi @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +class Color: + BLACK: Color + BLUE: Color + GREEN: Color + YELLOW: Color + RED: Color + WHITE: Color + BROWN: Color + ORANGE: Color + PURPLE: Color + +class Port: + A: Port + B: Port + C: Port + D: Port + S1: Port + S2: Port + S3: Port + S4: Port + +class Stop: + COAST: Stop + BRAKE: Stop + HOLD: Stop + +class Direction: + CLOCKWISE: Direction + COUNTERCLOCKWISE: Direction + +class Button: + LEFT_DOWN: Button + DOWN: Button + RIGHT_DOWN: Button + LEFT: Button + CENTER: Button + RIGHT: Button + LEFT_UP: Button + UP: Button + BEACON: Button + RIGHT_UP: Button diff --git a/pybricks/py.typed b/pybricks/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pybricks/robotics.pyi b/pybricks/robotics.pyi new file mode 100644 index 0000000..bcd702b --- /dev/null +++ b/pybricks/robotics.pyi @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import Optional, Tuple, overload +from ._common import Control, Motor + +class DriveBase: + distance_control: Control + heading_control: Control + def __init__( + self, + left_motor: Motor, + right_motor: Motor, + wheel_diameter: int, + axle_track: int, + ): ... + def drive(self, drive_speed: int, turn_rate: int) -> None: ... + def stop(self) -> None: ... + def distance(self) -> int: ... + def angle(self) -> int: ... + def state(self) -> Tuple[int, int, int, int]: ... + def reset(self) -> None: ... + @overload + def settings(self) -> Tuple[int, int, int, int]: ... + @overload + def settings( + self, + straight_speed: Optional[int], + straight_acceleration: Optional[int], + turn_rate: Optional[int], + turn_acceleration: Optional[int], + ) -> None: ... + def straight(self, distance: int) -> None: ... + def turn(self, angle: int) -> None: ... diff --git a/pybricks/tools.pyi b/pybricks/tools.pyi new file mode 100644 index 0000000..bed3f94 --- /dev/null +++ b/pybricks/tools.pyi @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2020 The Pybricks Authors + +from typing import Any + +def wait(time: int) -> None: ... + +class StopWatch: + def time(self) -> int: ... + def pause(self) -> None: ... + def resume(self) -> None: ... + def reset(self) -> None: ... + +class DataLog: + def __init__( + self, + *headers: str, + name: str = "log", + timestamp: bool = True, + extension: str = "csv", + append: bool = False + ): ... + def log(self, *values: Any) -> None: ... diff --git a/pyproject.toml b/pyproject.toml index 4bc11c1..0209433 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,11 +13,13 @@ classifiers = [ "Development Status :: 3 - Alpha", "Programming Language :: Python :: Implementation :: MicroPython", ] +include = ["pybricks/py.typed"] [tool.poetry.dependencies] -python = "^3.5" +python = "^3.8" [tool.poetry.dev-dependencies] +black = {version = "^20.8b1", allow-prereleases = true} doc8 = "*" flake8 = "*" sphinx = "==1.7.9" @@ -26,5 +28,5 @@ sphinxcontrib-contentui = "==0.2.2" toml = "^0.10.0" [build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.cfg b/setup.cfg index 70225b0..08428ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [flake8] -exclude = .venv/ +exclude = .venv/,*.pyi max-line-length = 88 [doc8]