diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d288bcd..a9f77ef 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,7 @@ on: paths-ignore: - ".idea/**" - ".vscode/**" + - "scripts/**" - "**/*.md" - ".prettierrc.json" - "LICENSE" @@ -24,17 +25,22 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Setup node + - name: Setup Node v18.15.x uses: actions/setup-node@v3 with: node-version: "18.15.x" registry-url: "https://npm.pkg.github.com" scope: "@paulober" token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Python v3.11 + uses: actions/setup-python@v4 + with: + python-version: '3.11' - - name: Install Dependencies + - name: Install NPM Dependencies And Download Stubs shell: bash run: | sed -i '1i//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}' .npmrc @@ -43,4 +49,4 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package Extension - run: npx @vscode/vsce package --no-yarn -o pico-w-go-${{ github.sha }}.vsix + run: npx @vscode/vsce package --no-yarn -o micropico-${{ github.sha }}.vsix diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8af84f7..f58dd61 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,15 +15,22 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + + - name: Setup Node v18.15.x + uses: actions/setup-node@v3 with: node-version: '18.15.x' registry-url: "https://npm.pkg.github.com" scope: "@paulober" token: ${{ secrets.GITHUB_TOKEN }} - - name: NPM install + - name: Setup Python v3.11 + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install NPM dependencies And Download Stubs shell: bash run: | sed -i '1i//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}' .npmrc @@ -35,18 +42,18 @@ jobs: - name: Package run: npx @vscode/vsce package --no-yarn - - run: npx @vscode/vsce publish --no-yarn --target win32-x64 linux-x64 linux-arm64 darwin-x64 darwin-arm64 - name: Publish + - name: Publish + run: npx @vscode/vsce publish --no-yarn --target win32-x64 linux-x64 linux-arm64 darwin-x64 darwin-arm64 env: VSCE_PAT: ${{ secrets.VSCE_PAT }} - - name: Upload artifact + - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: Visual Studio Code extension package path: pico-w-go-*.vsix - - name: Upload artifact to release + - name: Upload Artifact To Release #gh api --method POST -H "Accept: application/vnd.github+json" /repos/paulober/Pico-W-Go/releases/$RELEASE_ID/assets run: gh release upload $RELEASE_TAG_NAME pico-w-go-*.vsix env: diff --git a/.gitignore b/.gitignore index c221435..6fea060 100755 --- a/.gitignore +++ b/.gitignore @@ -478,3 +478,4 @@ fabric.properties # End of https://www.toptal.com/developers/gitignore/api/node,python,webstorm,visualstudiocode,macos *.zip +mpy_stubs/ diff --git a/.vscodeignore b/.vscodeignore index a3b43d1..7b853ae 100755 --- a/.vscodeignore +++ b/.vscodeignore @@ -25,3 +25,4 @@ azure-pipelines.yml !dist/*.cjs !dist/scripts/*.py dist/scripts/__pycache__ +!mpy_stubs/ diff --git a/README.md b/README.md index e077a38..a911b2a 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ "MicroPico" is a Visual Studio Code extension designed to simplify and accelerate the development of MicroPython projects for the Raspberry Pi Pico and Pico W boards. This tool streamlines the coding process, providing code highlighting, auto-completion, code snippets, and project management features, all tailored for the seamless development experience with MicroPython on Raspberry Pi Pico and Pico W microcontrollers. -> __Auto-completion based on Raspberry Pi Pico W MicroPython firmware: [RPI_PICO_W-20231005-v1.21.0.uf2](https://micropython.org/resources/firmware/RPI_PICO_W-20231005-v1.21.0.uf2)__ +> __Auto-completion based on Raspberry Pi Pico W MicroPython firmware: [RPI_PICO_W-20230426-v1.20.0.uf2](https://micropython.org/resources/firmware/RPI_PICO_W-20230426-v1.20.0.uf2) from the [micropython-stubs project](https://github.com/Josverl/micropython-stubs)__ +> NOTE: Support for MPY v1.21.0 will be added in the next few days. Works with: | Platform | x64 | arm64 | @@ -13,7 +14,7 @@ Works with: ## Features -- Auto-completion and docs +- Auto-completion with docs - Pseudo terminal integration for communication with MicroPython REPL on a Pico (w) board (with support for tab-completion) - Running / Transferring files to / from your board - Built-in virtual-workspace provider for Raspberry Pi Pico (W) boards diff --git a/package-lock.json b/package-lock.json index 7f25c17..4addc01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "x64", "arm64" ], + "hasInstallScript": true, "license": "MPL-2.0", "os": [ "win32", diff --git a/package.json b/package.json index 0f04d0e..cc724af 100644 --- a/package.json +++ b/package.json @@ -493,6 +493,7 @@ "scripts": { "vscode:uninstall": "node ./dist/vscodeUninstall.mjs", "vscode:prepublish": "npm run package", + "postinstall": "python3 -m pip install -U micropython-rp2-pico_w-stubs --target ./mpy_stubs --no-user", "compile-uninstaller": "rollup -c uninstall.rollup.config.mjs", "compile": "rollup -c && npm run compile-uninstaller", "watch": "rollup -cw", diff --git a/src/stubs.mts b/src/stubs.mts index 60a3fe5..846f83b 100644 --- a/src/stubs.mts +++ b/src/stubs.mts @@ -6,7 +6,7 @@ import { recommendedExtensions, shouldRecommendExtensions, } from "./api.mjs"; -import { mkdir, readFile, symlink } from "fs/promises"; +import { mkdir, readdir, symlink } from "fs/promises"; import { pathExists, readJsonFile, writeJsonFile } from "./osHelper.mjs"; import { copy, emptyDir } from "fs-extra"; import Logger from "./logger.mjs"; @@ -19,37 +19,76 @@ export default class Stubs { this.logger = new Logger("Stubs"); } + private async updateSettings(): Promise { + const workspace = getProjectPath(); + + if (workspace === undefined) { + return; + } + + // the path to the .vscode folder in the project folder + const vsc = join(workspace, ".vscode"); + + // check if .vscode folder exists if not create it + if (!(await pathExists(vsc))) { + await mkdir(vsc); + } + + // update to new vscode settings for new stubs if old stubs are still installed + // TODO: maybe remove in later versions + await this.addSettings(vsc, true); + } + public async update(): Promise { const configFolder = getVsCodeUserPath(); - const stubsFolder = join(configFolder, "Pico-W-Stub"); + const installedStubsFolder = join(configFolder, "Pico-W-Stub"); - // ensure config folder exists - await mkdir(configFolder, { recursive: true }); + // TODO: remove in later versions + await this.updateSettings(); - const existingVersionFile = join(stubsFolder, "version.json"); - const currentVersionFile = resolve( - join(__dirname, "..", "stubs", "version.json") - ); + if (!(await pathExists(join(installedStubsFolder, "version.json")))) { + // ensure config folder exists + await mkdir(configFolder, { recursive: true }); + + let installedVersion = ""; + let currentVersion = ""; + + if (await pathExists(installedStubsFolder)) { + const installedMatchingFolders = ( + await readdir(installedStubsFolder) + ).filter(name => name.match(/micropython_rp2.*\.dist-info/)); + + if (installedMatchingFolders.length > 0) { + installedVersion = installedMatchingFolders[0]; + } + } + + const currentFolder = join(__dirname, "..", "mpy_stubs"); - const currentVersion = JSON.parse( - await readFile(currentVersionFile, "utf8") - ) as { version: string }; + if (await pathExists(currentFolder)) { + const currentMatchingFolders = (await readdir(currentFolder)).filter( + name => name.match(/micropython_rp2.*\.dist-info/) + ); + + if (currentMatchingFolders.length > 0) { + currentVersion = currentMatchingFolders[0]; + } + } - // Check if the existing version file exists and if the version is the same - if (await pathExists(existingVersionFile)) { - const existingVersion = JSON.parse( - await readFile(existingVersionFile, "utf8") - ) as { version: string }; + // Check if the existing version file exists and if the version is the same + if (installedVersion === currentVersion) { + this.logger.info("Installed stubs are already up to date!"); - if (existingVersion.version === currentVersion.version) { return; } } try { // update stubs folder - await emptyDir(stubsFolder); - await copy(join(__dirname, "..", "stubs"), stubsFolder); + await emptyDir(installedStubsFolder); + await copy(join(__dirname, "..", "mpy_stubs"), installedStubsFolder); + + this.logger.info("Updated stubs successfully!"); } catch (error) { const msg: string = typeof error === "string" ? error : (error as Error).message; @@ -126,10 +165,13 @@ export default class Stubs { await writeJsonFile(extensionsFilePath, extensions); } - private async addSettings(vsc: string): Promise { + private async addSettings( + vsc: string, + justUpdate: boolean = false + ): Promise { const settingsFilePath = join(vsc, "settings.json"); const stubsPath = join(".vscode", "Pico-W-Stub"); - const defaultSettings = { + const defaultSettings: { [key: string]: string | boolean | object } = { // eslint-disable-next-line @typescript-eslint/naming-convention "python.linting.enabled": true, // eslint-disable-next-line @typescript-eslint/naming-convention @@ -137,11 +179,18 @@ export default class Stubs { // eslint-disable-next-line @typescript-eslint/naming-convention "python.analysis.typeCheckingMode": "basic", // eslint-disable-next-line @typescript-eslint/naming-convention - "micropico.syncFolder": "", - // eslint-disable-next-line @typescript-eslint/naming-convention - "micropico.openOnStart": true, + "python.analysis.diagnosticSeverityOverrides": { + reportMissingModuleSource: "none", + }, }; + if (!justUpdate) { + // eslint-disable-next-line @typescript-eslint/naming-convention + defaultSettings["micropico.syncFolder"] = ""; + // eslint-disable-next-line @typescript-eslint/naming-convention + defaultSettings["micropico.openOnStart"] = true; + } + interface ISettings { // eslint-disable-next-line @typescript-eslint/naming-convention "python.analysis.typeshedPaths": string[]; @@ -158,7 +207,7 @@ export default class Stubs { ); settings["python.analysis.extraPaths"] = _.union( settings["python.analysis.extraPaths"] || [], - [join(stubsPath, "stubs")] + [stubsPath] ); await writeJsonFile(settingsFilePath, settings); diff --git a/stubs/README.md b/stubs/README.md deleted file mode 100644 index 8134e1a..0000000 --- a/stubs/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Raspberry Pi Pico-W stubs -... from [github.com/paulober/Pico-W-Stub](https://github.com/paulober/Pico-W-Stub) diff --git a/stubs/stdlib/_ast.pyi b/stubs/stdlib/_ast.pyi deleted file mode 100644 index e39ab0a..0000000 --- a/stubs/stdlib/_ast.pyi +++ /dev/null @@ -1,576 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from typing import Any, ClassVar -from typing_extensions import Literal, TypeAlias - -PyCF_ONLY_AST: Literal[1024] -if sys.version_info >= (3, 8): - PyCF_TYPE_COMMENTS: Literal[4096] - PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192] - -_Identifier: TypeAlias = str - -class AST: - if sys.version_info >= (3, 10): - __match_args__ = () - _attributes: ClassVar[tuple[str, ...]] - _fields: ClassVar[tuple[str, ...]] - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - # TODO: Not all nodes have all of the following attributes - lineno: int - col_offset: int - if sys.version_info >= (3, 8): - end_lineno: int | None - end_col_offset: int | None - type_comment: str | None - -class mod(AST): ... - -if sys.version_info >= (3, 8): - class type_ignore(AST): ... - - class TypeIgnore(type_ignore): - if sys.version_info >= (3, 10): - __match_args__ = ("lineno", "tag") - tag: str - - class FunctionType(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("argtypes", "returns") - argtypes: list[expr] - returns: expr - -class Module(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body", "type_ignores") - body: list[stmt] - if sys.version_info >= (3, 8): - type_ignores: list[TypeIgnore] - -class Interactive(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body",) - body: list[stmt] - -class Expression(mod): - if sys.version_info >= (3, 10): - __match_args__ = ("body",) - body: expr - -class stmt(AST): ... - -class FunctionDef(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") - name: _Identifier - args: arguments - body: list[stmt] - decorator_list: list[expr] - returns: expr | None - -class AsyncFunctionDef(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment") - name: _Identifier - args: arguments - body: list[stmt] - decorator_list: list[expr] - returns: expr | None - -class ClassDef(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("name", "bases", "keywords", "body", "decorator_list") - name: _Identifier - bases: list[expr] - keywords: list[keyword] - body: list[stmt] - decorator_list: list[expr] - -class Return(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) - value: expr | None - -class Delete(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("targets",) - targets: list[expr] - -class Assign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("targets", "value", "type_comment") - targets: list[expr] - value: expr - -class AugAssign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "op", "value") - target: expr - op: operator - value: expr - -class AnnAssign(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "annotation", "value", "simple") - target: expr - annotation: expr - value: expr | None - simple: int - -class For(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") - target: expr - iter: expr - body: list[stmt] - orelse: list[stmt] - -class AsyncFor(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "body", "orelse", "type_comment") - target: expr - iter: expr - body: list[stmt] - orelse: list[stmt] - -class While(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") - test: expr - body: list[stmt] - orelse: list[stmt] - -class If(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") - test: expr - body: list[stmt] - orelse: list[stmt] - -class With(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("items", "body", "type_comment") - items: list[withitem] - body: list[stmt] - -class AsyncWith(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("items", "body", "type_comment") - items: list[withitem] - body: list[stmt] - -class Raise(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("exc", "cause") - exc: expr | None - cause: expr | None - -class Try(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("body", "handlers", "orelse", "finalbody") - body: list[stmt] - handlers: list[ExceptHandler] - orelse: list[stmt] - finalbody: list[stmt] - -if sys.version_info >= (3, 11): - class TryStar(stmt): - __match_args__ = ("body", "handlers", "orelse", "finalbody") - body: list[stmt] - handlers: list[ExceptHandler] - orelse: list[stmt] - finalbody: list[stmt] - -class Assert(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "msg") - test: expr - msg: expr | None - -class Import(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) - names: list[alias] - -class ImportFrom(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("module", "names", "level") - module: str | None - names: list[alias] - level: int - -class Global(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) - names: list[_Identifier] - -class Nonlocal(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("names",) - names: list[_Identifier] - -class Expr(stmt): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) - value: expr - -class Pass(stmt): ... -class Break(stmt): ... -class Continue(stmt): ... -class expr(AST): ... - -class BoolOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("op", "values") - op: boolop - values: list[expr] - -class BinOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("left", "op", "right") - left: expr - op: operator - right: expr - -class UnaryOp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("op", "operand") - op: unaryop - operand: expr - -class Lambda(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("args", "body") - args: arguments - body: expr - -class IfExp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("test", "body", "orelse") - test: expr - body: expr - orelse: expr - -class Dict(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("keys", "values") - keys: list[expr | None] - values: list[expr] - -class Set(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts",) - elts: list[expr] - -class ListComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") - elt: expr - generators: list[comprehension] - -class SetComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") - elt: expr - generators: list[comprehension] - -class DictComp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("key", "value", "generators") - key: expr - value: expr - generators: list[comprehension] - -class GeneratorExp(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elt", "generators") - elt: expr - generators: list[comprehension] - -class Await(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) - value: expr - -class Yield(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) - value: expr | None - -class YieldFrom(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value",) - value: expr - -class Compare(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("left", "ops", "comparators") - left: expr - ops: list[cmpop] - comparators: list[expr] - -class Call(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("func", "args", "keywords") - func: expr - args: list[expr] - keywords: list[keyword] - -class FormattedValue(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "conversion", "format_spec") - value: expr - conversion: int - format_spec: expr | None - -class JoinedStr(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("values",) - values: list[expr] - -if sys.version_info < (3, 8): - class Num(expr): # Deprecated in 3.8; use Constant - n: complex - - class Str(expr): # Deprecated in 3.8; use Constant - s: str - - class Bytes(expr): # Deprecated in 3.8; use Constant - s: bytes - - class NameConstant(expr): # Deprecated in 3.8; use Constant - value: Any - - class Ellipsis(expr): ... # Deprecated in 3.8; use Constant - -class Constant(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "kind") - value: Any # None, str, bytes, bool, int, float, complex, Ellipsis - kind: str | None - # Aliases for value, for backwards compatibility - s: Any - n: complex - -if sys.version_info >= (3, 8): - class NamedExpr(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "value") - target: expr - value: expr - -class Attribute(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "attr", "ctx") - value: expr - attr: _Identifier - ctx: expr_context - -if sys.version_info >= (3, 9): - _Slice: TypeAlias = expr -else: - class slice(AST): ... - _Slice: TypeAlias = slice - -class Slice(_Slice): - if sys.version_info >= (3, 10): - __match_args__ = ("lower", "upper", "step") - lower: expr | None - upper: expr | None - step: expr | None - -if sys.version_info < (3, 9): - class ExtSlice(slice): - dims: list[slice] - - class Index(slice): - value: expr - -class Subscript(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "slice", "ctx") - value: expr - slice: _Slice - ctx: expr_context - -class Starred(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("value", "ctx") - value: expr - ctx: expr_context - -class Name(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("id", "ctx") - id: _Identifier - ctx: expr_context - -class List(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts", "ctx") - elts: list[expr] - ctx: expr_context - -class Tuple(expr): - if sys.version_info >= (3, 10): - __match_args__ = ("elts", "ctx") - elts: list[expr] - ctx: expr_context - if sys.version_info >= (3, 9): - dims: list[expr] - -class expr_context(AST): ... - -if sys.version_info < (3, 9): - class AugLoad(expr_context): ... - class AugStore(expr_context): ... - class Param(expr_context): ... - - class Suite(mod): - body: list[stmt] - -class Del(expr_context): ... -class Load(expr_context): ... -class Store(expr_context): ... -class boolop(AST): ... -class And(boolop): ... -class Or(boolop): ... -class operator(AST): ... -class Add(operator): ... -class BitAnd(operator): ... -class BitOr(operator): ... -class BitXor(operator): ... -class Div(operator): ... -class FloorDiv(operator): ... -class LShift(operator): ... -class Mod(operator): ... -class Mult(operator): ... -class MatMult(operator): ... -class Pow(operator): ... -class RShift(operator): ... -class Sub(operator): ... -class unaryop(AST): ... -class Invert(unaryop): ... -class Not(unaryop): ... -class UAdd(unaryop): ... -class USub(unaryop): ... -class cmpop(AST): ... -class Eq(cmpop): ... -class Gt(cmpop): ... -class GtE(cmpop): ... -class In(cmpop): ... -class Is(cmpop): ... -class IsNot(cmpop): ... -class Lt(cmpop): ... -class LtE(cmpop): ... -class NotEq(cmpop): ... -class NotIn(cmpop): ... - -class comprehension(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("target", "iter", "ifs", "is_async") - target: expr - iter: expr - ifs: list[expr] - is_async: int - -class excepthandler(AST): ... - -class ExceptHandler(excepthandler): - if sys.version_info >= (3, 10): - __match_args__ = ("type", "name", "body") - type: expr | None - name: _Identifier | None - body: list[stmt] - -class arguments(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults") - if sys.version_info >= (3, 8): - posonlyargs: list[arg] - args: list[arg] - vararg: arg | None - kwonlyargs: list[arg] - kw_defaults: list[expr | None] - kwarg: arg | None - defaults: list[expr] - -class arg(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("arg", "annotation", "type_comment") - arg: _Identifier - annotation: expr | None - -class keyword(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("arg", "value") - arg: _Identifier | None - value: expr - -class alias(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("name", "asname") - name: _Identifier - asname: _Identifier | None - -class withitem(AST): - if sys.version_info >= (3, 10): - __match_args__ = ("context_expr", "optional_vars") - context_expr: expr - optional_vars: expr | None - -if sys.version_info >= (3, 10): - class Match(stmt): - __match_args__ = ("subject", "cases") - subject: expr - cases: list[match_case] - - class pattern(AST): ... - # Without the alias, Pyright complains variables named pattern are recursively defined - _Pattern: TypeAlias = pattern - - class match_case(AST): - __match_args__ = ("pattern", "guard", "body") - pattern: _Pattern - guard: expr | None - body: list[stmt] - - class MatchValue(pattern): - __match_args__ = ("value",) - value: expr - - class MatchSingleton(pattern): - __match_args__ = ("value",) - value: Literal[True, False, None] - - class MatchSequence(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] - - class MatchStar(pattern): - __match_args__ = ("name",) - name: _Identifier | None - - class MatchMapping(pattern): - __match_args__ = ("keys", "patterns", "rest") - keys: list[expr] - patterns: list[pattern] - rest: _Identifier | None - - class MatchClass(pattern): - __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns") - cls: expr - patterns: list[pattern] - kwd_attrs: list[_Identifier] - kwd_patterns: list[pattern] - - class MatchAs(pattern): - __match_args__ = ("pattern", "name") - pattern: _Pattern | None - name: _Identifier | None - - class MatchOr(pattern): - __match_args__ = ("patterns",) - patterns: list[pattern] diff --git a/stubs/stdlib/_collections_abc.pyi b/stubs/stdlib/_collections_abc.pyi deleted file mode 100644 index 3d8148c..0000000 --- a/stubs/stdlib/_collections_abc.pyi +++ /dev/null @@ -1,84 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from types import MappingProxyType -from typing import ( # noqa: Y027,Y038 - AbstractSet as Set, - AsyncGenerator as AsyncGenerator, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - ByteString as ByteString, - Callable as Callable, - Collection as Collection, - Container as Container, - Coroutine as Coroutine, - Generator as Generator, - Generic, - Hashable as Hashable, - ItemsView as ItemsView, - Iterable as Iterable, - Iterator as Iterator, - KeysView as KeysView, - Mapping as Mapping, - MappingView as MappingView, - MutableMapping as MutableMapping, - MutableSequence as MutableSequence, - MutableSet as MutableSet, - Reversible as Reversible, - Sequence as Sequence, - Sized as Sized, - TypeVar, - ValuesView as ValuesView, -) -from typing_extensions import final - -__all__ = [ - "Awaitable", - "Coroutine", - "AsyncIterable", - "AsyncIterator", - "AsyncGenerator", - "Hashable", - "Iterable", - "Iterator", - "Generator", - "Reversible", - "Sized", - "Container", - "Callable", - "Collection", - "Set", - "MutableSet", - "Mapping", - "MutableMapping", - "MappingView", - "KeysView", - "ItemsView", - "ValuesView", - "Sequence", - "MutableSequence", - "ByteString", -] - -_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers. -_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers. - -@final -class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... - -@final -class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... - -@final -class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented - if sys.version_info >= (3, 10): - @property - def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... diff --git a/stubs/stdlib/_thread.pyi b/stubs/stdlib/_thread.pyi deleted file mode 100644 index 1aa8110..0000000 --- a/stubs/stdlib/_thread.pyi +++ /dev/null @@ -1,37 +0,0 @@ -import sys -from collections.abc import Callable -from threading import Thread -from types import TracebackType -from typing import Any, NoReturn, Optional - -error = RuntimeError - -class LockType: - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - def release(self) -> None: ... - def locked(self) -> bool: ... - def __enter__(self) -> bool: ... - def __exit__( - self, type: type[BaseException]|None, value: BaseException|None, traceback: TracebackType|None - ) -> None: ... - -def start_new_thread(function: Callable[..., ...], args: tuple[..., ...], kwargs: dict[str, Any] = ...) -> int: ... -def allocate_lock() -> LockType: ... -def exit() -> NoReturn: ... -def get_ident() -> int: ... -def stack_size(size: int = ...) -> int: ... - -TIMEOUT_MAX: float - -if sys.version_info >= (3, 8): - - class _ExceptHookArgs(tuple[type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]): - @property - def exc_type(self) -> type[BaseException]: ... - @property - def exc_value(self) -> BaseException|None: ... - @property - def exc_traceback(self) -> TracebackType|None: ... - @property - def thread(self) -> Thread|None: ... - _excepthook: Callable[[_ExceptHookArgs], Any] diff --git a/stubs/stdlib/_typeshed/__init__.pyi b/stubs/stdlib/_typeshed/__init__.pyi deleted file mode 100644 index f37e164..0000000 --- a/stubs/stdlib/_typeshed/__init__.pyi +++ /dev/null @@ -1,281 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -# Utility types for typeshed -# -# See the README.md file in this directory for more information. - -import array -import ctypes -import mmap -import pickle -import sys -from collections.abc import Awaitable, Callable, Container, Iterable, Set as AbstractSet -from os import PathLike -from types import FrameType, TracebackType -from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union -from typing_extensions import Final, Literal, LiteralString, TypeAlias, final - -_KT = TypeVar("_KT") -_KT_co = TypeVar("_KT_co", covariant=True) -_KT_contra = TypeVar("_KT_contra", contravariant=True) -_VT = TypeVar("_VT") -_VT_co = TypeVar("_VT_co", covariant=True) -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_T_contra = TypeVar("_T_contra", contravariant=True) - -# Use for "self" annotations: -# def __enter__(self: Self) -> Self: ... -Self = TypeVar("Self") # noqa: Y001 - -# covariant version of typing.AnyStr, useful for protocols -AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True) # noqa: Y001 - -# For partially known annotations. Usually, fields where type annotations -# haven't been added are left unannotated, but in some situations this -# isn't possible or a type is already partially known. In cases like these, -# use Incomplete instead of Any as a marker. For example, use -# "Incomplete | None" instead of "Any | None". -Incomplete: TypeAlias = Any - -# stable -class IdentityFunction(Protocol): - def __call__(self, __x: _T) -> _T: ... - -# stable -class SupportsNext(Protocol[_T_co]): - def __next__(self) -> _T_co: ... - -# stable -class SupportsAnext(Protocol[_T_co]): - def __anext__(self) -> Awaitable[_T_co]: ... - -# Comparison protocols - -class SupportsDunderLT(Protocol[_T_contra]): - def __lt__(self, __other: _T_contra) -> bool: ... - -class SupportsDunderGT(Protocol[_T_contra]): - def __gt__(self, __other: _T_contra) -> bool: ... - -class SupportsDunderLE(Protocol[_T_contra]): - def __le__(self, __other: _T_contra) -> bool: ... - -class SupportsDunderGE(Protocol[_T_contra]): - def __ge__(self, __other: _T_contra) -> bool: ... - -class SupportsAllComparisons( - SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol -): ... - -SupportsRichComparison: TypeAlias = SupportsDunderLT[Any] | SupportsDunderGT[Any] -SupportsRichComparisonT = TypeVar("SupportsRichComparisonT", bound=SupportsRichComparison) # noqa: Y001 - -# Dunder protocols - -class SupportsAdd(Protocol[_T_contra, _T_co]): - def __add__(self, __x: _T_contra) -> _T_co: ... - -class SupportsRAdd(Protocol[_T_contra, _T_co]): - def __radd__(self, __x: _T_contra) -> _T_co: ... - -class SupportsSub(Protocol[_T_contra, _T_co]): - def __sub__(self, __x: _T_contra) -> _T_co: ... - -class SupportsRSub(Protocol[_T_contra, _T_co]): - def __rsub__(self, __x: _T_contra) -> _T_co: ... - -class SupportsDivMod(Protocol[_T_contra, _T_co]): - def __divmod__(self, __other: _T_contra) -> _T_co: ... - -class SupportsRDivMod(Protocol[_T_contra, _T_co]): - def __rdivmod__(self, __other: _T_contra) -> _T_co: ... - -# This protocol is generic over the iterator type, while Iterable is -# generic over the type that is iterated over. -class SupportsIter(Protocol[_T_co]): - def __iter__(self) -> _T_co: ... - -# This protocol is generic over the iterator type, while AsyncIterable is -# generic over the type that is iterated over. -class SupportsAiter(Protocol[_T_co]): - def __aiter__(self) -> _T_co: ... - -class SupportsLenAndGetItem(Protocol[_T_co]): - def __len__(self) -> int: ... - def __getitem__(self, __k: int) -> _T_co: ... - -class SupportsTrunc(Protocol): - def __trunc__(self) -> int: ... - -# Mapping-like protocols - -# stable -class SupportsItems(Protocol[_KT_co, _VT_co]): - def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ... - -# stable -class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]): - def keys(self) -> Iterable[_KT]: ... - def __getitem__(self, __key: _KT) -> _VT_co: ... - -# stable -class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]): - def __getitem__(self, __key: _KT_contra) -> _VT_co: ... - -# stable -class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]): - def __setitem__(self, __key: _KT_contra, __value: _VT) -> None: ... - def __delitem__(self, __key: _KT_contra) -> None: ... - -StrPath: TypeAlias = str | PathLike[str] # stable -BytesPath: TypeAlias = bytes | PathLike[bytes] # stable -GenericPath: TypeAlias = AnyStr | PathLike[AnyStr] -StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes] # stable - -OpenTextModeUpdating: TypeAlias = Literal[ - "r+", - "+r", - "rt+", - "r+t", - "+rt", - "tr+", - "t+r", - "+tr", - "w+", - "+w", - "wt+", - "w+t", - "+wt", - "tw+", - "t+w", - "+tw", - "a+", - "+a", - "at+", - "a+t", - "+at", - "ta+", - "t+a", - "+ta", - "x+", - "+x", - "xt+", - "x+t", - "+xt", - "tx+", - "t+x", - "+tx", -] -OpenTextModeWriting: TypeAlias = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"] -OpenTextModeReading: TypeAlias = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"] -OpenTextMode: TypeAlias = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading -OpenBinaryModeUpdating: TypeAlias = Literal[ - "rb+", - "r+b", - "+rb", - "br+", - "b+r", - "+br", - "wb+", - "w+b", - "+wb", - "bw+", - "b+w", - "+bw", - "ab+", - "a+b", - "+ab", - "ba+", - "b+a", - "+ba", - "xb+", - "x+b", - "+xb", - "bx+", - "b+x", - "+bx", -] -OpenBinaryModeWriting: TypeAlias = Literal["wb", "bw", "ab", "ba", "xb", "bx"] -OpenBinaryModeReading: TypeAlias = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"] -OpenBinaryMode: TypeAlias = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting - -# stable -class HasFileno(Protocol): - def fileno(self) -> int: ... - -FileDescriptor: TypeAlias = int # stable -FileDescriptorLike: TypeAlias = int | HasFileno # stable - -# stable -class SupportsRead(Protocol[_T_co]): - def read(self, __length: int = ...) -> _T_co: ... - -# stable -class SupportsReadline(Protocol[_T_co]): - def readline(self, __length: int = ...) -> _T_co: ... - -# stable -class SupportsNoArgReadline(Protocol[_T_co]): - def readline(self) -> _T_co: ... - -# stable -class SupportsWrite(Protocol[_T_contra]): - def write(self, __s: _T_contra) -> object: ... - -ReadOnlyBuffer: TypeAlias = bytes # stable -# Anything that implements the read-write buffer interface. -# The buffer interface is defined purely on the C level, so we cannot define a normal Protocol -# for it (until PEP 688 is implemented). Instead we have to list the most common stdlib buffer classes in a Union. -if sys.version_info >= (3, 8): - WriteableBuffer: TypeAlias = ( - bytearray | memoryview | array.array[Any] | mmap.mmap | ctypes._CData | pickle.PickleBuffer - ) # stable -else: - WriteableBuffer: TypeAlias = bytearray | memoryview | array.array[Any] | mmap.mmap | ctypes._CData # stable -# Same as _WriteableBuffer, but also includes read-only buffer types (like bytes). -ReadableBuffer: TypeAlias = ReadOnlyBuffer | WriteableBuffer # stable - -ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType] -OptExcInfo: TypeAlias = Union[ExcInfo, tuple[None, None, None]] - -# stable -if sys.version_info >= (3, 10): - from types import NoneType as NoneType -else: - # Used by type checkers for checks involving None (does not exist at runtime) - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... - -# This is an internal CPython type that is like, but subtly different from, a NamedTuple -# Subclasses of this type are found in multiple modules. -# In typeshed, `structseq` is only ever used as a mixin in combination with a fixed-length `Tuple` -# See discussion at #6546 & #6560 -# `structseq` classes are unsubclassable, so are all decorated with `@final`. -class structseq(Generic[_T_co]): - n_fields: Final[int] - n_unnamed_fields: Final[int] - n_sequence_fields: Final[int] - # The first parameter will generally only take an iterable of a specific length. - # E.g. `os.uname_result` takes any iterable of length exactly 5. - # - # The second parameter will accept a dict of any kind without raising an exception, - # but only has any meaning if you supply it a dict where the keys are strings. - # https://github.com/python/typeshed/pull/6560#discussion_r767149830 - def __new__(cls: type[Self], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> Self: ... - -# Superset of typing.AnyStr that also inclues LiteralString -AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001 - -# Represents when str or LiteralStr is acceptable. Useful for string processing -# APIs where literalness of return value depends on literalness of inputs -StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001 - -# Objects suitable to be passed to sys.setprofile, threading.setprofile, and similar -ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object] - -# Objects suitable to be passed to sys.settrace, threading.settrace, and similar -# TODO: Ideally this would be a recursive type alias -TraceFunction: TypeAlias = Callable[[FrameType, str, Any], Callable[[FrameType, str, Any], Any] | None] diff --git a/stubs/stdlib/abc.pyi b/stubs/stdlib/abc.pyi deleted file mode 100644 index fe2bf13..0000000 --- a/stubs/stdlib/abc.pyi +++ /dev/null @@ -1,49 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from _typeshed import Self, SupportsWrite -from collections.abc import Callable -from typing import Any, Generic, TypeVar, Optional, Literal - -_T = TypeVar("_T") -_R_co = TypeVar("_R_co", covariant=True) -_FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) - -# These definitions have special processing in mypy -class ABCMeta(type): - __abstractmethods__: frozenset[str] - if sys.version_info >= (3, 11): - def __new__( - __mcls: type[Self], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwargs: Any - ) -> Self: ... - else: - # pyright doesn't like the first parameter being called mcls, hence the `pyright: ignore` - def __new__( - mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any # pyright: ignore - ) -> Self: ... - - def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... - def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... - def _dump_registry(cls: ABCMeta, file: Optional[SupportsWrite[str]] = ...) -> None: ... - def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ... - -def abstractmethod(funcobj: _FuncT) -> _FuncT: ... - -class abstractclassmethod(classmethod[_R_co], Generic[_R_co]): - __isabstractmethod__: Literal[True] - def __init__(self: abstractclassmethod[_R_co], callable: Callable[..., _R_co]) -> None: ... - -class abstractstaticmethod(staticmethod[_R_co], Generic[_R_co]): - __isabstractmethod__: Literal[True] - def __init__(self, callable: Callable[..., _R_co]) -> None: ... - -class abstractproperty(property): - __isabstractmethod__: Literal[True] - -class ABC(metaclass=ABCMeta): ... - -def get_cache_token() -> object: ... - -if sys.version_info >= (3, 10): - def update_abstractmethods(cls: type[_T]) -> type[_T]: ... diff --git a/stubs/stdlib/array.pyi b/stubs/stdlib/array.pyi deleted file mode 100644 index 7a5e9ca..0000000 --- a/stubs/stdlib/array.pyi +++ /dev/null @@ -1 +0,0 @@ -from uarray import * diff --git a/stubs/stdlib/ast.pyi b/stubs/stdlib/ast.pyi deleted file mode 100644 index 2bb2a0a..0000000 --- a/stubs/stdlib/ast.pyi +++ /dev/null @@ -1,270 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from _ast import * -from collections.abc import Iterator -from typing import Any, TypeVar, overload, Literal, Union, Optional - -if sys.version_info >= (3, 8): - class _ABC(type): - if sys.version_info >= (3, 9): - def __init__(cls, *args: object) -> None: ... - - class Num(Constant, metaclass=_ABC): - value: complex - - class Str(Constant, metaclass=_ABC): - value: str - # Aliases for value, for backwards compatibility - s: str - - class Bytes(Constant, metaclass=_ABC): - value: bytes - # Aliases for value, for backwards compatibility - s: bytes - - class NameConstant(Constant, metaclass=_ABC): ... - class Ellipsis(Constant, metaclass=_ABC): ... - -if sys.version_info >= (3, 9): - class slice(AST): ... - class ExtSlice(slice): ... - class Index(slice): ... - class Suite(mod): ... - class AugLoad(expr_context): ... - class AugStore(expr_context): ... - class Param(expr_context): ... - -class NodeVisitor: - def visit(self, node: AST) -> Any: ... - def generic_visit(self, node: AST) -> Any: ... - def visit_Module(self, node: Module) -> Any: ... - def visit_Interactive(self, node: Interactive) -> Any: ... - def visit_Expression(self, node: Expression) -> Any: ... - def visit_FunctionDef(self, node: FunctionDef) -> Any: ... - def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> Any: ... - def visit_ClassDef(self, node: ClassDef) -> Any: ... - def visit_Return(self, node: Return) -> Any: ... - def visit_Delete(self, node: Delete) -> Any: ... - def visit_Assign(self, node: Assign) -> Any: ... - def visit_AugAssign(self, node: AugAssign) -> Any: ... - def visit_AnnAssign(self, node: AnnAssign) -> Any: ... - def visit_For(self, node: For) -> Any: ... - def visit_AsyncFor(self, node: AsyncFor) -> Any: ... - def visit_While(self, node: While) -> Any: ... - def visit_If(self, node: If) -> Any: ... - def visit_With(self, node: With) -> Any: ... - def visit_AsyncWith(self, node: AsyncWith) -> Any: ... - def visit_Raise(self, node: Raise) -> Any: ... - def visit_Try(self, node: Try) -> Any: ... - def visit_Assert(self, node: Assert) -> Any: ... - def visit_Import(self, node: Import) -> Any: ... - def visit_ImportFrom(self, node: ImportFrom) -> Any: ... - def visit_Global(self, node: Global) -> Any: ... - def visit_Nonlocal(self, node: Nonlocal) -> Any: ... - def visit_Expr(self, node: Expr) -> Any: ... - def visit_Pass(self, node: Pass) -> Any: ... - def visit_Break(self, node: Break) -> Any: ... - def visit_Continue(self, node: Continue) -> Any: ... - def visit_Slice(self, node: Slice) -> Any: ... - def visit_BoolOp(self, node: BoolOp) -> Any: ... - def visit_BinOp(self, node: BinOp) -> Any: ... - def visit_UnaryOp(self, node: UnaryOp) -> Any: ... - def visit_Lambda(self, node: Lambda) -> Any: ... - def visit_IfExp(self, node: IfExp) -> Any: ... - def visit_Dict(self, node: Dict) -> Any: ... - def visit_Set(self, node: Set) -> Any: ... - def visit_ListComp(self, node: ListComp) -> Any: ... - def visit_SetComp(self, node: SetComp) -> Any: ... - def visit_DictComp(self, node: DictComp) -> Any: ... - def visit_GeneratorExp(self, node: GeneratorExp) -> Any: ... - def visit_Await(self, node: Await) -> Any: ... - def visit_Yield(self, node: Yield) -> Any: ... - def visit_YieldFrom(self, node: YieldFrom) -> Any: ... - def visit_Compare(self, node: Compare) -> Any: ... - def visit_Call(self, node: Call) -> Any: ... - def visit_FormattedValue(self, node: FormattedValue) -> Any: ... - def visit_JoinedStr(self, node: JoinedStr) -> Any: ... - def visit_Constant(self, node: Constant) -> Any: ... - if sys.version_info >= (3, 8): - def visit_NamedExpr(self, node: NamedExpr) -> Any: ... - - def visit_Attribute(self, node: Attribute) -> Any: ... - def visit_Subscript(self, node: Subscript) -> Any: ... - def visit_Starred(self, node: Starred) -> Any: ... - def visit_Name(self, node: Name) -> Any: ... - def visit_List(self, node: List) -> Any: ... - def visit_Tuple(self, node: Tuple) -> Any: ... - def visit_Del(self, node: Del) -> Any: ... - def visit_Load(self, node: Load) -> Any: ... - def visit_Store(self, node: Store) -> Any: ... - def visit_And(self, node: And) -> Any: ... - def visit_Or(self, node: Or) -> Any: ... - def visit_Add(self, node: Add) -> Any: ... - def visit_BitAnd(self, node: BitAnd) -> Any: ... - def visit_BitOr(self, node: BitOr) -> Any: ... - def visit_BitXor(self, node: BitXor) -> Any: ... - def visit_Div(self, node: Div) -> Any: ... - def visit_FloorDiv(self, node: FloorDiv) -> Any: ... - def visit_LShift(self, node: LShift) -> Any: ... - def visit_Mod(self, node: Mod) -> Any: ... - def visit_Mult(self, node: Mult) -> Any: ... - def visit_MatMult(self, node: MatMult) -> Any: ... - def visit_Pow(self, node: Pow) -> Any: ... - def visit_RShift(self, node: RShift) -> Any: ... - def visit_Sub(self, node: Sub) -> Any: ... - def visit_Invert(self, node: Invert) -> Any: ... - def visit_Not(self, node: Not) -> Any: ... - def visit_UAdd(self, node: UAdd) -> Any: ... - def visit_USub(self, node: USub) -> Any: ... - def visit_Eq(self, node: Eq) -> Any: ... - def visit_Gt(self, node: Gt) -> Any: ... - def visit_GtE(self, node: GtE) -> Any: ... - def visit_In(self, node: In) -> Any: ... - def visit_Is(self, node: Is) -> Any: ... - def visit_IsNot(self, node: IsNot) -> Any: ... - def visit_Lt(self, node: Lt) -> Any: ... - def visit_LtE(self, node: LtE) -> Any: ... - def visit_NotEq(self, node: NotEq) -> Any: ... - def visit_NotIn(self, node: NotIn) -> Any: ... - def visit_comprehension(self, node: comprehension) -> Any: ... - def visit_ExceptHandler(self, node: ExceptHandler) -> Any: ... - def visit_arguments(self, node: arguments) -> Any: ... - def visit_arg(self, node: arg) -> Any: ... - def visit_keyword(self, node: keyword) -> Any: ... - def visit_alias(self, node: alias) -> Any: ... - def visit_withitem(self, node: withitem) -> Any: ... - # visit methods for deprecated nodes - def visit_ExtSlice(self, node: ExtSlice) -> Any: ... - def visit_Index(self, node: Index) -> Any: ... - def visit_Suite(self, node: Suite) -> Any: ... - def visit_AugLoad(self, node: AugLoad) -> Any: ... - def visit_AugStore(self, node: AugStore) -> Any: ... - def visit_Param(self, node: Param) -> Any: ... - def visit_Num(self, node: Num) -> Any: ... - def visit_Str(self, node: Str) -> Any: ... - def visit_Bytes(self, node: Bytes) -> Any: ... - def visit_NameConstant(self, node: NameConstant) -> Any: ... - def visit_Ellipsis(self, node: Ellipsis) -> Any: ... - -class NodeTransformer(NodeVisitor): - def generic_visit(self, node: AST) -> AST: ... - # TODO: Override the visit_* methods with better return types. - # The usual return type is AST | None, but Iterable[AST] - # is also allowed in some cases -- this needs to be mapped. - -_T = TypeVar("_T", bound=AST) - -if sys.version_info >= (3, 8): - @overload - def parse( - source: Union[str, bytes], - filename: Union[str, bytes] = ..., - mode: Literal["exec"] = ..., - *, - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> Module: ... - @overload - def parse( - source: Union[str, bytes], - filename: Union[str, bytes], - mode: Literal["eval"], - *, - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> Expression: ... - @overload - def parse( - source: Union[str, bytes], - filename: Union[str, bytes], - mode: Literal["func_type"], - *, - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> FunctionType: ... - @overload - def parse( - source: Union[str, bytes], - filename: Union[str, bytes], - mode: Literal["single"], - *, - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> Interactive: ... - @overload - def parse( - source: Union[str, bytes], - *, - mode: Literal["eval"], - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> Expression: ... - @overload - def parse( - source: Union[str, bytes], - *, - mode: Literal["func_type"], - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> FunctionType: ... - @overload - def parse( - source: Union[str, bytes], - *, - mode: Literal["single"], - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> Interactive: ... - @overload - def parse( - source: Union[str, bytes], - filename: Union[str, bytes] = ..., - mode: str = ..., - *, - type_comments: bool = ..., - feature_version: Optional[Union[int, tuple[int, int]]] = ..., - ) -> AST: ... - -else: - @overload - def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: Literal["exec"] = ...) -> Module: ... - @overload - def parse(source: Union[str, bytes], filename: Union[str, bytes], mode: Literal["eval"]) -> Expression: ... - @overload - def parse(source: Union[str, bytes], filename: Union[str, bytes], mode: Literal["single"]) -> Interactive: ... - @overload - def parse(source: Union[str, bytes], *, mode: Literal["eval"]) -> Expression: ... - @overload - def parse(source: Union[str, bytes], *, mode: Literal["single"]) -> Interactive: ... - @overload - def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... - -if sys.version_info >= (3, 9): - def unparse(ast_obj: AST) -> str: ... - -def copy_location(new_node: _T, old_node: AST) -> _T: ... - -if sys.version_info >= (3, 9): - def dump( - node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: Optional[Union[int, str]] = ... - ) -> str: ... - -else: - def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... - -def fix_missing_locations(node: _T) -> _T: ... -def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ... -def increment_lineno(node: _T, n: int = ...) -> _T: ... -def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... -def literal_eval(node_or_string: Union[str, AST]) -> Any: ... - -if sys.version_info >= (3, 8): - def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ... - -def walk(node: AST) -> Iterator[AST]: ... - -if sys.version_info >= (3, 9): - def main() -> None: ... diff --git a/stubs/stdlib/binascii.pyi b/stubs/stdlib/binascii.pyi deleted file mode 100644 index c907f53..0000000 --- a/stubs/stdlib/binascii.pyi +++ /dev/null @@ -1 +0,0 @@ -from ubinascii import * diff --git a/stubs/stdlib/builtins.pyi b/stubs/stdlib/builtins.pyi deleted file mode 100644 index 5ba38a1..0000000 --- a/stubs/stdlib/builtins.pyi +++ /dev/null @@ -1,1984 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -import types -from _ast import AST -from _collections_abc import dict_items, dict_keys, dict_values -from _typeshed import ( - AnyStr_co, - OpenBinaryMode, - OpenBinaryModeReading, - OpenBinaryModeUpdating, - OpenBinaryModeWriting, - OpenTextMode, - ReadableBuffer, - Self, - StrOrBytesPath, - SupportsAdd, - SupportsAiter, - SupportsAnext, - SupportsDivMod, - SupportsIter, - SupportsKeysAndGetItem, - SupportsLenAndGetItem, - SupportsNext, - SupportsRAdd, - SupportsRDivMod, - SupportsRichComparison, - SupportsRichComparisonT, - SupportsTrunc, - SupportsWrite, -) -from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized -from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper -from types import CodeType, TracebackType, _Cell - -# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping} are imported from collections.abc in builtins.pyi -from typing import ( # noqa: Y027 - IO, - Any, - BinaryIO, - ByteString, - ClassVar, - Generic, - Mapping, - MutableMapping, - MutableSequence, - NoReturn, - Protocol, - Sequence, - SupportsAbs, - SupportsBytes, - SupportsComplex, - SupportsFloat, - SupportsInt, - SupportsRound, - TypeVar, - overload, - type_check_only, - Optional, - Union, -) -from typing_extensions import Literal, LiteralString, SupportsIndex, TypeAlias, TypeGuard, final - -if sys.version_info >= (3, 9): - from types import GenericAlias - -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_T_contra = TypeVar("_T_contra", contravariant=True) -_R_co = TypeVar("_R_co", covariant=True) -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_S = TypeVar("_S") -_T1 = TypeVar("_T1") -_T2 = TypeVar("_T2") -_T3 = TypeVar("_T3") -_T4 = TypeVar("_T4") -_T5 = TypeVar("_T5") -_SupportsNextT = TypeVar("_SupportsNextT", bound=SupportsNext[Any], covariant=True) -_SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant=True) -_AwaitableT = TypeVar("_AwaitableT", bound=Awaitable[Any]) -_AwaitableT_co = TypeVar("_AwaitableT_co", bound=Awaitable[Any], covariant=True) - -class object: - __doc__: Optional[str] - __dict__: dict[str, Any] - __module__: str - __annotations__: dict[str, Any] - @property - def __class__(self: Self) -> type[Self]: ... - # Ignore errors about type mismatch between property getter and setter - @__class__.setter - def __class__(self, __type: type[object]) -> None: ... # noqa: F811 - def __init__(self) -> None: ... - def __new__(cls: type[Self]) -> Self: ... - # N.B. `object.__setattr__` and `object.__delattr__` are heavily special-cased by type checkers. - # Overriding them in subclasses has different semantics, even if the override has an identical signature. - def __setattr__(self, __name: str, __value: Any) -> None: ... - def __delattr__(self, __name: str) -> None: ... - def __eq__(self, __o: object) -> bool: ... - def __ne__(self, __o: object) -> bool: ... - def __str__(self) -> str: ... # noqa: Y029 - def __repr__(self) -> str: ... # noqa: Y029 - def __hash__(self) -> int: ... - def __format__(self, __format_spec: str) -> str: ... - def __getattribute__(self, __name: str) -> Any: ... - def __sizeof__(self) -> int: ... - # return type of pickle methods is rather hard to express in the current type system - # see #6661 and https://docs.python.org/3/library/pickle.html#object.__reduce__ - def __reduce__(self) -> Union[str, tuple[Any, ...]]: ... - if sys.version_info >= (3, 8): - def __reduce_ex__(self, __protocol: SupportsIndex) -> Union[str, tuple[Any, ...]]: ... - else: - def __reduce_ex__(self, __protocol: int) -> Union[str, tuple[Any, ...]]: ... - - def __dir__(self) -> Iterable[str]: ... - def __init_subclass__(cls) -> None: ... - -class staticmethod(Generic[_R_co]): - @property - def __func__(self) -> Callable[..., _R_co]: ... - @property - def __isabstractmethod__(self) -> bool: ... - def __init__(self: staticmethod[_R_co], __f: Callable[..., _R_co]) -> None: ... - def __get__(self, __obj: _T, __type: Optional[type[_T]] = ...) -> Callable[..., _R_co]: ... - if sys.version_info >= (3, 10): - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[..., _R_co]: ... - def __call__(self, *args: Any, **kwargs: Any) -> _R_co: ... - -class classmethod(Generic[_R_co]): - @property - def __func__(self) -> Callable[..., _R_co]: ... - @property - def __isabstractmethod__(self) -> bool: ... - def __init__(self: classmethod[_R_co], __f: Callable[..., _R_co]) -> None: ... - def __get__(self, __obj: _T, __type: Optional[type[_T]] = ...) -> Callable[..., _R_co]: ... - if sys.version_info >= (3, 10): - __name__: str - __qualname__: str - @property - def __wrapped__(self) -> Callable[..., _R_co]: ... - -class type: - @property - def __base__(self) -> type: ... - __bases__: tuple[type, ...] - @property - def __basicsize__(self) -> int: ... - @property - def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override] - @property - def __dictoffset__(self) -> int: ... - @property - def __flags__(self) -> int: ... - @property - def __itemsize__(self) -> int: ... - __module__: str - @property - def __mro__(self) -> tuple[type, ...]: ... - __name__: str - __qualname__: str - @property - def __text_signature__(self) -> Optional[str]: ... - @property - def __weakrefoffset__(self) -> int: ... - @overload - def __init__(self, __o: object) -> None: ... - @overload - def __init__(self, __name: str, __bases: tuple[type, ...], __dict: dict[str, Any], **kwds: Any) -> None: ... - @overload - def __new__(cls, __o: object) -> type: ... - @overload - def __new__(cls: type[Self], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> Self: ... - def __call__(self, *args: Any, **kwds: Any) -> Any: ... - def __subclasses__(self: Self) -> list[Self]: ... - # Note: the documentation doesn't specify what the return type is, the standard - # implementation seems to be returning a list. - def mro(self) -> list[type]: ... - def __instancecheck__(self, __instance: Any) -> bool: ... - def __subclasscheck__(self, __subclass: type) -> bool: ... - @classmethod - def __prepare__(metacls, __name: str, __bases: tuple[type, ...], **kwds: Any) -> Mapping[str, object]: ... - if sys.version_info >= (3, 10): - def __or__(self, __t: Any) -> types.UnionType: ... - def __ror__(self, __t: Any) -> types.UnionType: ... - -class super: - @overload - def __init__(self, __t: Any, __obj: Any) -> None: ... - @overload - def __init__(self, __t: Any) -> None: ... - @overload - def __init__(self) -> None: ... - -_PositiveInteger: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] -_NegativeInteger: TypeAlias = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20] -_LiteralInteger = Union[_PositiveInteger, _NegativeInteger, Literal[0]] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed - -class int: - @overload - def __new__(cls: type[Self], __x: str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> Self: ... - @overload - def __new__(cls: type[Self], __x: Union[str, bytes] | bytearray, base: SupportsIndex) -> Self: ... - if sys.version_info >= (3, 8): - def as_integer_ratio(self) -> tuple[int, Literal[1]]: ... - - @property - def real(self) -> int: ... - @property - def imag(self) -> Literal[0]: ... - @property - def numerator(self) -> int: ... - @property - def denominator(self) -> Literal[1]: ... - def conjugate(self) -> int: ... - def bit_length(self) -> int: ... - if sys.version_info >= (3, 10): - def bit_count(self) -> int: ... - - if sys.version_info >= (3, 11): - def to_bytes( - self, length: SupportsIndex = ..., byteorder: Literal["little", "big"] = ..., *, signed: bool = ... - ) -> bytes: ... - @classmethod - def from_bytes( - cls: type[Self], - bytes: Iterable[SupportsIndex] | SupportsBytes | ReadableBuffer, - byteorder: Literal["little", "big"] = ..., - *, - signed: bool = ..., - ) -> Self: ... - else: - def to_bytes(self, length: SupportsIndex, byteorder: Literal["little", "big"], *, signed: bool = ...) -> bytes: ... - @classmethod - def from_bytes( - cls: type[Self], - bytes: Iterable[SupportsIndex] | SupportsBytes | ReadableBuffer, - byteorder: Literal["little", "big"], - *, - signed: bool = ..., - ) -> Self: ... - - def __add__(self, __x: int) -> int: ... - def __sub__(self, __x: int) -> int: ... - def __mul__(self, __x: int) -> int: ... - def __floordiv__(self, __x: int) -> int: ... - def __truediv__(self, __x: int) -> float: ... - def __mod__(self, __x: int) -> int: ... - def __divmod__(self, __x: int) -> tuple[int, int]: ... - def __radd__(self, __x: int) -> int: ... - def __rsub__(self, __x: int) -> int: ... - def __rmul__(self, __x: int) -> int: ... - def __rfloordiv__(self, __x: int) -> int: ... - def __rtruediv__(self, __x: int) -> float: ... - def __rmod__(self, __x: int) -> int: ... - def __rdivmod__(self, __x: int) -> tuple[int, int]: ... - @overload - def __pow__(self, __x: Literal[0]) -> Literal[1]: ... - @overload - def __pow__(self, __x: Literal[0], __modulo: None) -> Literal[1]: ... - @overload - def __pow__(self, __x: _PositiveInteger, __modulo: None = ...) -> int: ... - @overload - def __pow__(self, __x: _NegativeInteger, __modulo: None = ...) -> float: ... - # positive x -> int; negative x -> float - # return type must be Any as `int | float` causes too many false-positive errors - @overload - def __pow__(self, __x: int, __modulo: None = ...) -> Any: ... - @overload - def __pow__(self, __x: int, __modulo: int) -> int: ... - def __rpow__(self, __x: int, __mod: int | None = ...) -> Any: ... - def __and__(self, __n: int) -> int: ... - def __or__(self, __n: int) -> int: ... - def __xor__(self, __n: int) -> int: ... - def __lshift__(self, __n: int) -> int: ... - def __rshift__(self, __n: int) -> int: ... - def __rand__(self, __n: int) -> int: ... - def __ror__(self, __n: int) -> int: ... - def __rxor__(self, __n: int) -> int: ... - def __rlshift__(self, __n: int) -> int: ... - def __rrshift__(self, __n: int) -> int: ... - def __neg__(self) -> int: ... - def __pos__(self) -> int: ... - def __invert__(self) -> int: ... - def __trunc__(self) -> int: ... - def __ceil__(self) -> int: ... - def __floor__(self) -> int: ... - def __round__(self, __ndigits: SupportsIndex = ...) -> int: ... - def __getnewargs__(self) -> tuple[int]: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... - def __lt__(self, __x: int) -> bool: ... - def __le__(self, __x: int) -> bool: ... - def __gt__(self, __x: int) -> bool: ... - def __ge__(self, __x: int) -> bool: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - def __abs__(self) -> int: ... - def __bool__(self) -> bool: ... - def __index__(self) -> int: ... - -class float: - def __new__(cls: type[Self], x: SupportsFloat | SupportsIndex | str | ReadableBuffer = ...) -> Self: ... - def as_integer_ratio(self) -> tuple[int, int]: ... - def hex(self) -> str: ... - def is_integer(self) -> bool: ... - @classmethod - def fromhex(cls: type[Self], __s: str) -> Self: ... - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def conjugate(self) -> float: ... - def __add__(self, __x: float) -> float: ... - def __sub__(self, __x: float) -> float: ... - def __mul__(self, __x: float) -> float: ... - def __floordiv__(self, __x: float) -> float: ... - def __truediv__(self, __x: float) -> float: ... - def __mod__(self, __x: float) -> float: ... - def __divmod__(self, __x: float) -> tuple[float, float]: ... - @overload - def __pow__(self, __x: int, __mod: None = ...) -> float: ... - # positive x -> float; negative x -> complex - # return type must be Any as `float | complex` causes too many false-positive errors - @overload - def __pow__(self, __x: float, __mod: None = ...) -> Any: ... - def __radd__(self, __x: float) -> float: ... - def __rsub__(self, __x: float) -> float: ... - def __rmul__(self, __x: float) -> float: ... - def __rfloordiv__(self, __x: float) -> float: ... - def __rtruediv__(self, __x: float) -> float: ... - def __rmod__(self, __x: float) -> float: ... - def __rdivmod__(self, __x: float) -> tuple[float, float]: ... - @overload - def __rpow__(self, __x: _PositiveInteger, __modulo: None = ...) -> float: ... - @overload - def __rpow__(self, __x: _NegativeInteger, __mod: None = ...) -> complex: ... - # Returning `complex` for the general case gives too many false-positive errors. - @overload - def __rpow__(self, __x: float, __mod: None = ...) -> Any: ... - def __getnewargs__(self) -> tuple[float]: ... - def __trunc__(self) -> int: ... - if sys.version_info >= (3, 9): - def __ceil__(self) -> int: ... - def __floor__(self) -> int: ... - - @overload - def __round__(self, __ndigits: None = ...) -> int: ... - @overload - def __round__(self, __ndigits: SupportsIndex) -> float: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... - def __lt__(self, __x: float) -> bool: ... - def __le__(self, __x: float) -> bool: ... - def __gt__(self, __x: float) -> bool: ... - def __ge__(self, __x: float) -> bool: ... - def __neg__(self) -> float: ... - def __pos__(self) -> float: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __abs__(self) -> float: ... - def __bool__(self) -> bool: ... - -class complex: - if sys.version_info >= (3, 8): - # Python doesn't currently accept SupportsComplex for the second argument - @overload - def __new__( - cls: type[Self], - real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ..., - imag: complex | SupportsFloat | SupportsIndex = ..., - ) -> Self: ... - @overload - def __new__(cls: type[Self], real: str | SupportsComplex | SupportsFloat | SupportsIndex | complex) -> Self: ... - else: - @overload - def __new__( - cls: type[Self], real: complex | SupportsComplex | SupportsFloat = ..., imag: complex | SupportsFloat = ... - ) -> Self: ... - @overload - def __new__(cls: type[Self], real: str | SupportsComplex | SupportsFloat | complex) -> Self: ... - - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def conjugate(self) -> complex: ... - def __add__(self, __x: complex) -> complex: ... - def __sub__(self, __x: complex) -> complex: ... - def __mul__(self, __x: complex) -> complex: ... - def __pow__(self, __x: complex, __mod: None = ...) -> complex: ... - def __truediv__(self, __x: complex) -> complex: ... - def __radd__(self, __x: complex) -> complex: ... - def __rsub__(self, __x: complex) -> complex: ... - def __rmul__(self, __x: complex) -> complex: ... - def __rpow__(self, __x: complex, __mod: None = ...) -> complex: ... - def __rtruediv__(self, __x: complex) -> complex: ... - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... - def __neg__(self) -> complex: ... - def __pos__(self) -> complex: ... - def __abs__(self) -> float: ... - def __bool__(self) -> bool: ... - if sys.version_info >= (3, 11): - def __complex__(self) -> complex: ... - -class _FormatMapMapping(Protocol): - def __getitem__(self, __key: str) -> Any: ... - -class _TranslateTable(Protocol): - def __getitem__(self, __key: int) -> str | int | None: ... - -class str(Sequence[str]): - @overload - def __new__(cls: type[Self], object: object = ...) -> Self: ... - @overload - def __new__(cls: type[Self], object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ... - @overload - def capitalize(self: LiteralString) -> LiteralString: ... - @overload - def capitalize(self) -> str: ... # type: ignore[misc] - @overload - def casefold(self: LiteralString) -> LiteralString: ... - @overload - def casefold(self) -> str: ... # type: ignore[misc] - @overload - def center(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ... - @overload - def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc] - def count(self, x: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... - def encode(self, encoding: str = ..., errors: str = ...) -> bytes: ... - def endswith( - self, __suffix: Union[str, tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> bool: ... - if sys.version_info >= (3, 8): - @overload - def expandtabs(self: LiteralString, tabsize: SupportsIndex = ...) -> LiteralString: ... - @overload - def expandtabs(self, tabsize: SupportsIndex = ...) -> str: ... # type: ignore[misc] - else: - @overload - def expandtabs(self: LiteralString, tabsize: int = ...) -> LiteralString: ... - @overload - def expandtabs(self, tabsize: int = ...) -> str: ... # type: ignore[misc] - - def find(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... - @overload - def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ... - @overload - def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore[misc] - def format_map(self, map: _FormatMapMapping) -> str: ... - def index(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isascii(self) -> bool: ... - def isdecimal(self) -> bool: ... - def isdigit(self) -> bool: ... - def isidentifier(self) -> bool: ... - def islower(self) -> bool: ... - def isnumeric(self) -> bool: ... - def isprintable(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - @overload - def join(self: LiteralString, __iterable: Iterable[LiteralString]) -> LiteralString: ... - @overload - def join(self, __iterable: Iterable[str]) -> str: ... # type: ignore[misc] - @overload - def ljust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ... - @overload - def ljust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc] - @overload - def lower(self: LiteralString) -> LiteralString: ... - @overload - def lower(self) -> str: ... # type: ignore[misc] - @overload - def lstrip(self: LiteralString, __chars: Optional[LiteralString] = ...) -> LiteralString: ... - @overload - def lstrip(self, __chars: Optional[str] = ...) -> str: ... # type: ignore[misc] - @overload - def partition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ... - @overload - def partition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc] - @overload - def replace( - self: LiteralString, __old: LiteralString, __new: LiteralString, __count: SupportsIndex = ... - ) -> LiteralString: ... - @overload - def replace(self, __old: str, __new: str, __count: SupportsIndex = ...) -> str: ... # type: ignore[misc] - if sys.version_info >= (3, 9): - @overload - def removeprefix(self: LiteralString, __prefix: LiteralString) -> LiteralString: ... - @overload - def removeprefix(self, __prefix: str) -> str: ... # type: ignore[misc] - @overload - def removesuffix(self: LiteralString, __suffix: LiteralString) -> LiteralString: ... - @overload - def removesuffix(self, __suffix: str) -> str: ... # type: ignore[misc] - - def rfind(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... - def rindex(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... - @overload - def rjust(self: LiteralString, __width: SupportsIndex, __fillchar: LiteralString = ...) -> LiteralString: ... - @overload - def rjust(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... # type: ignore[misc] - @overload - def rpartition(self: LiteralString, __sep: LiteralString) -> tuple[LiteralString, LiteralString, LiteralString]: ... - @overload - def rpartition(self, __sep: str) -> tuple[str, str, str]: ... # type: ignore[misc] - @overload - def rsplit(self: LiteralString, sep: Optional[LiteralString] = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ... - @overload - def rsplit(self, sep: Optional[str] = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc] - @overload - def rstrip(self: LiteralString, __chars: Optional[LiteralString] = ...) -> LiteralString: ... - @overload - def rstrip(self, __chars: Optional[str] = ...) -> str: ... # type: ignore[misc] - @overload - def split(self: LiteralString, sep: Optional[LiteralString] = ..., maxsplit: SupportsIndex = ...) -> list[LiteralString]: ... - @overload - def split(self, sep: Optional[str] = ..., maxsplit: SupportsIndex = ...) -> list[str]: ... # type: ignore[misc] - @overload - def splitlines(self: LiteralString, keepends: bool = ...) -> list[LiteralString]: ... - @overload - def splitlines(self, keepends: bool = ...) -> list[str]: ... # type: ignore[misc] - def startswith( - self, __prefix: Union[str, tuple[str, ...]], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> bool: ... - @overload - def strip(self: LiteralString, __chars: Optional[LiteralString] = ...) -> LiteralString: ... - @overload - def strip(self, __chars: Optional[str] = ...) -> str: ... # type: ignore[misc] - @overload - def swapcase(self: LiteralString) -> LiteralString: ... - @overload - def swapcase(self) -> str: ... # type: ignore[misc] - @overload - def title(self: LiteralString) -> LiteralString: ... - @overload - def title(self) -> str: ... # type: ignore[misc] - def translate(self, __table: _TranslateTable) -> str: ... - @overload - def upper(self: LiteralString) -> LiteralString: ... - @overload - def upper(self) -> str: ... # type: ignore[misc] - @overload - def zfill(self: LiteralString, __width: SupportsIndex) -> LiteralString: ... - @overload - def zfill(self, __width: SupportsIndex) -> str: ... # type: ignore[misc] - @staticmethod - @overload - def maketrans(__x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ... - @staticmethod - @overload - def maketrans(__x: str, __y: str, __z: Optional[str] = ...) -> dict[int, int | None]: ... - @overload - def __add__(self: LiteralString, __s: LiteralString) -> LiteralString: ... - @overload - def __add__(self, __s: str) -> str: ... # type: ignore[misc] - # Incompatible with Sequence.__contains__ - def __contains__(self, __o: str) -> bool: ... # type: ignore[override] - def __eq__(self, __x: object) -> bool: ... - def __ge__(self, __x: str) -> bool: ... - def __getitem__(self, __i: Union[SupportsIndex, slice]) -> str: ... - def __gt__(self, __x: str) -> bool: ... - @overload - def __iter__(self: LiteralString) -> Iterator[LiteralString]: ... - @overload - def __iter__(self) -> Iterator[str]: ... # type: ignore[misc] - def __le__(self, __x: str) -> bool: ... - def __len__(self) -> int: ... - def __lt__(self, __x: str) -> bool: ... - @overload - def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ... - @overload - def __mod__(self, __x: Any) -> str: ... # type: ignore[misc] - @overload - def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ... - @overload - def __mul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc] - def __ne__(self, __x: object) -> bool: ... - @overload - def __rmul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ... - @overload - def __rmul__(self, __n: SupportsIndex) -> str: ... # type: ignore[misc] - def __getnewargs__(self) -> tuple[str]: ... - -class bytes(ByteString): - @overload - def __new__(cls: type[Self], __ints: Iterable[SupportsIndex]) -> Self: ... - @overload - def __new__(cls: type[Self], __string: str, encoding: str, errors: str = ...) -> Self: ... - @overload - def __new__(cls: type[Self], __length: SupportsIndex) -> Self: ... - @overload - def __new__(cls: type[Self]) -> Self: ... - @overload - def __new__(cls: type[Self], __o: SupportsBytes) -> Self: ... - def capitalize(self) -> bytes: ... - def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... - def count( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def decode(self, encoding: str = ..., errors: str = ...) -> str: ... - def endswith( - self, - __suffix: Union[ReadableBuffer, tuple[ReadableBuffer, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., - ) -> bool: ... - if sys.version_info >= (3, 8): - def expandtabs(self, tabsize: SupportsIndex = ...) -> bytes: ... - else: - def expandtabs(self, tabsize: int = ...) -> bytes: ... - - def find( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... - else: - def hex(self) -> str: ... - - def index( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isascii(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, __iterable_of_bytes: Iterable[ReadableBuffer]) -> bytes: ... - def ljust(self, __width: SupportsIndex, __fillchar: Union[bytes, bytearray] = ...) -> bytes: ... - def lower(self) -> bytes: ... - def lstrip(self, __bytes: Optional[ReadableBuffer] = ...) -> bytes: ... - def partition(self, __sep: ReadableBuffer) -> tuple[bytes, bytes, bytes]: ... - def replace(self, __old: ReadableBuffer, __new: ReadableBuffer, __count: SupportsIndex = ...) -> bytes: ... - if sys.version_info >= (3, 9): - def removeprefix(self, __prefix: ReadableBuffer) -> bytes: ... - def removesuffix(self, __suffix: ReadableBuffer) -> bytes: ... - - def rfind( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def rindex( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def rjust(self, __width: SupportsIndex, __fillchar: Union[bytes, bytearray] = ...) -> bytes: ... - def rpartition(self, __sep: ReadableBuffer) -> tuple[bytes, bytes, bytes]: ... - def rsplit(self, sep: Optional[ReadableBuffer] = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ... - def rstrip(self, __bytes: Optional[ReadableBuffer] = ...) -> bytes: ... - def split(self, sep: Optional[ReadableBuffer] = ..., maxsplit: SupportsIndex = ...) -> list[bytes]: ... - def splitlines(self, keepends: bool = ...) -> list[bytes]: ... - def startswith( - self, - __prefix: Union[ReadableBuffer, tuple[ReadableBuffer, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., - ) -> bool: ... - def strip(self, __bytes: Optional[ReadableBuffer] = ...) -> bytes: ... - def swapcase(self) -> bytes: ... - def title(self) -> bytes: ... - def translate(self, __table: Optional[ReadableBuffer], delete: bytes = ...) -> bytes: ... - def upper(self) -> bytes: ... - def zfill(self, __width: SupportsIndex) -> bytes: ... - @classmethod - def fromhex(cls: type[Self], __s: str) -> Self: ... - @staticmethod - def maketrans(__frm: ReadableBuffer, __to: ReadableBuffer) -> bytes: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - @overload - def __getitem__(self, __i: SupportsIndex) -> int: ... - @overload - def __getitem__(self, __s: slice) -> bytes: ... - def __add__(self, __s: ReadableBuffer) -> bytes: ... - def __mul__(self, __n: SupportsIndex) -> bytes: ... - def __rmul__(self, __n: SupportsIndex) -> bytes: ... - def __mod__(self, __value: Any) -> bytes: ... - # Incompatible with Sequence.__contains__ - def __contains__(self, __o: Union[SupportsIndex, bytes]) -> bool: ... # type: ignore[override] - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... - def __lt__(self, __x: bytes) -> bool: ... - def __le__(self, __x: bytes) -> bool: ... - def __gt__(self, __x: bytes) -> bool: ... - def __ge__(self, __x: bytes) -> bool: ... - def __getnewargs__(self) -> tuple[bytes]: ... - if sys.version_info >= (3, 11): - def __bytes__(self) -> bytes: ... - -class bytearray(MutableSequence[int], ByteString): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, __ints: Iterable[SupportsIndex]) -> None: ... - @overload - def __init__(self, __string: str, encoding: str, errors: str = ...) -> None: ... - @overload - def __init__(self, __length: SupportsIndex) -> None: ... - def append(self, __item: SupportsIndex) -> None: ... - def capitalize(self) -> bytearray: ... - def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ... - def count( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def copy(self) -> bytearray: ... - def decode(self, encoding: str = ..., errors: str = ...) -> str: ... - def endswith( - self, - __suffix: Union[ReadableBuffer, tuple[ReadableBuffer, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., - ) -> bool: ... - if sys.version_info >= (3, 8): - def expandtabs(self, tabsize: SupportsIndex = ...) -> bytearray: ... - else: - def expandtabs(self, tabsize: int = ...) -> bytearray: ... - - def extend(self, __iterable_of_ints: Iterable[SupportsIndex]) -> None: ... - def find( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... - else: - def hex(self) -> str: ... - - def index( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def insert(self, __index: SupportsIndex, __item: SupportsIndex) -> None: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isascii(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, __iterable_of_bytes: Iterable[ReadableBuffer]) -> bytearray: ... - def ljust(self, __width: SupportsIndex, __fillchar: Union[bytes, bytearray] = ...) -> bytearray: ... - def lower(self) -> bytearray: ... - def lstrip(self, __bytes: Optional[ReadableBuffer] = ...) -> bytearray: ... - def partition(self, __sep: ReadableBuffer) -> tuple[bytearray, bytearray, bytearray]: ... - def pop(self, __index: int = ...) -> int: ... - def remove(self, __value: int) -> None: ... - if sys.version_info >= (3, 9): - def removeprefix(self, __prefix: ReadableBuffer) -> bytearray: ... - def removesuffix(self, __suffix: ReadableBuffer) -> bytearray: ... - - def replace(self, __old: ReadableBuffer, __new: ReadableBuffer, __count: SupportsIndex = ...) -> bytearray: ... - def rfind( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def rindex( - self, __sub: Union[ReadableBuffer, SupportsIndex], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... - ) -> int: ... - def rjust(self, __width: SupportsIndex, __fillchar: Union[bytes, bytearray] = ...) -> bytearray: ... - def rpartition(self, __sep: ReadableBuffer) -> tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[ReadableBuffer] = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ... - def rstrip(self, __bytes: Optional[ReadableBuffer] = ...) -> bytearray: ... - def split(self, sep: Optional[ReadableBuffer] = ..., maxsplit: SupportsIndex = ...) -> list[bytearray]: ... - def splitlines(self, keepends: bool = ...) -> list[bytearray]: ... - def startswith( - self, - __prefix: Union[ReadableBuffer, tuple[ReadableBuffer, ...]], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., - ) -> bool: ... - def strip(self, __bytes: Optional[ReadableBuffer] = ...) -> bytearray: ... - def swapcase(self) -> bytearray: ... - def title(self) -> bytearray: ... - def translate(self, __table: Optional[ReadableBuffer], delete: bytes = ...) -> bytearray: ... - def upper(self) -> bytearray: ... - def zfill(self, __width: SupportsIndex) -> bytearray: ... - @classmethod - def fromhex(cls: type[Self], __string: str) -> Self: ... - @staticmethod - def maketrans(__frm: ReadableBuffer, __to: ReadableBuffer) -> bytes: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - @overload - def __getitem__(self, __i: SupportsIndex) -> int: ... - @overload - def __getitem__(self, __s: slice) -> bytearray: ... - @overload - def __setitem__(self, __i: SupportsIndex, __x: SupportsIndex) -> None: ... - @overload - def __setitem__(self, __s: slice, __x: Union[Iterable[SupportsIndex], bytes]) -> None: ... - def __delitem__(self, __i: Union[SupportsIndex, slice]) -> None: ... - def __add__(self, __s: ReadableBuffer) -> bytearray: ... - # The superclass wants us to accept Iterable[int], but that fails at runtime. - def __iadd__(self: Self, __s: ReadableBuffer) -> Self: ... # type: ignore[override] - def __mul__(self, __n: SupportsIndex) -> bytearray: ... - def __rmul__(self, __n: SupportsIndex) -> bytearray: ... - def __imul__(self: Self, __n: SupportsIndex) -> Self: ... - def __mod__(self, __value: Any) -> bytes: ... - # Incompatible with Sequence.__contains__ - def __contains__(self, __o: Union[SupportsIndex, ReadableBuffer]) -> bool: ... # type: ignore[override] - def __eq__(self, __x: object) -> bool: ... - def __ne__(self, __x: object) -> bool: ... - def __lt__(self, __x: bytes) -> bool: ... - def __le__(self, __x: bytes) -> bool: ... - def __gt__(self, __x: bytes) -> bool: ... - def __ge__(self, __x: bytes) -> bool: ... - def __alloc__(self) -> int: ... - -@final -class memoryview(Sized, Sequence[int]): - @property - def format(self) -> str: ... - @property - def itemsize(self) -> int: ... - @property - def shape(self) -> Optional[tuple[int, ...]]: ... - @property - def strides(self) -> Optional[tuple[int, ...]]: ... - @property - def suboffsets(self) -> Optional[tuple[int, ...]]: ... - @property - def readonly(self) -> bool: ... - @property - def ndim(self) -> int: ... - @property - def obj(self) -> Union[bytes, bytearray]: ... - @property - def c_contiguous(self) -> bool: ... - @property - def f_contiguous(self) -> bool: ... - @property - def contiguous(self) -> bool: ... - @property - def nbytes(self) -> int: ... - def __init__(self, obj: ReadableBuffer) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, __exc_type: type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None - ) -> None: ... - def cast(self, format: str, shape: list[int] | tuple[int, ...] = ...) -> memoryview: ... - @overload - def __getitem__(self, __i: SupportsIndex) -> int: ... - @overload - def __getitem__(self, __s: slice) -> memoryview: ... - def __contains__(self, __x: object) -> bool: ... - def __iter__(self) -> Iterator[int]: ... - def __len__(self) -> int: ... - @overload - def __setitem__(self, __s: slice, __o: ReadableBuffer) -> None: ... - @overload - def __setitem__(self, __i: SupportsIndex, __o: SupportsIndex) -> None: ... - if sys.version_info >= (3, 8): - def tobytes(self, order: Literal["C", "F", "A"] | None = ...) -> bytes: ... - else: - def tobytes(self) -> bytes: ... - - def tolist(self) -> list[int]: ... - if sys.version_info >= (3, 8): - def toreadonly(self) -> memoryview: ... - - def release(self) -> None: ... - if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: SupportsIndex = ...) -> str: ... - else: - def hex(self) -> str: ... - -@final -class bool(int): - def __new__(cls: type[Self], __o: object = ...) -> Self: ... - # The following overloads could be represented more elegantly with a TypeVar("_B", bool, int), - # however mypy has a bug regarding TypeVar constraints (https://github.com/python/mypy/issues/11880). - @overload - def __and__(self, __x: bool) -> bool: ... - @overload - def __and__(self, __x: int) -> int: ... - @overload - def __or__(self, __x: bool) -> bool: ... - @overload - def __or__(self, __x: int) -> int: ... - @overload - def __xor__(self, __x: bool) -> bool: ... - @overload - def __xor__(self, __x: int) -> int: ... - @overload - def __rand__(self, __x: bool) -> bool: ... - @overload - def __rand__(self, __x: int) -> int: ... - @overload - def __ror__(self, __x: bool) -> bool: ... - @overload - def __ror__(self, __x: int) -> int: ... - @overload - def __rxor__(self, __x: bool) -> bool: ... - @overload - def __rxor__(self, __x: int) -> int: ... - def __getnewargs__(self) -> tuple[int]: ... - -@final -class slice: - @property - def start(self) -> Any: ... - @property - def step(self) -> Any: ... - @property - def stop(self) -> Any: ... - @overload - def __init__(self, __stop: Any) -> None: ... - @overload - def __init__(self, __start: Any, __stop: Any, __step: Any = ...) -> None: ... - __hash__: ClassVar[None] # type: ignore[assignment] - def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ... - -class tuple(Sequence[_T_co], Generic[_T_co]): - def __new__(cls: type[Self], __iterable: Iterable[_T_co] = ...) -> Self: ... - def __len__(self) -> int: ... - def __contains__(self, __x: object) -> bool: ... - @overload - def __getitem__(self, __x: SupportsIndex) -> _T_co: ... - @overload - def __getitem__(self, __x: slice) -> tuple[_T_co, ...]: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __lt__(self, __x: tuple[_T_co, ...]) -> bool: ... - def __le__(self, __x: tuple[_T_co, ...]) -> bool: ... - def __gt__(self, __x: tuple[_T_co, ...]) -> bool: ... - def __ge__(self, __x: tuple[_T_co, ...]) -> bool: ... - @overload - def __add__(self, __x: tuple[_T_co, ...]) -> tuple[_T_co, ...]: ... - @overload - def __add__(self, __x: tuple[_T, ...]) -> tuple[_T_co | _T, ...]: ... - def __mul__(self, __n: SupportsIndex) -> tuple[_T_co, ...]: ... - def __rmul__(self, __n: SupportsIndex) -> tuple[_T_co, ...]: ... - def count(self, __value: Any) -> int: ... - def index(self, __value: Any, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -# Doesn't exist at runtime, but deleting this breaks mypy. See #2999 -@final -@type_check_only -class function: - # Make sure this class definition stays roughly in line with `types.FunctionType` - @property - def __closure__(self) -> tuple[_Cell, ...] | None: ... - __code__: CodeType - __defaults__: tuple[Any, ...] | None - __dict__: dict[str, Any] - @property - def __globals__(self) -> dict[str, Any]: ... - __name__: str - __qualname__: str - __annotations__: dict[str, Any] - __kwdefaults__: dict[str, Any] - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... - - __module__: str - # mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any. - def __get__(self, obj: object | None, type: type | None = ...) -> Any: ... - -class list(MutableSequence[_T], Generic[_T]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, __iterable: Iterable[_T]) -> None: ... - def copy(self) -> list[_T]: ... - def append(self, __object: _T) -> None: ... - def extend(self, __iterable: Iterable[_T]) -> None: ... - def pop(self, __index: SupportsIndex = ...) -> _T: ... - # Signature of `list.index` should be kept in line with `collections.UserList.index()` - # and multiprocessing.managers.ListProxy.index() - def index(self, __value: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... - def count(self, __value: _T) -> int: ... - def insert(self, __index: SupportsIndex, __object: _T) -> None: ... - def remove(self, __value: _T) -> None: ... - # Signature of `list.sort` should be kept inline with `collections.UserList.sort()` - # and multiprocessing.managers.ListProxy.sort() - # - # Use list[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison] - # to work around invariance - @overload - def sort(self: list[SupportsRichComparisonT], *, key: None = ..., reverse: bool = ...) -> None: ... - @overload - def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - @overload - def __getitem__(self, __i: SupportsIndex) -> _T: ... - @overload - def __getitem__(self, __s: slice) -> list[_T]: ... - @overload - def __setitem__(self, __i: SupportsIndex, __o: _T) -> None: ... - @overload - def __setitem__(self, __s: slice, __o: Iterable[_T]) -> None: ... - def __delitem__(self, __i: Union[SupportsIndex, slice]) -> None: ... - # Overloading looks unnecessary, but is needed to work around complex mypy problems - @overload - def __add__(self, __x: list[_T]) -> list[_T]: ... - @overload - def __add__(self, __x: list[_S]) -> list[_S | _T]: ... - def __iadd__(self: Self, __x: Iterable[_T]) -> Self: ... # type: ignore[misc] - def __mul__(self, __n: SupportsIndex) -> list[_T]: ... - def __rmul__(self, __n: SupportsIndex) -> list[_T]: ... - def __imul__(self: Self, __n: SupportsIndex) -> Self: ... - def __contains__(self, __o: object) -> bool: ... - def __reversed__(self) -> Iterator[_T]: ... - def __gt__(self, __x: list[_T]) -> bool: ... - def __ge__(self, __x: list[_T]) -> bool: ... - def __lt__(self, __x: list[_T]) -> bool: ... - def __le__(self, __x: list[_T]) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics - # Also multiprocessing.managers.SyncManager.dict() - @overload - def __init__(self) -> None: ... - @overload - def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, __map: SupportsKeysAndGetItem[_KT, _VT]) -> None: ... - @overload - def __init__(self: dict[str, _VT], __map: SupportsKeysAndGetItem[str, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ... - @overload - def __init__(self: dict[str, _VT], __iterable: Iterable[tuple[str, _VT]], **kwargs: _VT) -> None: ... - # Next overload is for dict(string.split(sep) for string in iterable) - # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error - @overload - def __init__(self: dict[str, str], __iterable: Iterable[list[str]]) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def copy(self) -> dict[_KT, _VT]: ... - def keys(self) -> dict_keys[_KT, _VT]: ... - def values(self) -> dict_values[_KT, _VT]: ... - def items(self) -> dict_items[_KT, _VT]: ... - # Signature of `dict.fromkeys` should be kept identical to `fromkeys` methods of `OrderedDict`/`ChainMap`/`UserDict` in `collections` - # TODO: the true signature of `dict.fromkeys` is not expressible in the current type system. - # See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963. - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T], __value: None = ...) -> dict[_T, Any | None]: ... - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> dict[_T, _S]: ... - # Positional-only in dict, but not in MutableMapping - @overload - def get(self, __key: _KT) -> _VT | None: ... - @overload - def get(self, __key: _KT, __default: _VT | _T) -> _VT | _T: ... - @overload - def pop(self, __key: _KT) -> _VT: ... - @overload - def pop(self, __key: _KT, __default: _VT | _T) -> _VT | _T: ... - def __len__(self) -> int: ... - def __getitem__(self, __key: _KT) -> _VT: ... - def __setitem__(self, __key: _KT, __value: _VT) -> None: ... - def __delitem__(self, __key: _KT) -> None: ... - def __iter__(self) -> Iterator[_KT]: ... - if sys.version_info >= (3, 8): - def __reversed__(self) -> Iterator[_KT]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ... - def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ... - # dict.__ior__ should be kept roughly in line with MutableMapping.update() - @overload # type: ignore[misc] - def __ior__(self: Self, __value: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ... - @overload - def __ior__(self: Self, __value: Iterable[tuple[_KT, _VT]]) -> Self: ... - -class set(MutableSet[_T], Generic[_T]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, __iterable: Iterable[_T]) -> None: ... - def add(self, __element: _T) -> None: ... - def copy(self) -> set[_T]: ... - def difference(self, *s: Iterable[Any]) -> set[_T]: ... - def difference_update(self, *s: Iterable[Any]) -> None: ... - def discard(self, __element: _T) -> None: ... - def intersection(self, *s: Iterable[Any]) -> set[_T]: ... - def intersection_update(self, *s: Iterable[Any]) -> None: ... - def isdisjoint(self, __s: Iterable[Any]) -> bool: ... - def issubset(self, __s: Iterable[Any]) -> bool: ... - def issuperset(self, __s: Iterable[Any]) -> bool: ... - def remove(self, __element: _T) -> None: ... - def symmetric_difference(self, __s: Iterable[_T]) -> set[_T]: ... - def symmetric_difference_update(self, __s: Iterable[_T]) -> None: ... - def union(self, *s: Iterable[_S]) -> set[_T | _S]: ... - def update(self, *s: Iterable[_T]) -> None: ... - def __len__(self) -> int: ... - def __contains__(self, __o: object) -> bool: ... - def __iter__(self) -> Iterator[_T]: ... - def __and__(self, __s: AbstractSet[object]) -> set[_T]: ... - def __iand__(self: Self, __s: AbstractSet[object]) -> Self: ... - def __or__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ... - def __ior__(self: Self, __s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - def __sub__(self, __s: AbstractSet[_T | None]) -> set[_T]: ... - def __isub__(self: Self, __s: AbstractSet[object]) -> Self: ... - def __xor__(self, __s: AbstractSet[_S]) -> set[_T | _S]: ... - def __ixor__(self: Self, __s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - def __le__(self, __s: AbstractSet[object]) -> bool: ... - def __lt__(self, __s: AbstractSet[object]) -> bool: ... - def __ge__(self, __s: AbstractSet[object]) -> bool: ... - def __gt__(self, __s: AbstractSet[object]) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -class frozenset(AbstractSet[_T_co], Generic[_T_co]): - @overload - def __new__(cls: type[Self]) -> Self: ... - @overload - def __new__(cls: type[Self], __iterable: Iterable[_T_co]) -> Self: ... - def copy(self) -> frozenset[_T_co]: ... - def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def isdisjoint(self, __s: Iterable[_T_co]) -> bool: ... - def issubset(self, __s: Iterable[object]) -> bool: ... - def issuperset(self, __s: Iterable[object]) -> bool: ... - def symmetric_difference(self, __s: Iterable[_T_co]) -> frozenset[_T_co]: ... - def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ... - def __len__(self) -> int: ... - def __contains__(self, __o: object) -> bool: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __and__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... - def __or__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... - def __sub__(self, __s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... - def __xor__(self, __s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... - def __le__(self, __s: AbstractSet[object]) -> bool: ... - def __lt__(self, __s: AbstractSet[object]) -> bool: ... - def __ge__(self, __s: AbstractSet[object]) -> bool: ... - def __gt__(self, __s: AbstractSet[object]) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -class enumerate(Iterator[tuple[int, _T]], Generic[_T]): - def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ... - def __iter__(self: Self) -> Self: ... - def __next__(self) -> tuple[int, _T]: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -@final -class range(Sequence[int]): - @property - def start(self) -> int: ... - @property - def stop(self) -> int: ... - @property - def step(self) -> int: ... - @overload - def __init__(self, __stop: SupportsIndex) -> None: ... - @overload - def __init__(self, __start: SupportsIndex, __stop: SupportsIndex, __step: SupportsIndex = ...) -> None: ... - def count(self, __value: int) -> int: ... - def index(self, __value: int) -> int: ... # type: ignore[override] - def __len__(self) -> int: ... - def __contains__(self, __o: object) -> bool: ... - def __iter__(self) -> Iterator[int]: ... - @overload - def __getitem__(self, __i: SupportsIndex) -> int: ... - @overload - def __getitem__(self, __s: slice) -> range: ... - def __reversed__(self) -> Iterator[int]: ... - -class property: - fget: Callable[[Any], Any] | None - fset: Callable[[Any, Any], None] | None - fdel: Callable[[Any], None] | None - __isabstractmethod__: bool - def __init__( - self, - fget: Callable[[Any], Any] | None = ..., - fset: Callable[[Any, Any], None] | None = ..., - fdel: Callable[[Any], None] | None = ..., - doc: Optional[str] = ..., - ) -> None: ... - def getter(self, __fget: Callable[[Any], Any]) -> property: ... - def setter(self, __fset: Callable[[Any, Any], None]) -> property: ... - def deleter(self, __fdel: Callable[[Any], None]) -> property: ... - def __get__(self, __obj: Any, __type: type | None = ...) -> Any: ... - def __set__(self, __obj: Any, __value: Any) -> None: ... - def __delete__(self, __obj: Any) -> None: ... - -@final -class _NotImplementedType(Any): # type: ignore[misc] - # A little weird, but typing the __call__ as NotImplemented makes the error message - # for NotImplemented() much better - __call__: NotImplemented # type: ignore[valid-type] - -NotImplemented: _NotImplementedType - -def abs(__x: SupportsAbs[_T]) -> _T: ... -def all(__iterable: Iterable[object]) -> bool: ... -def any(__iterable: Iterable[object]) -> bool: ... -def ascii(__obj: object) -> str: ... -def bin(__number: int | SupportsIndex) -> str: ... -def breakpoint(*args: Any, **kws: Any) -> None: ... -def callable(__obj: object) -> TypeGuard[Callable[..., object]]: ... -def chr(__i: int) -> str: ... - -# We define this here instead of using os.PathLike to avoid import cycle issues. -# See https://github.com/python/typeshed/pull/991#issuecomment-288160993 -class _PathLike(Protocol[AnyStr_co]): - def __fspath__(self) -> AnyStr_co: ... - -if sys.version_info >= (3, 10): - def aiter(__async_iterable: SupportsAiter[_SupportsAnextT]) -> _SupportsAnextT: ... - - class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]): - def __anext__(self) -> _AwaitableT_co: ... - - @overload - # `anext` is not, in fact, an async function. When default is not provided - # `anext` is just a passthrough for `obj.__anext__` - # See discussion in #7491 and pure-Python implementation of `anext` at https://github.com/python/cpython/blob/ea786a882b9ed4261eafabad6011bc7ef3b5bf94/Lib/test/test_asyncgen.py#L52-L80 - def anext(__i: _SupportsSynchronousAnext[_AwaitableT]) -> _AwaitableT: ... - @overload - async def anext(__i: SupportsAnext[_T], default: _VT) -> _T | _VT: ... - -# TODO: `compile` has a more precise return type in reality; work on a way of expressing that? -if sys.version_info >= (3, 8): - def compile( - source: str | ReadableBuffer | AST, - filename: str | ReadableBuffer | _PathLike[Any], - mode: str, - flags: int = ..., - dont_inherit: int = ..., - optimize: int = ..., - *, - _feature_version: int = ..., - ) -> Any: ... - -else: - def compile( - source: str | ReadableBuffer | AST, - filename: str | ReadableBuffer | _PathLike[Any], - mode: str, - flags: int = ..., - dont_inherit: int = ..., - optimize: int = ..., - ) -> Any: ... - -def copyright() -> None: ... -def credits() -> None: ... -def delattr(__obj: object, __name: str) -> None: ... -def dir(__o: object = ...) -> list[str]: ... -@overload -def divmod(__x: SupportsDivMod[_T_contra, _T_co], __y: _T_contra) -> _T_co: ... -@overload -def divmod(__x: _T_contra, __y: SupportsRDivMod[_T_contra, _T_co]) -> _T_co: ... - -# The `globals` argument to `eval` has to be `dict[str, Any]` rather than `dict[str, object]` due to invariance. -# (The `globals` argument has to be a "real dict", rather than any old mapping, unlike the `locals` argument.) -def eval( - __source: str | ReadableBuffer | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, object] | None = ... -) -> Any: ... - -# Comment above regarding `eval` applies to `exec` as well -if sys.version_info >= (3, 11): - def exec( - __source: str | ReadableBuffer | CodeType, - __globals: dict[str, Any] | None = ..., - __locals: Mapping[str, object] | None = ..., - *, - closure: tuple[_Cell, ...] | None = ..., - ) -> None: ... - -else: - def exec( - __source: str | ReadableBuffer | CodeType, - __globals: dict[str, Any] | None = ..., - __locals: Mapping[str, object] | None = ..., - ) -> None: ... - -def exit(code: sys._ExitCode = ...) -> NoReturn: ... - -class filter(Iterator[_T], Generic[_T]): - @overload - def __init__(self, __function: None, __iterable: Iterable[_T | None]) -> None: ... - @overload - def __init__(self, __function: Callable[[_S], TypeGuard[_T]], __iterable: Iterable[_S]) -> None: ... - @overload - def __init__(self, __function: Callable[[_T], Any], __iterable: Iterable[_T]) -> None: ... - def __iter__(self: Self) -> Self: ... - def __next__(self) -> _T: ... - -def format(__value: object, __format_spec: str = ...) -> str: ... -@overload -def getattr(__o: object, __name: str) -> Any: ... - -# While technically covered by the last overload, spelling out the types for None, bool -# and basic containers help mypy out in some tricky situations involving type context -# (aka bidirectional inference) -@overload -def getattr(__o: object, __name: str, __default: None) -> Any | None: ... -@overload -def getattr(__o: object, __name: str, __default: bool) -> Any | bool: ... -@overload -def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ... -@overload -def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ... -@overload -def getattr(__o: object, __name: str, __default: _T) -> Any | _T: ... -def globals() -> dict[str, Any]: ... -def hasattr(__obj: object, __name: str) -> bool: ... -def hash(__obj: object) -> int: ... -def help(request: object = ...) -> None: ... -def hex(__number: int | SupportsIndex) -> str: ... -def id(__obj: object) -> int: ... -def input(__prompt: object = ...) -> str: ... - -class _GetItemIterable(Protocol[_T_co]): - def __getitem__(self, __i: int) -> _T_co: ... - -@overload -def iter(__iterable: SupportsIter[_SupportsNextT]) -> _SupportsNextT: ... -@overload -def iter(__iterable: _GetItemIterable[_T]) -> Iterator[_T]: ... -@overload -def iter(__function: Callable[[], _T | None], __sentinel: None) -> Iterator[_T]: ... -@overload -def iter(__function: Callable[[], _T], __sentinel: object) -> Iterator[_T]: ... - -# We need recursive types to express the type of the second argument to `isinstance` properly, hence the use of `Any` -if sys.version_info >= (3, 10): - def isinstance( - __obj: object, __class_or_tuple: type | types.UnionType | tuple[type | types.UnionType | tuple[Any, ...], ...] - ) -> bool: ... - def issubclass( - __cls: type, __class_or_tuple: type | types.UnionType | tuple[type | types.UnionType | tuple[Any, ...], ...] - ) -> bool: ... - -else: - def isinstance(__obj: object, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... - def issubclass(__cls: type, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... - -def len(__obj: Sized) -> int: ... -def license() -> None: ... -def locals() -> dict[str, Any]: ... - -class map(Iterator[_S], Generic[_S]): - @overload - def __init__(self, __func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> None: ... - @overload - def __init__(self, __func: Callable[[_T1, _T2], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> None: ... - @overload - def __init__( - self, __func: Callable[[_T1, _T2, _T3], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3] - ) -> None: ... - @overload - def __init__( - self, - __func: Callable[[_T1, _T2, _T3, _T4], _S], - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - ) -> None: ... - @overload - def __init__( - self, - __func: Callable[[_T1, _T2, _T3, _T4, _T5], _S], - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], - ) -> None: ... - @overload - def __init__( - self, - __func: Callable[..., _S], - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], - ) -> None: ... - def __iter__(self: Self) -> Self: ... - def __next__(self) -> _S: ... - -@overload -def max( - __arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = ... -) -> SupportsRichComparisonT: ... -@overload -def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsRichComparison]) -> _T: ... -@overload -def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT: ... -@overload -def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison]) -> _T: ... -@overload -def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: _T) -> SupportsRichComparisonT | _T: ... -@overload -def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsRichComparison], default: _T2) -> _T1 | _T2: ... -@overload -def min( - __arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = ... -) -> SupportsRichComparisonT: ... -@overload -def min(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsRichComparison]) -> _T: ... -@overload -def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT: ... -@overload -def min(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison]) -> _T: ... -@overload -def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: _T) -> SupportsRichComparisonT | _T: ... -@overload -def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsRichComparison], default: _T2) -> _T1 | _T2: ... -@overload -def next(__i: SupportsNext[_T]) -> _T: ... -@overload -def next(__i: SupportsNext[_T], __default: _VT) -> _T | _VT: ... -def oct(__number: int | SupportsIndex) -> str: ... - -_OpenFile = StrOrBytesPath | int # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed -_Opener: TypeAlias = Callable[[str, int], int] - -# Text mode: always returns a TextIOWrapper -@overload -def open( - file: _OpenFile, - mode: OpenTextMode = ..., - buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> TextIOWrapper: ... - -# Unbuffered binary mode: returns a FileIO -@overload -def open( - file: _OpenFile, - mode: OpenBinaryMode, - buffering: Literal[0], - encoding: None = ..., - errors: None = ..., - newline: None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> FileIO: ... - -# Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter -@overload -def open( - file: _OpenFile, - mode: OpenBinaryModeUpdating, - buffering: Literal[-1, 1] = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> BufferedRandom: ... -@overload -def open( - file: _OpenFile, - mode: OpenBinaryModeWriting, - buffering: Literal[-1, 1] = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> BufferedWriter: ... -@overload -def open( - file: _OpenFile, - mode: OpenBinaryModeReading, - buffering: Literal[-1, 1] = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> BufferedReader: ... - -# Buffering cannot be determined: fall back to BinaryIO -@overload -def open( - file: _OpenFile, - mode: OpenBinaryMode, - buffering: int = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> BinaryIO: ... - -# Fallback if mode is not specified -@overload -def open( - file: _OpenFile, - mode: str, - buffering: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - closefd: bool = ..., - opener: _Opener | None = ..., -) -> IO[Any]: ... -def ord(__c: Union[str, bytes] | bytearray) -> int: ... - -class _SupportsWriteAndFlush(SupportsWrite[_T_contra], Protocol[_T_contra]): - def flush(self) -> None: ... - -@overload -def print( - *values: object, - sep: Optional[str] = ..., - end: Optional[str] = ..., - file: SupportsWrite[str] | None = ..., - flush: Literal[False] = ..., -) -> None: ... -@overload -def print( - *values: object, sep: Optional[str] = ..., end: Optional[str] = ..., file: _SupportsWriteAndFlush[str] | None = ..., flush: bool -) -> None: ... - -_E = TypeVar("_E", contravariant=True) -_M = TypeVar("_M", contravariant=True) - -class _SupportsPow2(Protocol[_E, _T_co]): - def __pow__(self, __other: _E) -> _T_co: ... - -class _SupportsPow3NoneOnly(Protocol[_E, _T_co]): - def __pow__(self, __other: _E, __modulo: None = ...) -> _T_co: ... - -class _SupportsPow3(Protocol[_E, _M, _T_co]): - def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ... - -_SupportsSomeKindOfPow = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed - _SupportsPow2[Any, Any] | _SupportsPow3NoneOnly[Any, Any] | _SupportsPow3[Any, Any, Any] -) - -if sys.version_info >= (3, 8): - # TODO: `pow(int, int, Literal[0])` fails at runtime, - # but adding a `NoReturn` overload isn't a good solution for expressing that (see #8566). - @overload - def pow(base: int, exp: int, mod: int) -> int: ... - @overload - def pow(base: int, exp: Literal[0], mod: None = ...) -> Literal[1]: ... # type: ignore[misc] - @overload - def pow(base: int, exp: _PositiveInteger, mod: None = ...) -> int: ... # type: ignore[misc] - @overload - def pow(base: int, exp: _NegativeInteger, mod: None = ...) -> float: ... # type: ignore[misc] - # int base & positive-int exp -> int; int base & negative-int exp -> float - # return type must be Any as `int | float` causes too many false-positive errors - @overload - def pow(base: int, exp: int, mod: None = ...) -> Any: ... - @overload - def pow(base: _PositiveInteger, exp: float, mod: None = ...) -> float: ... - @overload - def pow(base: _NegativeInteger, exp: float, mod: None = ...) -> complex: ... - @overload - def pow(base: float, exp: int, mod: None = ...) -> float: ... - # float base & float exp could return float or complex - # return type must be Any (same as complex base, complex exp), - # as `float | complex` causes too many false-positive errors - @overload - def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = ...) -> Any: ... - @overload - def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = ...) -> complex: ... - @overload - def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = ...) -> _T_co: ... - @overload - def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = ...) -> _T_co: ... - @overload - def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M = ...) -> _T_co: ... - @overload - def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = ...) -> Any: ... - @overload - def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = ...) -> complex: ... - -else: - @overload - def pow(__base: int, __exp: int, __mod: int) -> int: ... - @overload - def pow(__base: int, __exp: Literal[0], __mod: None = ...) -> Literal[1]: ... # type: ignore[misc] - @overload - def pow(__base: int, __exp: _PositiveInteger, __mod: None = ...) -> int: ... # type: ignore[misc] - @overload - def pow(__base: int, __exp: _NegativeInteger, __mod: None = ...) -> float: ... # type: ignore[misc] - @overload - def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... - @overload - def pow(__base: _PositiveInteger, __exp: float, __mod: None = ...) -> float: ... - @overload - def pow(__base: _NegativeInteger, __exp: float, __mod: None = ...) -> complex: ... - @overload - def pow(__base: float, __exp: int, __mod: None = ...) -> float: ... - @overload - def pow(__base: float, __exp: complex | _SupportsSomeKindOfPow, __mod: None = ...) -> Any: ... - @overload - def pow(__base: complex, __exp: complex | _SupportsSomeKindOfPow, __mod: None = ...) -> complex: ... - @overload - def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E, __mod: None = ...) -> _T_co: ... - @overload - def pow(__base: _SupportsPow3NoneOnly[_E, _T_co], __exp: _E, __mod: None = ...) -> _T_co: ... - @overload - def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M = ...) -> _T_co: ... - @overload - def pow(__base: _SupportsSomeKindOfPow, __exp: float, __mod: None = ...) -> Any: ... - @overload - def pow(__base: _SupportsSomeKindOfPow, __exp: complex, __mod: None = ...) -> complex: ... - -def quit(code: sys._ExitCode = ...) -> NoReturn: ... - -class reversed(Iterator[_T], Generic[_T]): - @overload - def __init__(self, __sequence: Reversible[_T]) -> None: ... - @overload - def __init__(self, __sequence: SupportsLenAndGetItem[_T]) -> None: ... - def __iter__(self: Self) -> Self: ... - def __next__(self) -> _T: ... - def __length_hint__(self) -> int: ... - -def repr(__obj: object) -> str: ... -@overload -def round(number: SupportsRound[Any]) -> int: ... -@overload -def round(number: SupportsRound[Any], ndigits: None) -> int: ... -@overload -def round(number: SupportsRound[_T], ndigits: SupportsIndex) -> _T: ... - -# See https://github.com/python/typeshed/pull/6292#discussion_r748875189 -# for why arg 3 of `setattr` should be annotated with `Any` and not `object` -def setattr(__obj: object, __name: str, __value: Any) -> None: ... -@overload -def sorted( - __iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., reverse: bool = ... -) -> list[SupportsRichComparisonT]: ... -@overload -def sorted(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> list[_T]: ... - -_AddableT1 = TypeVar("_AddableT1", bound=SupportsAdd[Any, Any]) -_AddableT2 = TypeVar("_AddableT2", bound=SupportsAdd[Any, Any]) - -class _SupportsSumWithNoDefaultGiven(SupportsAdd[Any, Any], SupportsRAdd[int, Any], Protocol): ... - -_SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWithNoDefaultGiven) - -# In general, the return type of `x + x` is *not* guaranteed to be the same type as x. -# However, we can't express that in the stub for `sum()` -# without creating many false-positive errors (see #7578). -# Instead, we special-case the most common examples of this: bool and literal integers. -if sys.version_info >= (3, 8): - @overload - def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = ...) -> int: ... # type: ignore[misc] - -else: - @overload - def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = ...) -> int: ... # type: ignore[misc] - -@overload -def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ... - -if sys.version_info >= (3, 8): - @overload - def sum(__iterable: Iterable[_AddableT1], start: _AddableT2) -> _AddableT1 | _AddableT2: ... - -else: - @overload - def sum(__iterable: Iterable[_AddableT1], __start: _AddableT2) -> _AddableT1 | _AddableT2: ... - -# The argument to `vars()` has to have a `__dict__` attribute, so can't be annotated with `object` -# (A "SupportsDunderDict" protocol doesn't work) -def vars(__object: Any = ...) -> dict[str, Any]: ... - -class zip(Iterator[_T_co], Generic[_T_co]): - if sys.version_info >= (3, 10): - @overload - def __new__(cls, __iter1: Iterable[_T1], *, strict: bool = ...) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], *, strict: bool = ...) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__( - cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], *, strict: bool = ... - ) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - *, - strict: bool = ..., - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], - *, - strict: bool = ..., - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], - strict: bool = ..., - ) -> zip[tuple[Any, ...]]: ... - else: - @overload - def __new__(cls, __iter1: Iterable[_T1]) -> zip[tuple[_T1]]: ... - @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> zip[tuple[_T1, _T2]]: ... - @overload - def __new__(cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> zip[tuple[_T1, _T2, _T3]]: ... - @overload - def __new__( - cls, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] - ) -> zip[tuple[_T1, _T2, _T3, _T4]]: ... - @overload - def __new__( - cls, - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], - ) -> zip[tuple[_T1, _T2, _T3, _T4, _T5]]: ... - @overload - def __new__( - cls, - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], - ) -> zip[tuple[Any, ...]]: ... - - def __iter__(self: Self) -> Self: ... - def __next__(self) -> _T_co: ... - -# Signature of `builtins.__import__` should be kept identical to `importlib.__import__` -# Return type of `__import__` should be kept the same as return type of `importlib.import_module` -def __import__( - name: str, - globals: Mapping[str, object] | None = ..., - locals: Mapping[str, object] | None = ..., - fromlist: Sequence[str] = ..., - level: int = ..., -) -> types.ModuleType: ... -def __build_class__(__func: Callable[[], _Cell | Any], __name: str, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ... - -# Actually the type of Ellipsis is , but since it's -# not exposed anywhere under that name, we make it private here. -@final -@type_check_only -class ellipsis: ... - -Ellipsis: ellipsis - -class BaseException: - args: tuple[Any, ...] - __cause__: BaseException | None - __context__: BaseException | None - __suppress_context__: bool - __traceback__: TracebackType | None - def __init__(self, *args: object) -> None: ... - def __setstate__(self, __state: dict[str, Any] | None) -> None: ... - def with_traceback(self: Self, __tb: TracebackType | None) -> Self: ... - if sys.version_info >= (3, 11): - # only present after add_note() is called - __notes__: list[str] - def add_note(self, __note: str) -> None: ... - -class GeneratorExit(BaseException): ... -class KeyboardInterrupt(BaseException): ... - -class SystemExit(BaseException): - code: sys._ExitCode - -class Exception(BaseException): ... - -class StopIteration(Exception): - value: Any - -_StandardError = Exception - -class OSError(Exception): - errno: int - strerror: str - # filename, filename2 are actually Union[str, bytes] | None - filename: Any - filename2: Any - if sys.platform == "win32": - winerror: int - -EnvironmentError = OSError -IOError = OSError -if sys.platform == "win32": - WindowsError = OSError - -class ArithmeticError(_StandardError): ... -class AssertionError(_StandardError): ... - -class AttributeError(_StandardError): - if sys.version_info >= (3, 10): - name: str - obj: object - -class BufferError(_StandardError): ... -class EOFError(_StandardError): ... - -class ImportError(_StandardError): - def __init__(self, *args: object, name: Optional[str] = ..., path: Optional[str] = ...) -> None: ... - name: Optional[str] - path: Optional[str] - msg: str # undocumented - -class LookupError(_StandardError): ... -class MemoryError(_StandardError): ... - -class NameError(_StandardError): - if sys.version_info >= (3, 10): - name: str - -class ReferenceError(_StandardError): ... -class RuntimeError(_StandardError): ... - -class StopAsyncIteration(Exception): - value: Any - -class SyntaxError(_StandardError): - msg: str - lineno: int | None - offset: int | None - text: Optional[str] - filename: Optional[str] - if sys.version_info >= (3, 10): - end_lineno: int | None - end_offset: int | None - -class SystemError(_StandardError): ... -class TypeError(_StandardError): ... -class ValueError(_StandardError): ... -class FloatingPointError(ArithmeticError): ... -class OverflowError(ArithmeticError): ... -class ZeroDivisionError(ArithmeticError): ... -class ModuleNotFoundError(ImportError): ... -class IndexError(LookupError): ... -class KeyError(LookupError): ... -class UnboundLocalError(NameError): ... - -class BlockingIOError(OSError): - characters_written: int - -class ChildProcessError(OSError): ... -class ConnectionError(OSError): ... -class BrokenPipeError(ConnectionError): ... -class ConnectionAbortedError(ConnectionError): ... -class ConnectionRefusedError(ConnectionError): ... -class ConnectionResetError(ConnectionError): ... -class FileExistsError(OSError): ... -class FileNotFoundError(OSError): ... -class InterruptedError(OSError): ... -class IsADirectoryError(OSError): ... -class NotADirectoryError(OSError): ... -class PermissionError(OSError): ... -class ProcessLookupError(OSError): ... -class TimeoutError(OSError): ... -class NotImplementedError(RuntimeError): ... -class RecursionError(RuntimeError): ... -class IndentationError(SyntaxError): ... -class TabError(IndentationError): ... -class UnicodeError(ValueError): ... - -class UnicodeDecodeError(UnicodeError): - encoding: str - object: bytes - start: int - end: int - reason: str - def __init__(self, __encoding: str, __object: ReadableBuffer, __start: int, __end: int, __reason: str) -> None: ... - -class UnicodeEncodeError(UnicodeError): - encoding: str - object: str - start: int - end: int - reason: str - def __init__(self, __encoding: str, __object: str, __start: int, __end: int, __reason: str) -> None: ... - -class UnicodeTranslateError(UnicodeError): - encoding: None - object: str - start: int - end: int - reason: str - def __init__(self, __object: str, __start: int, __end: int, __reason: str) -> None: ... - -class Warning(Exception): ... -class UserWarning(Warning): ... -class DeprecationWarning(Warning): ... -class SyntaxWarning(Warning): ... -class RuntimeWarning(Warning): ... -class FutureWarning(Warning): ... -class PendingDeprecationWarning(Warning): ... -class ImportWarning(Warning): ... -class UnicodeWarning(Warning): ... -class BytesWarning(Warning): ... -class ResourceWarning(Warning): ... - -if sys.version_info >= (3, 10): - class EncodingWarning(Warning): ... - -if sys.version_info >= (3, 11): - _BaseExceptionT_co = TypeVar("_BaseExceptionT_co", bound=BaseException, covariant=True) - _BaseExceptionT = TypeVar("_BaseExceptionT", bound=BaseException) - _ExceptionT_co = TypeVar("_ExceptionT_co", bound=Exception, covariant=True) - _ExceptionT = TypeVar("_ExceptionT", bound=Exception) - - class BaseExceptionGroup(BaseException, Generic[_BaseExceptionT_co]): - def __new__(cls: type[Self], __message: str, __exceptions: Sequence[_BaseExceptionT_co]) -> Self: ... - @property - def message(self) -> str: ... - @property - def exceptions(self) -> tuple[_BaseExceptionT_co | BaseExceptionGroup[_BaseExceptionT_co], ...]: ... - @overload - def subgroup( - self, __condition: type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] - ) -> BaseExceptionGroup[_BaseExceptionT] | None: ... - @overload - def subgroup(self: Self, __condition: Callable[[_BaseExceptionT_co], bool]) -> Self | None: ... - @overload - def split( - self: Self, __condition: type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] - ) -> tuple[BaseExceptionGroup[_BaseExceptionT] | None, Self | None]: ... - @overload - def split(self: Self, __condition: Callable[[_BaseExceptionT_co], bool]) -> tuple[Self | None, Self | None]: ... - def derive(self: Self, __excs: Sequence[_BaseExceptionT_co]) -> Self: ... - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - - class ExceptionGroup(BaseExceptionGroup[_ExceptionT_co], Exception): - def __new__(cls: type[Self], __message: str, __exceptions: Sequence[_ExceptionT_co]) -> Self: ... - @property - def exceptions(self) -> tuple[_ExceptionT_co | ExceptionGroup[_ExceptionT_co], ...]: ... - # We accept a narrower type, but that's OK. - @overload # type: ignore[override] - def subgroup( - self, __condition: type[_ExceptionT] | tuple[type[_ExceptionT], ...] - ) -> ExceptionGroup[_ExceptionT] | None: ... - @overload - def subgroup(self: Self, __condition: Callable[[_ExceptionT_co], bool]) -> Self | None: ... - @overload # type: ignore[override] - def split( - self: Self, __condition: type[_ExceptionT] | tuple[type[_ExceptionT], ...] - ) -> tuple[ExceptionGroup[_ExceptionT] | None, Self | None]: ... - @overload - def split(self: Self, __condition: Callable[[_ExceptionT_co], bool]) -> tuple[Self | None, Self | None]: ... diff --git a/stubs/stdlib/cmath.pyi b/stubs/stdlib/cmath.pyi deleted file mode 100644 index 8234710..0000000 --- a/stubs/stdlib/cmath.pyi +++ /dev/null @@ -1,24 +0,0 @@ -import sys -from typing import SupportsComplex, SupportsFloat, Union - -e: float -pi: float -if sys.version_info >= (3, 6): - inf: float - infj: complex - nan: float - nanj: complex - tau: float - -_C = Union[SupportsFloat, SupportsComplex, complex] - - -def cos(__z: _C) -> complex: ... -def exp(__z: _C) -> complex: ... -def log(__x: _C, __y_obj: _C = ...) -> complex: ... -def log10(__z: _C) -> complex: ... -def phase(__z: _C) -> float: ... -def polar(__z: _C) -> tuple[float, float]: ... -def rect(__r: float, __phi: float) -> complex: ... -def sin(__z: _C) -> complex: ... -def sqrt(__z: _C) -> complex: ... diff --git a/stubs/stdlib/collections/__init__.pyi b/stubs/stdlib/collections/__init__.pyi deleted file mode 100644 index dcf652b..0000000 --- a/stubs/stdlib/collections/__init__.pyi +++ /dev/null @@ -1,435 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from _collections_abc import dict_items, dict_keys, dict_values -from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT -from typing import Any, Generic, NoReturn, TypeVar, overload -from typing_extensions import SupportsIndex, final - -if sys.version_info >= (3, 9): - from types import GenericAlias - -if sys.version_info >= (3, 10): - from collections.abc import ( - Callable, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableMapping, - MutableSequence, - Reversible, - Sequence, - ValuesView, - ) -else: - from _collections_abc import * - -__all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"] - -_S = TypeVar("_S") -_T = TypeVar("_T") -_T1 = TypeVar("_T1") -_T2 = TypeVar("_T2") -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_KT_co = TypeVar("_KT_co", covariant=True) -_VT_co = TypeVar("_VT_co", covariant=True) - -# namedtuple is special-cased in the type checker; the initializer is ignored. -def namedtuple( - typename: str, - field_names: str | Iterable[str], - *, - rename: bool = ..., - module: str | None = ..., - defaults: Iterable[Any] | None = ..., -) -> type[tuple[Any, ...]]: ... - -class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - data: dict[_KT, _VT] - # __init__ should be kept roughly in line with `dict.__init__`, which has the same semantics - @overload - def __init__(self, __dict: None = ...) -> None: ... - @overload - def __init__(self: UserDict[str, _VT], __dict: None = ..., **kwargs: _VT) -> None: ... - @overload - def __init__(self, __dict: SupportsKeysAndGetItem[_KT, _VT]) -> None: ... - @overload - def __init__(self: UserDict[str, _VT], __dict: SupportsKeysAndGetItem[str, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ... - @overload - def __init__(self: UserDict[str, _VT], __iterable: Iterable[tuple[str, _VT]], **kwargs: _VT) -> None: ... - @overload - def __init__(self: UserDict[str, str], __iterable: Iterable[list[str]]) -> None: ... - def __len__(self) -> int: ... - def __getitem__(self, key: _KT) -> _VT: ... - def __setitem__(self, key: _KT, item: _VT) -> None: ... - def __delitem__(self, key: _KT) -> None: ... - def __iter__(self) -> Iterator[_KT]: ... - def __contains__(self, key: object) -> bool: ... - def copy(self: Self) -> Self: ... - def __copy__(self: Self) -> Self: ... - - # `UserDict.fromkeys` has the same semantics as `dict.fromkeys`, so should be kept in line with `dict.fromkeys`. - # TODO: Much like `dict.fromkeys`, the true signature of `UserDict.fromkeys` is inexpressible in the current type system. - # See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963. - @classmethod - @overload - def fromkeys(cls, iterable: Iterable[_T], value: None = ...) -> UserDict[_T, Any | None]: ... - @classmethod - @overload - def fromkeys(cls, iterable: Iterable[_T], value: _S) -> UserDict[_T, _S]: ... - if sys.version_info >= (3, 9): - def __or__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ... - def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc] - # UserDict.__ior__ should be kept roughly in line with MutableMapping.update() - @overload # type: ignore[misc] - def __ior__(self: Self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ... - @overload - def __ior__(self: Self, other: Iterable[tuple[_KT, _VT]]) -> Self: ... - -class UserList(MutableSequence[_T]): - data: list[_T] - @overload - def __init__(self, initlist: None = ...) -> None: ... - @overload - def __init__(self, initlist: Iterable[_T]) -> None: ... - def __lt__(self, other: list[_T] | UserList[_T]) -> bool: ... - def __le__(self, other: list[_T] | UserList[_T]) -> bool: ... - def __gt__(self, other: list[_T] | UserList[_T]) -> bool: ... - def __ge__(self, other: list[_T] | UserList[_T]) -> bool: ... - def __eq__(self, other: object) -> bool: ... - def __contains__(self, item: object) -> bool: ... - def __len__(self) -> int: ... - @overload - def __getitem__(self, i: SupportsIndex) -> _T: ... - @overload - def __getitem__(self: Self, i: slice) -> Self: ... - @overload - def __setitem__(self, i: SupportsIndex, item: _T) -> None: ... - @overload - def __setitem__(self, i: slice, item: Iterable[_T]) -> None: ... - def __delitem__(self, i: SupportsIndex | slice) -> None: ... - def __add__(self: Self, other: Iterable[_T]) -> Self: ... - def __radd__(self: Self, other: Iterable[_T]) -> Self: ... - def __iadd__(self: Self, other: Iterable[_T]) -> Self: ... - def __mul__(self: Self, n: int) -> Self: ... - def __rmul__(self: Self, n: int) -> Self: ... - def __imul__(self: Self, n: int) -> Self: ... - def append(self, item: _T) -> None: ... - def insert(self, i: int, item: _T) -> None: ... - def pop(self, i: int = ...) -> _T: ... - def remove(self, item: _T) -> None: ... - def copy(self: Self) -> Self: ... - def __copy__(self: Self) -> Self: ... - def count(self, item: _T) -> int: ... - # All arguments are passed to `list.index` at runtime, so the signature should be kept in line with `list.index`. - def index(self, item: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... - # All arguments are passed to `list.sort` at runtime, so the signature should be kept in line with `list.sort`. - @overload - def sort(self: UserList[SupportsRichComparisonT], *, key: None = ..., reverse: bool = ...) -> None: ... - @overload - def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ... - def extend(self, other: Iterable[_T]) -> None: ... - -class UserString(Sequence[UserString]): - data: str - def __init__(self, seq: object) -> None: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __complex__(self) -> complex: ... - def __getnewargs__(self) -> tuple[str]: ... - def __lt__(self, string: str | UserString) -> bool: ... - def __le__(self, string: str | UserString) -> bool: ... - def __gt__(self, string: str | UserString) -> bool: ... - def __ge__(self, string: str | UserString) -> bool: ... - def __eq__(self, string: object) -> bool: ... - def __contains__(self, char: object) -> bool: ... - def __len__(self) -> int: ... - def __getitem__(self: Self, index: SupportsIndex | slice) -> Self: ... - def __iter__(self: Self) -> Iterator[Self]: ... - def __reversed__(self: Self) -> Iterator[Self]: ... - def __add__(self: Self, other: object) -> Self: ... - def __radd__(self: Self, other: object) -> Self: ... - def __mul__(self: Self, n: int) -> Self: ... - def __rmul__(self: Self, n: int) -> Self: ... - def __mod__(self: Self, args: Any) -> Self: ... - if sys.version_info >= (3, 8): - def __rmod__(self: Self, template: object) -> Self: ... - else: - def __rmod__(self: Self, format: Any) -> Self: ... - - def capitalize(self: Self) -> Self: ... - def casefold(self: Self) -> Self: ... - def center(self: Self, width: int, *args: Any) -> Self: ... - def count(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... - if sys.version_info >= (3, 8): - def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ... - else: - def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ... - - def endswith(self, suffix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... - def expandtabs(self: Self, tabsize: int = ...) -> Self: ... - def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... - def format(self, *args: Any, **kwds: Any) -> str: ... - def format_map(self, mapping: Mapping[str, Any]) -> str: ... - def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def isalpha(self) -> bool: ... - def isalnum(self) -> bool: ... - def isdecimal(self) -> bool: ... - def isdigit(self) -> bool: ... - def isidentifier(self) -> bool: ... - def islower(self) -> bool: ... - def isnumeric(self) -> bool: ... - def isprintable(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def isascii(self) -> bool: ... - def join(self, seq: Iterable[str]) -> str: ... - def ljust(self: Self, width: int, *args: Any) -> Self: ... - def lower(self: Self) -> Self: ... - def lstrip(self: Self, chars: str | None = ...) -> Self: ... - @staticmethod - @overload - def maketrans(x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ... - @staticmethod - @overload - def maketrans(x: str, y: str, z: str = ...) -> dict[int, int | None]: ... - def partition(self, sep: str) -> tuple[str, str, str]: ... - if sys.version_info >= (3, 9): - def removeprefix(self: Self, __prefix: str | UserString) -> Self: ... - def removesuffix(self: Self, __suffix: str | UserString) -> Self: ... - - def replace(self: Self, old: str | UserString, new: str | UserString, maxsplit: int = ...) -> Self: ... - def rfind(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... - def rjust(self: Self, width: int, *args: Any) -> Self: ... - def rpartition(self, sep: str) -> tuple[str, str, str]: ... - def rstrip(self: Self, chars: str | None = ...) -> Self: ... - def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... - def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... - def splitlines(self, keepends: bool = ...) -> list[str]: ... - def startswith(self, prefix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ... - def strip(self: Self, chars: str | None = ...) -> Self: ... - def swapcase(self: Self) -> Self: ... - def title(self: Self) -> Self: ... - def translate(self: Self, *args: Any) -> Self: ... - def upper(self: Self) -> Self: ... - def zfill(self: Self, width: int) -> Self: ... - -class deque(MutableSequence[_T], Generic[_T]): - @property - def maxlen(self) -> int | None: ... - @overload - def __init__(self, *, maxlen: int | None = ...) -> None: ... - @overload - def __init__(self, iterable: Iterable[_T], maxlen: int | None = ...) -> None: ... - def append(self, __x: _T) -> None: ... - def appendleft(self, __x: _T) -> None: ... - def copy(self: Self) -> Self: ... - def count(self, __x: _T) -> int: ... - def extend(self, __iterable: Iterable[_T]) -> None: ... - def extendleft(self, __iterable: Iterable[_T]) -> None: ... - def insert(self, __i: int, __x: _T) -> None: ... - def index(self, __x: _T, __start: int = ..., __stop: int = ...) -> int: ... - def pop(self) -> _T: ... # type: ignore[override] - def popleft(self) -> _T: ... - def remove(self, __value: _T) -> None: ... - def rotate(self, __n: int = ...) -> None: ... - def __copy__(self: Self) -> Self: ... - def __len__(self) -> int: ... - # These methods of deque don't take slices, unlike MutableSequence, hence the type: ignores - def __getitem__(self, __index: SupportsIndex) -> _T: ... # type: ignore[override] - def __setitem__(self, __i: SupportsIndex, __x: _T) -> None: ... # type: ignore[override] - def __delitem__(self, __i: SupportsIndex) -> None: ... # type: ignore[override] - def __contains__(self, __o: object) -> bool: ... - def __reduce__(self: Self) -> tuple[type[Self], tuple[()], None, Iterator[_T]]: ... - def __iadd__(self: Self, __iterable: Iterable[_T]) -> Self: ... - def __add__(self: Self, __other: Self) -> Self: ... - def __mul__(self: Self, __other: int) -> Self: ... - def __imul__(self: Self, __other: int) -> Self: ... - def __lt__(self, __other: deque[_T]) -> bool: ... - def __le__(self, __other: deque[_T]) -> bool: ... - def __gt__(self, __other: deque[_T]) -> bool: ... - def __ge__(self, __other: deque[_T]) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -class Counter(dict[_T, int], Generic[_T]): - @overload - def __init__(self, __iterable: None = ...) -> None: ... - @overload - def __init__(self: Counter[str], __iterable: None = ..., **kwargs: int) -> None: ... - @overload - def __init__(self, __mapping: SupportsKeysAndGetItem[_T, int]) -> None: ... - @overload - def __init__(self, __iterable: Iterable[_T]) -> None: ... - def copy(self: Self) -> Self: ... - def elements(self) -> Iterator[_T]: ... - def most_common(self, n: int | None = ...) -> list[tuple[_T, int]]: ... - @classmethod - def fromkeys(cls, iterable: Any, v: int | None = ...) -> NoReturn: ... # type: ignore[override] - @overload - def subtract(self, __iterable: None = ...) -> None: ... - @overload - def subtract(self, __mapping: Mapping[_T, int]) -> None: ... - @overload - def subtract(self, __iterable: Iterable[_T]) -> None: ... - # Unlike dict.update(), use Mapping instead of SupportsKeysAndGetItem for the first overload - # (source code does an `isinstance(other, Mapping)` check) - # - # The second overload is also deliberately different to dict.update() - # (if it were `Iterable[_T] | Iterable[tuple[_T, int]]`, - # the tuples would be added as keys, breaking type safety) - @overload # type: ignore[override] - def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... - @overload - def update(self, __m: Iterable[_T], **kwargs: int) -> None: ... - @overload - def update(self, __m: None = ..., **kwargs: int) -> None: ... - def __missing__(self, key: _T) -> int: ... - def __delitem__(self, elem: object) -> None: ... - if sys.version_info >= (3, 10): - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - - def __add__(self, other: Counter[_S]) -> Counter[_T | _S]: ... - def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... - def __and__(self, other: Counter[_T]) -> Counter[_T]: ... - def __or__(self, other: Counter[_S]) -> Counter[_T | _S]: ... # type: ignore[override] - def __pos__(self) -> Counter[_T]: ... - def __neg__(self) -> Counter[_T]: ... - # several type: ignores because __iadd__ is supposedly incompatible with __add__, etc. - def __iadd__(self: Self, other: Counter[_T]) -> Self: ... # type: ignore[misc] - def __isub__(self: Self, other: Counter[_T]) -> Self: ... - def __iand__(self: Self, other: Counter[_T]) -> Self: ... - def __ior__(self: Self, other: Counter[_T]) -> Self: ... # type: ignore[override,misc] - if sys.version_info >= (3, 10): - def total(self) -> int: ... - def __le__(self, other: Counter[Any]) -> bool: ... - def __lt__(self, other: Counter[Any]) -> bool: ... - def __ge__(self, other: Counter[Any]) -> bool: ... - def __gt__(self, other: Counter[Any]) -> bool: ... - -# The pure-Python implementations of the "views" classes -# These are exposed at runtime in `collections/__init__.py` -class _OrderedDictKeysView(KeysView[_KT_co], Reversible[_KT_co]): - def __reversed__(self) -> Iterator[_KT_co]: ... - -class _OrderedDictItemsView(ItemsView[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): - def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... - -class _OrderedDictValuesView(ValuesView[_VT_co], Reversible[_VT_co]): - def __reversed__(self) -> Iterator[_VT_co]: ... - -# The C implementations of the "views" classes -# (At runtime, these are called `odict_keys`, `odict_items` and `odict_values`, -# but they are not exposed anywhere) -@final -class _odict_keys(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # type: ignore[misc] - def __reversed__(self) -> Iterator[_KT_co]: ... - -@final -class _odict_items(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc] - def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... - -@final -class _odict_values(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc] - def __reversed__(self) -> Iterator[_VT_co]: ... - -class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): - def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ... - def move_to_end(self, key: _KT, last: bool = ...) -> None: ... - def copy(self: Self) -> Self: ... - def __reversed__(self) -> Iterator[_KT]: ... - def keys(self) -> _odict_keys[_KT, _VT]: ... - def items(self) -> _odict_items[_KT, _VT]: ... - def values(self) -> _odict_values[_KT, _VT]: ... - # The signature of OrderedDict.fromkeys should be kept in line with `dict.fromkeys`, modulo positional-only differences. - # Like dict.fromkeys, its true signature is not expressible in the current type system. - # See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963. - @classmethod - @overload - def fromkeys(cls, iterable: Iterable[_T], value: None = ...) -> OrderedDict[_T, Any | None]: ... - @classmethod - @overload - def fromkeys(cls, iterable: Iterable[_T], value: _S) -> OrderedDict[_T, _S]: ... - # Keep OrderedDict.setdefault in line with MutableMapping.setdefault, modulo positional-only differences. - @overload - def setdefault(self: OrderedDict[_KT, _T | None], key: _KT) -> _T | None: ... - @overload - def setdefault(self, key: _KT, default: _VT) -> _VT: ... - -class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]): - default_factory: Callable[[], _VT] | None - @overload - def __init__(self) -> None: ... - @overload - def __init__(self: defaultdict[str, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, __default_factory: Callable[[], _VT] | None) -> None: ... - @overload - def __init__(self: defaultdict[str, _VT], __default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ... - @overload - def __init__(self, __default_factory: Callable[[], _VT] | None, __map: SupportsKeysAndGetItem[_KT, _VT]) -> None: ... - @overload - def __init__( - self: defaultdict[str, _VT], - __default_factory: Callable[[], _VT] | None, - __map: SupportsKeysAndGetItem[str, _VT], - **kwargs: _VT, - ) -> None: ... - @overload - def __init__(self, __default_factory: Callable[[], _VT] | None, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ... - @overload - def __init__( - self: defaultdict[str, _VT], - __default_factory: Callable[[], _VT] | None, - __iterable: Iterable[tuple[str, _VT]], - **kwargs: _VT, - ) -> None: ... - def __missing__(self, __key: _KT) -> _VT: ... - def __copy__(self: Self) -> Self: ... - def copy(self: Self) -> Self: ... - -class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - maps: list[MutableMapping[_KT, _VT]] - def __init__(self, *maps: MutableMapping[_KT, _VT]) -> None: ... - def new_child(self: Self, m: MutableMapping[_KT, _VT] | None = ...) -> Self: ... - @property - def parents(self: Self) -> Self: ... - def __setitem__(self, key: _KT, value: _VT) -> None: ... - def __delitem__(self, key: _KT) -> None: ... - def __getitem__(self, key: _KT) -> _VT: ... - def __iter__(self) -> Iterator[_KT]: ... - def __len__(self) -> int: ... - def __contains__(self, key: object) -> bool: ... - def __missing__(self, key: _KT) -> _VT: ... # undocumented - def __bool__(self) -> bool: ... - def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ... - @overload - def pop(self, key: _KT) -> _VT: ... - @overload - def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ... - def copy(self: Self) -> Self: ... - __copy__ = copy - # All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, so the signature should be kept in line with `dict.fromkeys`. - @classmethod - @overload - def fromkeys(cls, iterable: Iterable[_T], __value: None = ...) -> ChainMap[_T, Any | None]: ... - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> ChainMap[_T, _S]: ... - if sys.version_info >= (3, 9): - def __or__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ... - def __ror__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ... - # ChainMap.__ior__ should be kept roughly in line with MutableMapping.update() - @overload # type: ignore[misc] - def __ior__(self: Self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ... - @overload - def __ior__(self: Self, other: Iterable[tuple[_KT, _VT]]) -> Self: ... diff --git a/stubs/stdlib/collections/abc.pyi b/stubs/stdlib/collections/abc.pyi deleted file mode 100644 index 4c7f02a..0000000 --- a/stubs/stdlib/collections/abc.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -from _collections_abc import * -from _collections_abc import __all__ as __all__ diff --git a/stubs/stdlib/errno.pyi b/stubs/stdlib/errno.pyi deleted file mode 100644 index 0671ebb..0000000 --- a/stubs/stdlib/errno.pyi +++ /dev/null @@ -1 +0,0 @@ -from uerrno import * diff --git a/stubs/stdlib/gc.pyi b/stubs/stdlib/gc.pyi deleted file mode 100644 index b015763..0000000 --- a/stubs/stdlib/gc.pyi +++ /dev/null @@ -1,65 +0,0 @@ -"""Garbage Collection - -This module provides control over the garbage collection process. -""" -from typing import Optional - -def collect(): - """ - Run a garbage collection. - """ - ... - -def disable(): - """ - Disable automatic garbage collection. Heap memory can still be - allocated, and garbage collection can still be initiated - manually using ``gc.collect()``. - """ - ... - -def enable(): - """ - Enable automatic garbage collection. - """ - ... - -def isenabled() -> bool: - """ - Returns ``true`` when garbage collection is enabled. - """ - ... - -def mem_alloc() -> int: - """ - Return the number of bytes of heap RAM that are allocated. - """ - ... - -def mem_free() -> int: - """ - Return the number of bytes of available heap RAM, or -1 if this - amount is not known. - """ - ... - -def threshold(amount: Optional[int] = None) -> int: - """ - Set or query the additional GC allocation threshold. Normally, a - collection is triggered only when a new allocation cannot be - satisfied, i.e. on an out-of-memory (OOM) condition. If this - function is called, in addition to OOM, a collection will be - triggered each time after amount bytes have been allocated (in - total, since the previous time such an amount of bytes have been - allocated). amount is usually specified as less than the full - heap size, with the intention to trigger a collection earlier - than when the heap becomes exhausted, and in the hope that an - early collection will prevent excessive memory fragmentation. - This is a heuristic measure, the effect of which will vary from - application to application, as well as the optimal value of the - amount parameter. - - Calling the function without argument will return the current value - of the threshold. A value of -1 means a disabled allocation threshold. - """ - ... diff --git a/stubs/stdlib/hashlib.pyi b/stubs/stdlib/hashlib.pyi deleted file mode 100644 index cc926d7..0000000 --- a/stubs/stdlib/hashlib.pyi +++ /dev/null @@ -1 +0,0 @@ -from uhashlib import * diff --git a/stubs/stdlib/heapq.pyi b/stubs/stdlib/heapq.pyi deleted file mode 100644 index 85d98ba..0000000 --- a/stubs/stdlib/heapq.pyi +++ /dev/null @@ -1 +0,0 @@ -from uheapq import * diff --git a/stubs/stdlib/importlib/__init__.pyi b/stubs/stdlib/importlib/__init__.pyi deleted file mode 100644 index 761afa3..0000000 --- a/stubs/stdlib/importlib/__init__.pyi +++ /dev/null @@ -1,23 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -from collections.abc import Mapping, Sequence -from importlib.abc import Loader -from types import ModuleType - -__all__ = ["__import__", "import_module", "invalidate_caches", "reload"] - -# Signature of `builtins.__import__` should be kept identical to `importlib.__import__` -def __import__( - name: str, - globals: Mapping[str, object] | None = ..., - locals: Mapping[str, object] | None = ..., - fromlist: Sequence[str] = ..., - level: int = ..., -) -> ModuleType: ... - -# `importlib.import_module` return type should be kept the same as `builtins.__import__` -def import_module(name: str, package: str | None = ...) -> ModuleType: ... -def find_loader(name: str, path: str | None = ...) -> Loader | None: ... -def invalidate_caches() -> None: ... -def reload(module: ModuleType) -> ModuleType: ... diff --git a/stubs/stdlib/importlib/abc.pyi b/stubs/stdlib/importlib/abc.pyi deleted file mode 100644 index d0fd789..0000000 --- a/stubs/stdlib/importlib/abc.pyi +++ /dev/null @@ -1,198 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -import types -from _typeshed import ( - OpenBinaryMode, - OpenBinaryModeReading, - OpenBinaryModeUpdating, - OpenBinaryModeWriting, - OpenTextMode, - StrOrBytesPath, - StrPath, -) -from abc import ABCMeta, abstractmethod -from collections.abc import Iterator, Mapping, Sequence -from importlib.machinery import ModuleSpec -from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper -from typing import IO, Any, BinaryIO, NoReturn, Protocol, overload, runtime_checkable -from typing_extensions import Literal, TypeAlias - -if sys.version_info >= (3, 11): - __all__ = [ - "Loader", - "Finder", - "MetaPathFinder", - "PathEntryFinder", - "ResourceLoader", - "InspectLoader", - "ExecutionLoader", - "FileLoader", - "SourceLoader", - "ResourceReader", - "Traversable", - "TraversableResources", - ] - -_Path: TypeAlias = bytes | str - -class Finder(metaclass=ABCMeta): ... - -class Loader(metaclass=ABCMeta): - def load_module(self, fullname: str) -> types.ModuleType: ... - def module_repr(self, module: types.ModuleType) -> str: ... - def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ... - # Not defined on the actual class for backwards-compatibility reasons, - # but expected in new code. - def exec_module(self, module: types.ModuleType) -> None: ... - -class ResourceLoader(Loader): - @abstractmethod - def get_data(self, path: _Path) -> bytes: ... - -class InspectLoader(Loader): - def is_package(self, fullname: str) -> bool: ... - def get_code(self, fullname: str) -> types.CodeType | None: ... - @abstractmethod - def get_source(self, fullname: str) -> str | None: ... - def exec_module(self, module: types.ModuleType) -> None: ... - @staticmethod - def source_to_code(data: bytes | str, path: str = ...) -> types.CodeType: ... - -class ExecutionLoader(InspectLoader): - @abstractmethod - def get_filename(self, fullname: str) -> _Path: ... - -class SourceLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): - def path_mtime(self, path: _Path) -> float: ... - def set_data(self, path: _Path, data: bytes) -> None: ... - def get_source(self, fullname: str) -> str | None: ... - def path_stats(self, path: _Path) -> Mapping[str, Any]: ... - -# Please keep in sync with sys._MetaPathFinder -class MetaPathFinder(Finder): - def find_module(self, fullname: str, path: Sequence[_Path] | None) -> Loader | None: ... - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec( - self, fullname: str, path: Sequence[_Path] | None, target: types.ModuleType | None = ... - ) -> ModuleSpec | None: ... - -class PathEntryFinder(Finder): - def find_module(self, fullname: str) -> Loader | None: ... - def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[_Path]]: ... - def invalidate_caches(self) -> None: ... - # Not defined on the actual class, but expected to exist. - def find_spec(self, fullname: str, target: types.ModuleType | None = ...) -> ModuleSpec | None: ... - -class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): - name: str - path: _Path - def __init__(self, fullname: str, path: _Path) -> None: ... - def get_data(self, path: _Path) -> bytes: ... - def get_filename(self, name: str | None = ...) -> _Path: ... - def load_module(self, name: str | None = ...) -> types.ModuleType: ... - -class ResourceReader(metaclass=ABCMeta): - @abstractmethod - def open_resource(self, resource: StrOrBytesPath) -> IO[bytes]: ... - @abstractmethod - def resource_path(self, resource: StrOrBytesPath) -> str: ... - if sys.version_info >= (3, 10): - @abstractmethod - def is_resource(self, path: str) -> bool: ... - else: - @abstractmethod - def is_resource(self, name: str) -> bool: ... - - @abstractmethod - def contents(self) -> Iterator[str]: ... - -if sys.version_info >= (3, 9): - @runtime_checkable - class Traversable(Protocol): - @abstractmethod - def is_dir(self) -> bool: ... - @abstractmethod - def is_file(self) -> bool: ... - @abstractmethod - def iterdir(self) -> Iterator[Traversable]: ... - @abstractmethod - def joinpath(self, child: StrPath) -> Traversable: ... - # The .open method comes from pathlib.pyi and should be kept in sync. - @overload - @abstractmethod - def open( - self, - mode: OpenTextMode = ..., - buffering: int = ..., - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., - ) -> TextIOWrapper: ... - # Unbuffered binary mode: returns a FileIO - @overload - @abstractmethod - def open( - self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = ..., errors: None = ..., newline: None = ... - ) -> FileIO: ... - # Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter - @overload - @abstractmethod - def open( - self, - mode: OpenBinaryModeUpdating, - buffering: Literal[-1, 1] = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - ) -> BufferedRandom: ... - @overload - @abstractmethod - def open( - self, - mode: OpenBinaryModeWriting, - buffering: Literal[-1, 1] = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - ) -> BufferedWriter: ... - @overload - @abstractmethod - def open( - self, - mode: OpenBinaryModeReading, - buffering: Literal[-1, 1] = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - ) -> BufferedReader: ... - # Buffering cannot be determined: fall back to BinaryIO - @overload - @abstractmethod - def open( - self, mode: OpenBinaryMode, buffering: int = ..., encoding: None = ..., errors: None = ..., newline: None = ... - ) -> BinaryIO: ... - # Fallback if mode is not specified - @overload - @abstractmethod - def open( - self, mode: str, buffering: int = ..., encoding: str | None = ..., errors: str | None = ..., newline: str | None = ... - ) -> IO[Any]: ... - @property - def name(self) -> str: ... - @abstractmethod - def __truediv__(self, child: StrPath) -> Traversable: ... - @abstractmethod - def read_bytes(self) -> bytes: ... - @abstractmethod - def read_text(self, encoding: str | None = ...) -> str: ... - - class TraversableResources(ResourceReader): - @abstractmethod - def files(self) -> Traversable: ... - def open_resource(self, resource: StrPath) -> BufferedReader: ... # type: ignore[override] - def resource_path(self, resource: Any) -> NoReturn: ... - def is_resource(self, path: StrPath) -> bool: ... - def contents(self) -> Iterator[str]: ... diff --git a/stubs/stdlib/io.pyi b/stubs/stdlib/io.pyi deleted file mode 100644 index 6cf1cec..0000000 --- a/stubs/stdlib/io.pyi +++ /dev/null @@ -1 +0,0 @@ -from uio import * diff --git a/stubs/stdlib/math.pyi b/stubs/stdlib/math.pyi deleted file mode 100644 index e598367..0000000 --- a/stubs/stdlib/math.pyi +++ /dev/null @@ -1,306 +0,0 @@ -""" -Module: 'math' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} - -e = 2.718282 # type: float -nan = nan # type: float -pi = 3.141593 # type: float -tau = 6.283185 # type: float -inf = inf # type: float - -def acos(x: float) -> float: - """ - Return the arc cosine of ``x``, in radians. - """ - ... - -def acosh(x: float) -> float: - """ - Return the inverse hyperbolic cosine of ``x``, in radians. - """ - ... - -def asin(x: float) -> float: - """ - Return the arc sine of ``x``, in radians. - """ - ... - -def asinh(x: float) -> float: - """ - Return the inverse hyperbolic arc sine of ``x``, in radians. - """ - ... - -def atan(x: float) -> float: - """ - Return the arc tangent of ``x``, in radians. - """ - ... - -def atanh(x: float) -> float: - """ - Return the inverse hyperbolic arc tangent of ``x``, in radians. - """ - ... - -def atan2(y: float, x: float) -> float: - """ - Return ``atan(y / x)``, in radians. The result is between ``-pi`` and ``pi``. The vector in - the plane from the origin to point ``(x, y)`` makes this angle with the positive X - axis. The point of ``atan2()`` is that the signs of both inputs are known to it, so - it can compute the correct quadrant for the angle. For example, ``atan(1)`` and - ``atan2(1, 1)`` are both ``pi/4``, but ``atan2(-1, -1)`` is ``-3*pi/4``. - """ - ... - -def ceil(x: float) -> int: - """ - Return the ceiling of ``x`` as a float, the smallest integer - value greater than or equal to ``x``. - """ - ... - -def copysign(x: float, y: float) -> float: - """ - Return ``x`` with the sign of ``y``. On a platform that supports signed - zeros, ``copysign(1.0, -0.0)`` returns ``-1.0``. - """ - ... - -def cos(x: float) -> float: - """ - Return the cosine of ``x`` radians. - """ - ... - -def cosh(x: float) -> float: - """ - Return the hyperbolic cosine of ``x`` radians. - """ - ... - -def degrees(x: float) -> float: - """ - Convert angle ``x`` from radians to degrees. - """ - ... - -def erf(x: float) -> float: - """ - Return the error function at ``x``. - """ - ... -def erfc(x: float) -> float: - """ - Return the complementary error function at ``x``. The complementary error - function is defined as ``1.0 - erf(x)``. It is used for large values of ``x`` where - a subtraction from one would cause a loss of significance. - """ - ... - -def exp(x: float) -> float: - """ - Return ``e**x``. - """ - ... - -def expm1(x: float) -> float: - """ - Return ``e`` raised to the power ``x``, minus 1. Here e is the base of natural logarithms. - For small floats ``x``, the subtraction in ``exp(x) - 1`` can result in a significant loss - of precision; the ``expm1()`` function provides a way to compute this quantity to full - precision. - """ - ... - -def fabs(x: float) -> float: - """ - Return the absolute value of ``x``. - """ - ... - -def factorial(x: int) -> int: - """ - Return ``x`` factorial as an integer. Raises ``ValueError`` if ``x`` is not integral or is negative. - """ - ... - -def floor(x: float) -> float: - """ - Return the floor of ``x`` as a float, the largest integer value less - than or equal to ``x``. - """ - ... - -def fmod(x: float, y: float) -> float: - """ - Return ``fmod(x, y)``, as defined by the platform C library. Note that the - Python expression ``x % y`` may not return the same result. The intent of - the C standard is that ``fmod(x, y)`` be exactly (mathematically; to infinite - precision) equal to ``x - n*y`` for some integer ``n`` such that the result has - the same sign as x and magnitude less than ``abs(y)``. Python’s ``x % y`` returns - a result with the sign of ``y`` instead, and may not be exactly computable - for float arguments. For example, ``fmod(-1e-100, 1e100)`` is ``-1e-100``, but - the result of Python’s ``-1e-100 % 1e100`` is ``1e100-1e-100``, which cannot be - represented exactly as a float, and rounds to the surprising ``1e100``. For - this reason, function ``fmod()`` is generally preferred when working with - floats, while Python’s ``x % y`` is preferred when working with integers. - """ - ... - -def frexp(x: float) -> tuple[float, int]: - """ - Return the mantissa and exponent of ``x`` as the pair ``(m, e)``. ``m`` is a float and - ``e`` is an integer such that ``x == m * 2**e`` exactly. If ``x`` is zero, returns ``(0.0, 0)``, - otherwise ``0.5 <= abs(m) < 1``. This is used to “pick apart” the internal - representation of a float in a portable way. - """ - ... - -def gamma(x: float) -> float: - """ - Return the Gamma function at ``x``. - """ - ... - -def isclose(a: float, b: float, *, rel_tol: float = ..., abs_tol: float = ...) -> bool: - """ - Return ``True`` if the values ``a`` and ``b`` are close to each other and ``False`` otherwise. - - Whether or not two values are considered close is determined according to given - absolute and relative tolerances. - - ``rel_tol`` is the relative tolerance – it is the maximum allowed difference between - ``a`` and ``b``, relative to the larger absolute value of ``a`` or ``b``. For example, to set a - tolerance of 5%, pass ``rel_tol=0.05``. The default tolerance is ``1e-09``, which assures - that the two values are the same within about 9 decimal digits. ``rel_tol`` must be - greater than zero. - - ``abs_tol`` is the minimum absolute tolerance – useful for comparisons near zero. - ``abs_tol`` must be at least zero. - - If no errors occur, the result will be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``. - - The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be handled according to IEEE rules. - Specifically, ``NaN`` is not considered close to any other value, including ``NaN``. ``inf`` and - ``-inf`` are only considered close to themselves. - """ - ... - -def isfinite(x: float) -> bool: - """ - Check if the float ``x`` is finite. - """ - ... - -def isinf(x: float) -> bool: - """ - Check if the float ``x`` is positive or negative infinity. - """ - ... - -def isnan(x: float) -> bool: - """ - Check if the float ``x`` is a NaN (not a number). For more information on - NaNs, see the IEEE 754 standards. - """ - ... - -def ldexp(x: float, i: int) -> float: - """ - Return ``x * (2**i)``. This is essentially the inverse of function ``frexp()``. - """ - ... - -def lgamma(x: float) -> float: - """ - Return the natural logarithm of the absolute value of the Gamma function at ``x``. - """ - ... - -def log(x: float, base: float = ...) -> float: - """ - With one argument, return the natural logarithm of ``x`` (to base ``e``). - - With two arguments, return the logarithm of ``x`` to the given base, - calculated as ``log(x)/log(base)``. - """ - ... - -def log2(__x: float) -> float: - """ - Return the base-2 logarithm of ``x``. This is usually more accurate than ``log(x, 2)``. - """ - ... - -def log10(__x: float) -> float: - """ - Return the base-10 logarithm of ``x``. This is usually more accurate than ``log(x, 10)``. - """ - ... - -def modf(x: float) -> tuple[float, float]: - """ - Return the fractional and integer parts of ``x``. Both results carry the sign - of ``x`` and are floats. - """ - ... - -def pow(x: float, y: float) -> float: - """ - Return ``x`` raised to the power ``y``. Exceptional cases follow Annex ‘F’ of - the C99 standard as far as possible. In particular, ``pow(1.0, x)`` and - ``pow(x, 0.0)`` always return ``1.0``, even when ``x`` is a zero or a NaN. If - both ``x`` and ``y`` are finite, ``x`` is negative, and ``y`` is not an integer then - ``pow(x, y)`` is undefined, and raises ``ValueError``. - - Unlike the built-in ``**`` operator, ``math.pow()`` converts both its arguments to - type float. Use ``**`` or the built-in ``pow()`` function for computing exact integer - powers. - """ - ... - -def radians(x: float) -> float: - """ - Convert angle ``x`` from degrees to radians. - """ - ... - -def sin(x: float) -> float: - """ - Return the sine of ``x`` in radians. - """ - ... - -def sinh(x: float) -> float: - """ - Return the inverse hyperbolic sine of ``x`` in radians. - """ - ... - -def sqrt(x: float) -> float: - """ - Return the square root of ``x``. - """ - ... - -def tan(x: float) -> float: - """ - Return the tangent of ``x`` in radians. - """ - ... - -def tanh(x: float) -> float: - """ - Return the inverse hyperbolic tangent of ``x`` in radians. - """ - ... - -def trunc(x: float) -> int: - """ - Return the ``Real`` value ``x`` truncated to an Integral (usually a long - integer). Uses the ``__trunc__`` method. - """ - ... diff --git a/stubs/stdlib/mmap.pyi b/stubs/stdlib/mmap.pyi deleted file mode 100644 index b116a50..0000000 --- a/stubs/stdlib/mmap.pyi +++ /dev/null @@ -1,112 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from _typeshed import ReadableBuffer, Self -from collections.abc import Iterable, Iterator, Sized -from typing import NoReturn, overload, Optional, Union - -ACCESS_DEFAULT: int -ACCESS_READ: int -ACCESS_WRITE: int -ACCESS_COPY: int - -ALLOCATIONGRANULARITY: int - -if sys.platform == "linux": - MAP_DENYWRITE: int - MAP_EXECUTABLE: int - if sys.version_info >= (3, 10): - MAP_POPULATE: int - -if sys.platform != "win32": - MAP_ANON: int - MAP_ANONYMOUS: int - MAP_PRIVATE: int - MAP_SHARED: int - PROT_EXEC: int - PROT_READ: int - PROT_WRITE: int - - PAGESIZE: int - -class mmap(Iterable[int], Sized): - if sys.platform == "win32": - def __init__(self, fileno: int, length: int, tagname: Optional[str] = ..., access: int = ..., offset: int = ...) -> None: ... - else: - def __init__( - self, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ... - ) -> None: ... - - def close(self) -> None: ... - if sys.version_info >= (3, 8): - def flush(self, offset: int = ..., size: int = ...) -> None: ... - else: - def flush(self, offset: int = ..., size: int = ...) -> int: ... - - def move(self, dest: int, src: int, count: int) -> None: ... - def read_byte(self) -> int: ... - def readline(self) -> bytes: ... - def resize(self, newsize: int) -> None: ... - def seek(self, pos: int, whence: int = ...) -> None: ... - def size(self) -> int: ... - def tell(self) -> int: ... - def write_byte(self, byte: int) -> None: ... - def __len__(self) -> int: ... - closed: bool - if sys.version_info >= (3, 8) and sys.platform != "win32": - def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... - - def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def read(self, n: Optional[int] = ...) -> bytes: ... - def write(self, bytes: ReadableBuffer) -> int: ... - @overload - def __getitem__(self, __index: int) -> int: ... - @overload - def __getitem__(self, __index: slice) -> bytes: ... - def __delitem__(self, __index: Union[int, slice]) -> NoReturn: ... - @overload - def __setitem__(self, __index: int, __object: int) -> None: ... - @overload - def __setitem__(self, __index: slice, __object: ReadableBuffer) -> None: ... - # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and - # __len__, so we claim that there is also an __iter__ to help type checkers. - def __iter__(self) -> Iterator[int]: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... - -if sys.version_info >= (3, 8) and sys.platform != "win32": - MADV_NORMAL: int - MADV_RANDOM: int - MADV_SEQUENTIAL: int - MADV_WILLNEED: int - MADV_DONTNEED: int - MADV_FREE: int - - if sys.platform == "linux": - MADV_REMOVE: int - MADV_DONTFORK: int - MADV_DOFORK: int - MADV_HWPOISON: int - MADV_MERGEABLE: int - MADV_UNMERGEABLE: int - # Seems like this constant is not defined in glibc. - # See https://github.com/python/typeshed/pull/5360 for details - # MADV_SOFT_OFFLINE: int - MADV_HUGEPAGE: int - MADV_NOHUGEPAGE: int - MADV_DONTDUMP: int - MADV_DODUMP: int - - # This Values are defined for FreeBSD but type checkers do not support conditions for these - if sys.platform != "linux" and sys.platform != "darwin": - MADV_NOSYNC: int - MADV_AUTOSYNC: int - MADV_NOCORE: int - MADV_CORE: int - MADV_PROTECT: int - -if sys.version_info >= (3, 10) and sys.platform == "darwin": - MADV_FREE_REUSABLE: int - MADV_FREE_REUSE: int diff --git a/stubs/stdlib/os.pyi b/stubs/stdlib/os.pyi deleted file mode 100644 index c3df8b0..0000000 --- a/stubs/stdlib/os.pyi +++ /dev/null @@ -1 +0,0 @@ -from uos import * diff --git a/stubs/stdlib/platform.pyi b/stubs/stdlib/platform.pyi deleted file mode 100644 index ff9375e..0000000 --- a/stubs/stdlib/platform.pyi +++ /dev/null @@ -1 +0,0 @@ -from uplatform import * diff --git a/stubs/stdlib/random.pyi b/stubs/stdlib/random.pyi deleted file mode 100644 index 667e5ae..0000000 --- a/stubs/stdlib/random.pyi +++ /dev/null @@ -1 +0,0 @@ -from urandom import * diff --git a/stubs/stdlib/re.pyi b/stubs/stdlib/re.pyi deleted file mode 100644 index 607817a..0000000 --- a/stubs/stdlib/re.pyi +++ /dev/null @@ -1 +0,0 @@ -from ure import * diff --git a/stubs/stdlib/select.pyi b/stubs/stdlib/select.pyi deleted file mode 100644 index 9a582af..0000000 --- a/stubs/stdlib/select.pyi +++ /dev/null @@ -1 +0,0 @@ -from uselect import * diff --git a/stubs/stdlib/socket.pyi b/stubs/stdlib/socket.pyi deleted file mode 100644 index d10cb93..0000000 --- a/stubs/stdlib/socket.pyi +++ /dev/null @@ -1 +0,0 @@ -from usocket import * diff --git a/stubs/stdlib/ssl.pyi b/stubs/stdlib/ssl.pyi deleted file mode 100644 index 09639b4..0000000 --- a/stubs/stdlib/ssl.pyi +++ /dev/null @@ -1 +0,0 @@ -from ussl import * diff --git a/stubs/stdlib/struct.pyi b/stubs/stdlib/struct.pyi deleted file mode 100644 index 677ad73..0000000 --- a/stubs/stdlib/struct.pyi +++ /dev/null @@ -1 +0,0 @@ -from ustruct import * diff --git a/stubs/stdlib/sys.pyi b/stubs/stdlib/sys.pyi deleted file mode 100644 index f163572..0000000 --- a/stubs/stdlib/sys.pyi +++ /dev/null @@ -1 +0,0 @@ -from usys import * diff --git a/stubs/stdlib/time.pyi b/stubs/stdlib/time.pyi deleted file mode 100644 index bc54271..0000000 --- a/stubs/stdlib/time.pyi +++ /dev/null @@ -1 +0,0 @@ -from utime import * diff --git a/stubs/stdlib/types.pyi b/stubs/stdlib/types.pyi deleted file mode 100644 index 0e1c633..0000000 --- a/stubs/stdlib/types.pyi +++ /dev/null @@ -1,612 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import sys -from _typeshed import SupportsKeysAndGetItem -from collections.abc import ( - AsyncGenerator, - Awaitable, - Callable, - Coroutine, - Generator, - ItemsView, - Iterable, - Iterator, - KeysView, - MutableSequence, - ValuesView, -) -from importlib.machinery import ModuleSpec - -# pytype crashes if types.MappingProxyType inherits from collections.abc.Mapping instead of typing.Mapping -from typing import Any, ClassVar, Generic, Mapping, Protocol, TypeVar, overload # noqa: Y027 -from typing_extensions import Literal, ParamSpec, final - -__all__ = [ - "FunctionType", - "LambdaType", - "CodeType", - "MappingProxyType", - "SimpleNamespace", - "GeneratorType", - "CoroutineType", - "AsyncGeneratorType", - "MethodType", - "BuiltinFunctionType", - "ModuleType", - "TracebackType", - "FrameType", - "GetSetDescriptorType", - "MemberDescriptorType", - "new_class", - "prepare_class", - "DynamicClassAttribute", - "coroutine", - "BuiltinMethodType", - "ClassMethodDescriptorType", - "MethodDescriptorType", - "MethodWrapperType", - "WrapperDescriptorType", - "resolve_bases", -] - -if sys.version_info >= (3, 8): - __all__ += ["CellType"] - -if sys.version_info >= (3, 9): - __all__ += ["GenericAlias"] - -if sys.version_info >= (3, 10): - __all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"] - -# Note, all classes "defined" here require special handling. - -_T1 = TypeVar("_T1") -_T2 = TypeVar("_T2") -_T_co = TypeVar("_T_co", covariant=True) -_T_contra = TypeVar("_T_contra", contravariant=True) -_KT = TypeVar("_KT") -_VT_co = TypeVar("_VT_co", covariant=True) -_V_co = TypeVar("_V_co", covariant=True) - -@final -class _Cell: - __hash__: ClassVar[None] # type: ignore[assignment] - cell_contents: Any - -# Make sure this class definition stays roughly in line with `builtins.function` -@final -class FunctionType: - @property - def __closure__(self) -> tuple[_Cell, ...] | None: ... - __code__: CodeType - __defaults__: tuple[Any, ...] | None - __dict__: dict[str, Any] - @property - def __globals__(self) -> dict[str, Any]: ... - __name__: str - __qualname__: str - __annotations__: dict[str, Any] - __kwdefaults__: dict[str, Any] - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... - - __module__: str - def __init__( - self, - code: CodeType, - globals: dict[str, Any], - name: str | None = ..., - argdefs: tuple[object, ...] | None = ..., - closure: tuple[_Cell, ...] | None = ..., - ) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - @overload - def __get__(self, obj: None, type: type) -> FunctionType: ... - @overload - def __get__(self, obj: object, type: type | None = ...) -> MethodType: ... - -LambdaType = FunctionType - -@final -class CodeType: - @property - def co_argcount(self) -> int: ... - if sys.version_info >= (3, 8): - @property - def co_posonlyargcount(self) -> int: ... - - @property - def co_kwonlyargcount(self) -> int: ... - @property - def co_nlocals(self) -> int: ... - @property - def co_stacksize(self) -> int: ... - @property - def co_flags(self) -> int: ... - @property - def co_code(self) -> bytes: ... - @property - def co_consts(self) -> tuple[Any, ...]: ... - @property - def co_names(self) -> tuple[str, ...]: ... - @property - def co_varnames(self) -> tuple[str, ...]: ... - @property - def co_filename(self) -> str: ... - @property - def co_name(self) -> str: ... - @property - def co_firstlineno(self) -> int: ... - @property - def co_lnotab(self) -> bytes: ... - @property - def co_freevars(self) -> tuple[str, ...]: ... - @property - def co_cellvars(self) -> tuple[str, ...]: ... - if sys.version_info >= (3, 10): - @property - def co_linetable(self) -> bytes: ... - def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ... - if sys.version_info >= (3, 11): - @property - def co_exceptiontable(self) -> bytes: ... - @property - def co_qualname(self) -> str: ... - def co_positions(self) -> Iterable[tuple[int | None, int | None, int | None, int | None]]: ... - - if sys.version_info >= (3, 11): - def __init__( - self, - __argcount: int, - __posonlyargcount: int, - __kwonlyargcount: int, - __nlocals: int, - __stacksize: int, - __flags: int, - __codestring: bytes, - __constants: tuple[object, ...], - __names: tuple[str, ...], - __varnames: tuple[str, ...], - __filename: str, - __name: str, - __qualname: str, - __firstlineno: int, - __linetable: bytes, - __exceptiontable: bytes, - __freevars: tuple[str, ...] = ..., - __cellvars: tuple[str, ...] = ..., - ) -> None: ... - elif sys.version_info >= (3, 10): - def __init__( - self, - __argcount: int, - __posonlyargcount: int, - __kwonlyargcount: int, - __nlocals: int, - __stacksize: int, - __flags: int, - __codestring: bytes, - __constants: tuple[object, ...], - __names: tuple[str, ...], - __varnames: tuple[str, ...], - __filename: str, - __name: str, - __firstlineno: int, - __linetable: bytes, - __freevars: tuple[str, ...] = ..., - __cellvars: tuple[str, ...] = ..., - ) -> None: ... - elif sys.version_info >= (3, 8): - def __init__( - self, - __argcount: int, - __posonlyargcount: int, - __kwonlyargcount: int, - __nlocals: int, - __stacksize: int, - __flags: int, - __codestring: bytes, - __constants: tuple[object, ...], - __names: tuple[str, ...], - __varnames: tuple[str, ...], - __filename: str, - __name: str, - __firstlineno: int, - __lnotab: bytes, - __freevars: tuple[str, ...] = ..., - __cellvars: tuple[str, ...] = ..., - ) -> None: ... - else: - def __init__( - self, - __argcount: int, - __kwonlyargcount: int, - __nlocals: int, - __stacksize: int, - __flags: int, - __codestring: bytes, - __constants: tuple[object, ...], - __names: tuple[str, ...], - __varnames: tuple[str, ...], - __filename: str, - __name: str, - __firstlineno: int, - __lnotab: bytes, - __freevars: tuple[str, ...] = ..., - __cellvars: tuple[str, ...] = ..., - ) -> None: ... - if sys.version_info >= (3, 11): - def replace( - self, - *, - co_argcount: int = ..., - co_posonlyargcount: int = ..., - co_kwonlyargcount: int = ..., - co_nlocals: int = ..., - co_stacksize: int = ..., - co_flags: int = ..., - co_firstlineno: int = ..., - co_code: bytes = ..., - co_consts: tuple[object, ...] = ..., - co_names: tuple[str, ...] = ..., - co_varnames: tuple[str, ...] = ..., - co_freevars: tuple[str, ...] = ..., - co_cellvars: tuple[str, ...] = ..., - co_filename: str = ..., - co_name: str = ..., - co_qualname: str = ..., - co_linetable: bytes = ..., - co_exceptiontable: bytes = ..., - ) -> CodeType: ... - elif sys.version_info >= (3, 10): - def replace( - self, - *, - co_argcount: int = ..., - co_posonlyargcount: int = ..., - co_kwonlyargcount: int = ..., - co_nlocals: int = ..., - co_stacksize: int = ..., - co_flags: int = ..., - co_firstlineno: int = ..., - co_code: bytes = ..., - co_consts: tuple[object, ...] = ..., - co_names: tuple[str, ...] = ..., - co_varnames: tuple[str, ...] = ..., - co_freevars: tuple[str, ...] = ..., - co_cellvars: tuple[str, ...] = ..., - co_filename: str = ..., - co_name: str = ..., - co_linetable: bytes = ..., - ) -> CodeType: ... - elif sys.version_info >= (3, 8): - def replace( - self, - *, - co_argcount: int = ..., - co_posonlyargcount: int = ..., - co_kwonlyargcount: int = ..., - co_nlocals: int = ..., - co_stacksize: int = ..., - co_flags: int = ..., - co_firstlineno: int = ..., - co_code: bytes = ..., - co_consts: tuple[object, ...] = ..., - co_names: tuple[str, ...] = ..., - co_varnames: tuple[str, ...] = ..., - co_freevars: tuple[str, ...] = ..., - co_cellvars: tuple[str, ...] = ..., - co_filename: str = ..., - co_name: str = ..., - co_lnotab: bytes = ..., - ) -> CodeType: ... - -@final -class MappingProxyType(Mapping[_KT, _VT_co], Generic[_KT, _VT_co]): - __hash__: ClassVar[None] # type: ignore[assignment] - def __init__(self, mapping: SupportsKeysAndGetItem[_KT, _VT_co]) -> None: ... - def __getitem__(self, __key: _KT) -> _VT_co: ... - def __iter__(self) -> Iterator[_KT]: ... - def __len__(self) -> int: ... - def copy(self) -> dict[_KT, _VT_co]: ... - def keys(self) -> KeysView[_KT]: ... - def values(self) -> ValuesView[_VT_co]: ... - def items(self) -> ItemsView[_KT, _VT_co]: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - def __reversed__(self) -> Iterator[_KT]: ... - def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT_co | _T2]: ... - def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT_co | _T2]: ... - -class SimpleNamespace: - __hash__: ClassVar[None] # type: ignore[assignment] - def __init__(self, **kwargs: Any) -> None: ... - def __getattribute__(self, __name: str) -> Any: ... - def __setattr__(self, __name: str, __value: Any) -> None: ... - def __delattr__(self, __name: str) -> None: ... - -class _LoaderProtocol(Protocol): - def load_module(self, fullname: str) -> ModuleType: ... - -class ModuleType: - __name__: str - __file__: str | None - @property - def __dict__(self) -> dict[str, Any]: ... # type: ignore[override] - __loader__: _LoaderProtocol | None - __package__: str | None - __path__: MutableSequence[str] - __spec__: ModuleSpec | None - def __init__(self, name: str, doc: str | None = ...) -> None: ... - # __getattr__ doesn't exist at runtime, - # but having it here in typeshed makes dynamic imports - # using `builtins.__import__` or `importlib.import_module` less painful - def __getattr__(self, name: str) -> Any: ... - -@final -class GeneratorType(Generator[_T_co, _T_contra, _V_co]): - @property - def gi_yieldfrom(self) -> GeneratorType[_T_co, _T_contra, Any] | None: ... - if sys.version_info >= (3, 11): - @property - def gi_suspended(self) -> bool: ... - __name__: str - __qualname__: str - def __iter__(self) -> GeneratorType[_T_co, _T_contra, _V_co]: ... - def __next__(self) -> _T_co: ... - def send(self, __arg: _T_contra) -> _T_co: ... - @overload - def throw( - self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> _T_co: ... - @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... - -@final -class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): - @property - def ag_await(self) -> Awaitable[Any] | None: ... - __name__: str - __qualname__: str - def __aiter__(self) -> AsyncGeneratorType[_T_co, _T_contra]: ... - def __anext__(self) -> Coroutine[Any, Any, _T_co]: ... - def asend(self, __val: _T_contra) -> Coroutine[Any, Any, _T_co]: ... - @overload - async def athrow( - self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> _T_co: ... - @overload - async def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... - def aclose(self) -> Coroutine[Any, Any, None]: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, __item: Any) -> GenericAlias: ... - -@final -class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]): - __name__: str - __qualname__: str - @property - def cr_origin(self) -> tuple[tuple[str, int, str], ...] | None: ... - if sys.version_info >= (3, 11): - @property - def cr_suspended(self) -> bool: ... - - def close(self) -> None: ... - def __await__(self) -> Generator[Any, None, _V_co]: ... - def send(self, __arg: _T_contra) -> _T_co: ... - @overload - def throw( - self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> _T_co: ... - @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... - -class _StaticFunctionType: - # Fictional type to correct the type of MethodType.__func__. - # FunctionType is a descriptor, so mypy follows the descriptor protocol and - # converts MethodType.__func__ back to MethodType (the return type of - # FunctionType.__get__). But this is actually a special case; MethodType is - # implemented in C and its attribute access doesn't go through - # __getattribute__. - # By wrapping FunctionType in _StaticFunctionType, we get the right result; - # similar to wrapping a function in staticmethod() at runtime to prevent it - # being bound as a method. - def __get__(self, obj: object | None, type: type | None) -> FunctionType: ... - -@final -class MethodType: - @property - def __closure__(self) -> tuple[_Cell, ...] | None: ... # inherited from the added function - @property - def __defaults__(self) -> tuple[Any, ...] | None: ... # inherited from the added function - @property - def __func__(self) -> _StaticFunctionType: ... - @property - def __self__(self) -> object: ... - @property - def __name__(self) -> str: ... # inherited from the added function - @property - def __qualname__(self) -> str: ... # inherited from the added function - def __init__(self, __func: Callable[..., Any], __obj: object) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - -@final -class BuiltinFunctionType: - @property - def __self__(self) -> object | ModuleType: ... - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - -BuiltinMethodType = BuiltinFunctionType - -@final -class WrapperDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, __obj: Any, __type: type = ...) -> Any: ... - -@final -class MethodWrapperType: - @property - def __self__(self) -> object: ... - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __eq__(self, __other: object) -> bool: ... - def __ne__(self, __other: object) -> bool: ... - -@final -class MethodDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: Any, type: type = ...) -> Any: ... - -@final -class ClassMethodDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: Any, type: type = ...) -> Any: ... - -@final -class TracebackType: - def __init__(self, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... - tb_next: TracebackType | None - # the rest are read-only even in 3.7 - @property - def tb_frame(self) -> FrameType: ... - @property - def tb_lasti(self) -> int: ... - @property - def tb_lineno(self) -> int: ... - -@final -class FrameType: - @property - def f_back(self) -> FrameType | None: ... - @property - def f_builtins(self) -> dict[str, Any]: ... - @property - def f_code(self) -> CodeType: ... - @property - def f_globals(self) -> dict[str, Any]: ... - @property - def f_lasti(self) -> int: ... - # see discussion in #6769: f_lineno *can* sometimes be None, - # but you should probably file a bug report with CPython if you encounter it being None in the wild. - # An `int | None` annotation here causes too many false-positive errors. - @property - def f_lineno(self) -> int | Any: ... - @property - def f_locals(self) -> dict[str, Any]: ... - f_trace: Callable[[FrameType, str, Any], Any] | None - f_trace_lines: bool - f_trace_opcodes: bool - def clear(self) -> None: ... - -@final -class GetSetDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __get__(self, __obj: Any, __type: type = ...) -> Any: ... - def __set__(self, __instance: Any, __value: Any) -> None: ... - def __delete__(self, __obj: Any) -> None: ... - -@final -class MemberDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __get__(self, __obj: Any, __type: type = ...) -> Any: ... - def __set__(self, __instance: Any, __value: Any) -> None: ... - def __delete__(self, __obj: Any) -> None: ... - -def new_class( - name: str, - bases: Iterable[object] = ..., - kwds: dict[str, Any] | None = ..., - exec_body: Callable[[dict[str, Any]], object] | None = ..., -) -> type: ... -def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ... -def prepare_class( - name: str, bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... -) -> tuple[type, dict[str, Any], dict[str, Any]]: ... - -# Actually a different type, but `property` is special and we want that too. -DynamicClassAttribute = property - -_Fn = TypeVar("_Fn", bound=Callable[..., object]) -_R = TypeVar("_R") -_P = ParamSpec("_P") - -# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable -# The type: ignore is due to overlapping overloads, not the use of ParamSpec -@overload -def coroutine(func: Callable[_P, Generator[_R, Any, Any]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[misc] -@overload -def coroutine(func: _Fn) -> _Fn: ... - -if sys.version_info >= (3, 8): - CellType = _Cell - -if sys.version_info >= (3, 9): - class GenericAlias: - @property - def __origin__(self) -> type: ... - @property - def __args__(self) -> tuple[Any, ...]: ... - @property - def __parameters__(self) -> tuple[Any, ...]: ... - def __init__(self, origin: type, args: Any) -> None: ... - if sys.version_info >= (3, 11): - @property - def __unpacked__(self) -> bool: ... - @property - def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ... - - def __getattr__(self, name: str) -> Any: ... # incomplete - -if sys.version_info >= (3, 10): - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... - EllipsisType = ellipsis # noqa: F821 from builtins - from builtins import _NotImplementedType - - NotImplementedType = _NotImplementedType - @final - class UnionType: - @property - def __args__(self) -> tuple[Any, ...]: ... - def __or__(self, __obj: Any) -> UnionType: ... - def __ror__(self, __obj: Any) -> UnionType: ... diff --git a/stubs/stdlib/typing.pyi b/stubs/stdlib/typing.pyi deleted file mode 100644 index f66f78b..0000000 --- a/stubs/stdlib/typing.pyi +++ /dev/null @@ -1,841 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import _typeshed -import collections # Needed by aliases like DefaultDict, see mypy issue 2986 -import sys -from _collections_abc import dict_items, dict_keys, dict_values -from _typeshed import IdentityFunction, Incomplete, SupportsKeysAndGetItem -from abc import ABCMeta, abstractmethod -from contextlib import AbstractAsyncContextManager, AbstractContextManager -from re import match as Match, Pattern as Pattern -from types import ( - BuiltinFunctionType, - CodeType, - FrameType, - FunctionType, - MethodDescriptorType, - MethodType, - MethodWrapperType, - ModuleType, - TracebackType, - WrapperDescriptorType, -) -from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, final as _final - -__all__ = [ - "AbstractSet", - "Any", - "AnyStr", - "AsyncContextManager", - "AsyncGenerator", - "AsyncIterable", - "AsyncIterator", - "Awaitable", - "ByteString", - "Callable", - "ChainMap", - "ClassVar", - "Collection", - "Container", - "ContextManager", - "Coroutine", - "Counter", - "DefaultDict", - "Deque", - "Dict", - "FrozenSet", - "Generator", - "Generic", - "Hashable", - "ItemsView", - "Iterable", - "Iterator", - "KeysView", - "List", - "Mapping", - "MappingView", - "MutableMapping", - "MutableSequence", - "MutableSet", - "NamedTuple", - "NewType", - "Optional", - "Reversible", - "Sequence", - "Set", - "Sized", - "SupportsAbs", - "SupportsBytes", - "SupportsComplex", - "SupportsFloat", - "SupportsInt", - "SupportsRound", - "Text", - "Tuple", - "Type", - "TypeVar", - "Union", - "ValuesView", - "TYPE_CHECKING", - "cast", - "get_type_hints", - "no_type_check", - "no_type_check_decorator", - "overload", - "ForwardRef", - "NoReturn", - "OrderedDict", -] - -if sys.version_info >= (3, 8): - __all__ += [ - "Final", - "Literal", - "Protocol", - "SupportsIndex", - "TypedDict", - "final", - "get_args", - "get_origin", - "runtime_checkable", - ] - -if sys.version_info >= (3, 9): - __all__ += ["Annotated", "BinaryIO", "IO", "Match", "Pattern", "TextIO"] - -if sys.version_info >= (3, 10): - __all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"] - -if sys.version_info >= (3, 11): - __all__ += [ - "LiteralString", - "Never", - "NotRequired", - "Required", - "Self", - "TypeVarTuple", - "Unpack", - "assert_never", - "assert_type", - "clear_overloads", - "dataclass_transform", - "get_overloads", - "reveal_type", - ] - -ContextManager = AbstractContextManager -AsyncContextManager = AbstractAsyncContextManager - -# This itself is only available during type checking -def type_check_only(func_or_cls: _F) -> _F: ... - -Any = object() - -@_final -class TypeVar: - __name__: str - __bound__: Any | None - __constraints__: tuple[Any, ...] - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *constraints: Any, bound: Any | None = ..., covariant: bool = ..., contravariant: bool = ... - ) -> None: ... - if sys.version_info >= (3, 10): - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... - if sys.version_info >= (3, 11): - def __typing_subst__(self, arg: Incomplete) -> Incomplete: ... - -# Used for an undocumented mypy feature. Does not exist at runtime. -_promote = object() - -# N.B. Keep this definition in sync with typing_extensions._SpecialForm -@_final -class _SpecialForm: - def __getitem__(self, parameters: Any) -> object: ... - if sys.version_info >= (3, 10): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - -_F = TypeVar("_F", bound=Callable[..., Any]) -_P = _ParamSpec("_P") -_T = TypeVar("_T") - -def overload(func: _F) -> _F: ... - -# Unlike the vast majority module-level objects in stub files, -# these `_SpecialForm` objects in typing need the default value `= ...`, -# due to the fact that they are used elswhere in the same file. -# Otherwise, flake8 erroneously flags them as undefined. -# `_SpecialForm` objects in typing.py that are not used elswhere in the same file -# do not need the default value assignment. -Union: _SpecialForm = ... -Generic: _SpecialForm = ... -# Protocol is only present in 3.8 and later, but mypy needs it unconditionally -Protocol: _SpecialForm = ... -Callable: _SpecialForm = ... -Type: _SpecialForm = ... -NoReturn: _SpecialForm = ... -ClassVar: _SpecialForm = ... - -Optional: _SpecialForm -Tuple: _SpecialForm -if sys.version_info >= (3, 8): - Final: _SpecialForm - def final(f: _T) -> _T: ... - Literal: _SpecialForm - # TypedDict is a (non-subscriptable) special form. - TypedDict: object - -if sys.version_info >= (3, 11): - Self: _SpecialForm - Never: _SpecialForm = ... - Unpack: _SpecialForm - Required: _SpecialForm - NotRequired: _SpecialForm - LiteralString: _SpecialForm - - class TypeVarTuple: - __name__: str - def __init__(self, name: str) -> None: ... - def __iter__(self) -> Any: ... - def __typing_subst__(self, arg: Never) -> Never: ... - def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ... - -if sys.version_info >= (3, 10): - class ParamSpecArgs: - __origin__: ParamSpec - def __init__(self, origin: ParamSpec) -> None: ... - - class ParamSpecKwargs: - __origin__: ParamSpec - def __init__(self, origin: ParamSpec) -> None: ... - - class ParamSpec: - __name__: str - __bound__: Any | None - __covariant__: bool - __contravariant__: bool - def __init__(self, name: str, *, bound: Any | None = ..., contravariant: bool = ..., covariant: bool = ...) -> None: ... - @property - def args(self) -> ParamSpecArgs: ... - @property - def kwargs(self) -> ParamSpecKwargs: ... - if sys.version_info >= (3, 11): - def __typing_subst__(self, arg: Incomplete) -> Incomplete: ... - def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ... - - def __or__(self, right: Any) -> _SpecialForm: ... - def __ror__(self, left: Any) -> _SpecialForm: ... - Concatenate: _SpecialForm - TypeAlias: _SpecialForm - TypeGuard: _SpecialForm - - class NewType: - def __init__(self, name: str, tp: Any) -> None: ... - def __call__(self, x: _T) -> _T: ... - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - __supertype__: type - -else: - def NewType(name: str, tp: Any) -> Any: ... - -# These type variables are used by the container types. -_S = TypeVar("_S") -_KT = TypeVar("_KT") # Key type. -_VT = TypeVar("_VT") # Value type. -_T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers. -_V_co = TypeVar("_V_co", covariant=True) # Any type covariant containers. -_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers. -_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers. -_T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant. -_TC = TypeVar("_TC", bound=Type[object]) - -def no_type_check(arg: _F) -> _F: ... -def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore[misc] - -# Type aliases and type constructors - -class _Alias: - # Class for defining generic aliases for library types. - def __getitem__(self, typeargs: Any) -> Any: ... - -List = _Alias() -Dict = _Alias() -DefaultDict = _Alias() -Set = _Alias() -FrozenSet = _Alias() -Counter = _Alias() -Deque = _Alias() -ChainMap = _Alias() - -OrderedDict = _Alias() - -if sys.version_info >= (3, 9): - Annotated: _SpecialForm - -# Predefined type variables. -AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001 - -# Technically in 3.7 this inherited from GenericMeta. But let's not reflect that, since -# type checkers tend to assume that Protocols all have the ABCMeta metaclass. -class _ProtocolMeta(ABCMeta): ... - -# Abstract base classes. - -def runtime_checkable(cls: _TC) -> _TC: ... -@runtime_checkable -class SupportsInt(Protocol, metaclass=ABCMeta): - @abstractmethod - def __int__(self) -> int: ... - -@runtime_checkable -class SupportsFloat(Protocol, metaclass=ABCMeta): - @abstractmethod - def __float__(self) -> float: ... - -@runtime_checkable -class SupportsComplex(Protocol, metaclass=ABCMeta): - @abstractmethod - def __complex__(self) -> complex: ... - -@runtime_checkable -class SupportsBytes(Protocol, metaclass=ABCMeta): - @abstractmethod - def __bytes__(self) -> bytes: ... - -if sys.version_info >= (3, 8): - @runtime_checkable - class SupportsIndex(Protocol, metaclass=ABCMeta): - @abstractmethod - def __index__(self) -> int: ... - -@runtime_checkable -class SupportsAbs(Protocol[_T_co]): - @abstractmethod - def __abs__(self) -> _T_co: ... - -@runtime_checkable -class SupportsRound(Protocol[_T_co]): - @overload - @abstractmethod - def __round__(self) -> int: ... - @overload - @abstractmethod - def __round__(self, __ndigits: int) -> _T_co: ... - -@runtime_checkable -class Sized(Protocol, metaclass=ABCMeta): - @abstractmethod - def __len__(self) -> int: ... - -@runtime_checkable -class Hashable(Protocol, metaclass=ABCMeta): - # TODO: This is special, in that a subclass of a hashable class may not be hashable - # (for example, list vs. object). It's not obvious how to represent this. This class - # is currently mostly useless for static checking. - @abstractmethod - def __hash__(self) -> int: ... - -@runtime_checkable -class Iterable(Protocol[_T_co]): - @abstractmethod - def __iter__(self) -> Iterator[_T_co]: ... - -@runtime_checkable -class Iterator(Iterable[_T_co], Protocol[_T_co]): - @abstractmethod - def __next__(self) -> _T_co: ... - def __iter__(self) -> Iterator[_T_co]: ... - -@runtime_checkable -class Reversible(Iterable[_T_co], Protocol[_T_co]): - @abstractmethod - def __reversed__(self) -> Iterator[_T_co]: ... - -class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): - def __next__(self) -> _T_co: ... - @abstractmethod - def send(self, __value: _T_contra) -> _T_co: ... - @overload - @abstractmethod - def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> _T_co: ... - @overload - @abstractmethod - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... - def close(self) -> None: ... - def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ... - @property - def gi_code(self) -> CodeType: ... - @property - def gi_frame(self) -> FrameType: ... - @property - def gi_running(self) -> bool: ... - @property - def gi_yieldfrom(self) -> Generator[Any, Any, Any] | None: ... - -@runtime_checkable -class Awaitable(Protocol[_T_co]): - @abstractmethod - def __await__(self) -> Generator[Any, None, _T_co]: ... - -class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]): - __name__: str - __qualname__: str - @property - def cr_await(self) -> Any | None: ... - @property - def cr_code(self) -> CodeType: ... - @property - def cr_frame(self) -> FrameType: ... - @property - def cr_running(self) -> bool: ... - @abstractmethod - def send(self, __value: _T_contra) -> _T_co: ... - @overload - @abstractmethod - def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> _T_co: ... - @overload - @abstractmethod - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... - @abstractmethod - def close(self) -> None: ... - -# NOTE: This type does not exist in typing.py or PEP 484 but mypy needs it to exist. -# The parameters correspond to Generator, but the 4th is the original type. -@type_check_only -class AwaitableGenerator( - Awaitable[_V_co], Generator[_T_co, _T_contra, _V_co], Generic[_T_co, _T_contra, _V_co, _S], metaclass=ABCMeta -): ... - -@runtime_checkable -class AsyncIterable(Protocol[_T_co]): - @abstractmethod - def __aiter__(self) -> AsyncIterator[_T_co]: ... - -@runtime_checkable -class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]): - @abstractmethod - def __anext__(self) -> Awaitable[_T_co]: ... - def __aiter__(self) -> AsyncIterator[_T_co]: ... - -class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]): - def __anext__(self) -> Awaitable[_T_co]: ... - @abstractmethod - def asend(self, __value: _T_contra) -> Awaitable[_T_co]: ... - @overload - @abstractmethod - def athrow( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> Awaitable[_T_co]: ... - @overload - @abstractmethod - def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ... - def aclose(self) -> Awaitable[None]: ... - @property - def ag_await(self) -> Any: ... - @property - def ag_code(self) -> CodeType: ... - @property - def ag_frame(self) -> FrameType: ... - @property - def ag_running(self) -> bool: ... - -@runtime_checkable -class Container(Protocol[_T_co]): - @abstractmethod - def __contains__(self, __x: object) -> bool: ... - -@runtime_checkable -class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]): - # Implement Sized (but don't have it as a base class). - @abstractmethod - def __len__(self) -> int: ... - -class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]): - @overload - @abstractmethod - def __getitem__(self, index: int) -> _T_co: ... - @overload - @abstractmethod - def __getitem__(self, index: slice) -> Sequence[_T_co]: ... - # Mixin methods - def index(self, value: Any, start: int = ..., stop: int = ...) -> int: ... - def count(self, value: Any) -> int: ... - def __contains__(self, value: object) -> bool: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __reversed__(self) -> Iterator[_T_co]: ... - -class MutableSequence(Sequence[_T], Generic[_T]): - @abstractmethod - def insert(self, index: int, value: _T) -> None: ... - @overload - @abstractmethod - def __getitem__(self, index: int) -> _T: ... - @overload - @abstractmethod - def __getitem__(self, index: slice) -> MutableSequence[_T]: ... - @overload - @abstractmethod - def __setitem__(self, index: int, value: _T) -> None: ... - @overload - @abstractmethod - def __setitem__(self, index: slice, value: Iterable[_T]) -> None: ... - @overload - @abstractmethod - def __delitem__(self, index: int) -> None: ... - @overload - @abstractmethod - def __delitem__(self, index: slice) -> None: ... - # Mixin methods - def append(self, value: _T) -> None: ... - def clear(self) -> None: ... - def extend(self, values: Iterable[_T]) -> None: ... - def reverse(self) -> None: ... - def pop(self, index: int = ...) -> _T: ... - def remove(self, value: _T) -> None: ... - def __iadd__(self: _typeshed.Self, values: Iterable[_T]) -> _typeshed.Self: ... - -class AbstractSet(Collection[_T_co], Generic[_T_co]): - @abstractmethod - def __contains__(self, x: object) -> bool: ... - def _hash(self) -> int: ... - # Mixin methods - def __le__(self, other: AbstractSet[Any]) -> bool: ... - def __lt__(self, other: AbstractSet[Any]) -> bool: ... - def __gt__(self, other: AbstractSet[Any]) -> bool: ... - def __ge__(self, other: AbstractSet[Any]) -> bool: ... - def __and__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __or__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... - def __sub__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __xor__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... - def isdisjoint(self, other: Iterable[Any]) -> bool: ... - -class MutableSet(AbstractSet[_T], Generic[_T]): - @abstractmethod - def add(self, value: _T) -> None: ... - @abstractmethod - def discard(self, value: _T) -> None: ... - # Mixin methods - def clear(self) -> None: ... - def pop(self) -> _T: ... - def remove(self, value: _T) -> None: ... - def __ior__(self: _typeshed.Self, it: AbstractSet[_T]) -> _typeshed.Self: ... # type: ignore[override,misc] - def __iand__(self: _typeshed.Self, it: AbstractSet[Any]) -> _typeshed.Self: ... - def __ixor__(self: _typeshed.Self, it: AbstractSet[_T]) -> _typeshed.Self: ... # type: ignore[override,misc] - def __isub__(self: _typeshed.Self, it: AbstractSet[Any]) -> _typeshed.Self: ... - -class MappingView(Sized): - def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented - def __len__(self) -> int: ... - -class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]): - def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented - def __and__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ... - def __rand__(self, other: Iterable[_T]) -> set[_T]: ... - def __contains__(self, item: object) -> bool: ... - def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... - if sys.version_info >= (3, 8): - def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... - - def __or__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ... - def __ror__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ... - def __sub__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ... - def __rsub__(self, other: Iterable[_T]) -> set[_T]: ... - def __xor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ... - def __rxor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ... - -class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): - def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented - def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ... - def __rand__(self, other: Iterable[_T]) -> set[_T]: ... - def __contains__(self, key: object) -> bool: ... - def __iter__(self) -> Iterator[_KT_co]: ... - if sys.version_info >= (3, 8): - def __reversed__(self) -> Iterator[_KT_co]: ... - - def __or__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ... - def __ror__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ... - def __sub__(self, other: Iterable[Any]) -> set[_KT_co]: ... - def __rsub__(self, other: Iterable[_T]) -> set[_T]: ... - def __xor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ... - def __rxor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ... - -class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): - def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented - def __contains__(self, value: object) -> bool: ... - def __iter__(self) -> Iterator[_VT_co]: ... - if sys.version_info >= (3, 8): - def __reversed__(self) -> Iterator[_VT_co]: ... - -class Mapping(Collection[_KT], Generic[_KT, _VT_co]): - # TODO: We wish the key type could also be covariant, but that doesn't work, - # see discussion in https://github.com/python/typing/pull/273. - @abstractmethod - def __getitem__(self, __key: _KT) -> _VT_co: ... - # Mixin methods - @overload - def get(self, __key: _KT) -> _VT_co | None: ... - @overload - def get(self, __key: _KT, default: _VT_co | _T) -> _VT_co | _T: ... - def items(self) -> ItemsView[_KT, _VT_co]: ... - def keys(self) -> KeysView[_KT]: ... - def values(self) -> ValuesView[_VT_co]: ... - def __contains__(self, __o: object) -> bool: ... - -class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): - @abstractmethod - def __setitem__(self, __key: _KT, __value: _VT) -> None: ... - @abstractmethod - def __delitem__(self, __key: _KT) -> None: ... - def clear(self) -> None: ... - @overload - def pop(self, __key: _KT) -> _VT: ... - @overload - def pop(self, __key: _KT, default: _VT | _T) -> _VT | _T: ... - def popitem(self) -> tuple[_KT, _VT]: ... - # This overload should be allowed only if the value type is compatible with None. - # Keep OrderedDict.setdefault in line with MutableMapping.setdefault, modulo positional-only differences. - @overload - def setdefault(self: MutableMapping[_KT, _T | None], __key: _KT) -> _T | None: ... - @overload - def setdefault(self, __key: _KT, __default: _VT) -> _VT: ... - # 'update' used to take a Union, but using overloading is better. - # The second overloaded type here is a bit too general, because - # Mapping[tuple[_KT, _VT], W] is a subclass of Iterable[tuple[_KT, _VT]], - # but will always have the behavior of the first overloaded type - # at runtime, leading to keys of a mix of types _KT and tuple[_KT, _VT]. - # We don't currently have any way of forcing all Mappings to use - # the first overload, but by using overloading rather than a Union, - # mypy will commit to using the first overload when the argument is - # known to be a Mapping with unknown type parameters, which is closer - # to the behavior we want. See mypy issue #1430. - # - # Various mapping classes have __ior__ methods that should be kept roughly in line with .update(): - # -- dict.__ior__ - # -- os._Environ.__ior__ - # -- collections.UserDict.__ior__ - # -- collections.ChainMap.__ior__ - # -- weakref.WeakValueDictionary.__ior__ - # -- weakref.WeakKeyDictionary.__ior__ - @overload - def update(self, __m: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - @overload - def update(self, **kwargs: _VT) -> None: ... - -Text = str - -TYPE_CHECKING: bool - -# In stubs, the arguments of the IO class are marked as positional-only. -# This differs from runtime, but better reflects the fact that in reality -# classes deriving from IO use different names for the arguments. -class IO(Iterator[AnyStr], Generic[AnyStr]): - # TODO use abstract properties - @property - def mode(self) -> str: ... - @property - def name(self) -> str: ... - @abstractmethod - def close(self) -> None: ... - @property - def closed(self) -> bool: ... - @abstractmethod - def fileno(self) -> int: ... - @abstractmethod - def flush(self) -> None: ... - @abstractmethod - def isatty(self) -> bool: ... - @abstractmethod - def read(self, __n: int = ...) -> AnyStr: ... - @abstractmethod - def readable(self) -> bool: ... - @abstractmethod - def readline(self, __limit: int = ...) -> AnyStr: ... - @abstractmethod - def readlines(self, __hint: int = ...) -> list[AnyStr]: ... - @abstractmethod - def seek(self, __offset: int, __whence: int = ...) -> int: ... - @abstractmethod - def seekable(self) -> bool: ... - @abstractmethod - def tell(self) -> int: ... - @abstractmethod - def truncate(self, __size: int | None = ...) -> int: ... - @abstractmethod - def writable(self) -> bool: ... - @abstractmethod - def write(self, __s: AnyStr) -> int: ... - @abstractmethod - def writelines(self, __lines: Iterable[AnyStr]) -> None: ... - @abstractmethod - def __next__(self) -> AnyStr: ... - @abstractmethod - def __iter__(self) -> Iterator[AnyStr]: ... - @abstractmethod - def __enter__(self) -> IO[AnyStr]: ... - @abstractmethod - def __exit__( - self, __t: Type[BaseException] | None, __value: BaseException | None, __traceback: TracebackType | None - ) -> None: ... - -class BinaryIO(IO[bytes]): - @abstractmethod - def __enter__(self) -> BinaryIO: ... - -class TextIO(IO[str]): - # TODO use abstractproperty - @property - def buffer(self) -> BinaryIO: ... - @property - def encoding(self) -> str: ... - @property - def errors(self) -> str | None: ... - @property - def line_buffering(self) -> int: ... # int on PyPy, bool on CPython - @property - def newlines(self) -> Any: ... # None, str or tuple - @abstractmethod - def __enter__(self) -> TextIO: ... - -class ByteString(Sequence[int], metaclass=ABCMeta): ... - -# Functions - -_get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed - object - | Callable[..., Any] - | FunctionType - | BuiltinFunctionType - | MethodType - | ModuleType - | WrapperDescriptorType - | MethodWrapperType - | MethodDescriptorType -) - -if sys.version_info >= (3, 9): - def get_type_hints( - obj: _get_type_hints_obj_allowed_types, - globalns: dict[str, Any] | None = ..., - localns: dict[str, Any] | None = ..., - include_extras: bool = ..., - ) -> dict[str, Any]: ... - -else: - def get_type_hints( - obj: _get_type_hints_obj_allowed_types, globalns: dict[str, Any] | None = ..., localns: dict[str, Any] | None = ... - ) -> dict[str, Any]: ... - -if sys.version_info >= (3, 8): - def get_origin(tp: Any) -> Any | None: ... - def get_args(tp: Any) -> tuple[Any, ...]: ... - -@overload -def cast(typ: Type[_T], val: Any) -> _T: ... -@overload -def cast(typ: str, val: Any) -> Any: ... -@overload -def cast(typ: object, val: Any) -> Any: ... - -if sys.version_info >= (3, 11): - def reveal_type(__obj: _T) -> _T: ... - def assert_never(__arg: Never) -> Never: ... - def assert_type(__val: _T, __typ: Any) -> _T: ... - def clear_overloads() -> None: ... - def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ... - def dataclass_transform( - *, - eq_default: bool = ..., - order_default: bool = ..., - kw_only_default: bool = ..., - field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ..., - **kwargs: Any, - ) -> IdentityFunction: ... - -# Type constructors - -class NamedTuple(tuple[Any, ...]): - if sys.version_info < (3, 8): - _field_types: collections.OrderedDict[str, type] - elif sys.version_info < (3, 9): - _field_types: dict[str, type] - _field_defaults: dict[str, Any] - _fields: tuple[str, ...] - _source: str - @overload - def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ... - @overload - def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ... - @classmethod - def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ... - if sys.version_info >= (3, 8): - def _asdict(self) -> dict[str, Any]: ... - else: - def _asdict(self) -> collections.OrderedDict[str, Any]: ... - - def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ... - -# Internal mypy fallback type for all typed dicts (does not exist at runtime) -# N.B. Keep this mostly in sync with typing_extensions._TypedDict/mypy_extensions._TypedDict -@type_check_only -class _TypedDict(Mapping[str, object], metaclass=ABCMeta): - __total__: ClassVar[bool] - if sys.version_info >= (3, 9): - __required_keys__: ClassVar[frozenset[str]] - __optional_keys__: ClassVar[frozenset[str]] - def copy(self: _typeshed.Self) -> _typeshed.Self: ... - # Using Never so that only calls using mypy plugin hook that specialize the signature - # can go through. - def setdefault(self, k: _Never, default: object) -> object: ... - # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. - def pop(self, k: _Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse] - def update(self: _T, __m: _T) -> None: ... - def __delitem__(self, k: _Never) -> None: ... - def items(self) -> dict_items[str, object]: ... - def keys(self) -> dict_keys[str, object]: ... - def values(self) -> dict_values[str, object]: ... - if sys.version_info >= (3, 9): - def __or__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ... - def __ior__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ... - -@_final -class ForwardRef: - __forward_arg__: str - __forward_code__: CodeType - __forward_evaluated__: bool - __forward_value__: Any | None - __forward_is_argument__: bool - __forward_is_class__: bool - __forward_module__: Any | None - if sys.version_info >= (3, 9): - # The module and is_class arguments were added in later Python 3.9 versions. - def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ..., *, is_class: bool = ...) -> None: ... - else: - def __init__(self, arg: str, is_argument: bool = ...) -> None: ... - - if sys.version_info >= (3, 9): - def _evaluate( - self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None, recursive_guard: frozenset[str] - ) -> Any | None: ... - else: - def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ... - - def __eq__(self, other: object) -> bool: ... - if sys.version_info >= (3, 11): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - -if sys.version_info >= (3, 10): - def is_typeddict(tp: object) -> bool: ... - -def _type_repr(obj: object) -> str: ... diff --git a/stubs/stdlib/uarray.pyi b/stubs/stdlib/uarray.pyi deleted file mode 100644 index c0a542a..0000000 --- a/stubs/stdlib/uarray.pyi +++ /dev/null @@ -1,62 +0,0 @@ -import sys -from collections.abc import Iterable, MutableSequence -from typing import Any, Generic, TypeVar, overload, Union - -_IntTypeCode = ["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] -_FloatTypeCode = ["f", "d"] -_UnicodeTypeCode = ["u"] -_TypeCode = _IntTypeCode|_FloatTypeCode|_UnicodeTypeCode - -_T = TypeVar("_T", int, float, str) - -if sys.version_info.major >= 3: - typecodes: str - -class array(MutableSequence[_T], Generic[_T]): - typecode: _TypeCode - itemsize: int - def __init__(self: Any, typecode: Union[str, _IntTypeCode, _FloatTypeCode, _UnicodeTypeCode], __initializer: Union[bytes, Iterable[_T]] = ...) -> None: - ... - - def append(self, __v: _T) -> None: - ... - - def extend(self, __bb: Iterable[_T]) -> None: - ... - - def __len__(self) -> int: - ... - - @overload - def __getitem__(self, i: int) -> _T: - ... - - @overload - def __getitem__(self, s: slice) -> array[_T]: - ... - - @overload # type: ignore # Overrides MutableSequence - def __setitem__(self, i: int, o: _T) -> None: - ... - - @overload - def __setitem__(self, s: slice, o: array[_T]) -> None: - ... - - def __delitem__(self, i: int|slice) -> None: ... - def __add__(self, x: array[_T]) -> array[_T]: ... - def __ge__(self, other: array[_T]) -> bool: ... - def __gt__(self, other: array[_T]) -> bool: ... - def __iadd__(self, x: array[_T]) -> array[_T]: ... # type: ignore # Overrides MutableSequence - def __imul__(self, n: int) -> array[_T]: ... - def __le__(self, other: array[_T]) -> bool: ... - def __lt__(self, other: array[_T]) -> bool: ... - def __mul__(self, n: int) -> array[_T]: ... - def __rmul__(self, n: int) -> array[_T]: ... - - if sys.version_info.major < 3: - def __delslice__(self, i: int, j: int) -> None: ... - def __getslice__(self, i: int, j: int) -> array[_T]: ... - def __setslice__(self, i: int, j: int, y: array[_T]) -> None: ... - -ArrayType = array diff --git a/stubs/stdlib/ubinascii.pyi b/stubs/stdlib/ubinascii.pyi deleted file mode 100644 index f9bdcc5..0000000 --- a/stubs/stdlib/ubinascii.pyi +++ /dev/null @@ -1,49 +0,0 @@ -""" -Module: 'ubinascii' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def a2b_base64(data: str) -> bytes: - """Decode base64-encoded data, ignoring invalid characters - in the input. Conforms to RFC 2045 s.6.8. Returns - a bytes object. - """ - ... - -def b2a_base64(data: Any, *, newline: bool=True) -> bytes: - """Encode binary data in base64 format, as in RFC 3548. - Returns the encoded data followed by a newline character - if *newline* is true, as a bytes object. - """ - ... - -def crc32(data: Any, value: Any = ...) -> Any: - """Compute CRC-32, the unsigned 32-bit checksum of data, - starting with an initial CRC of value. The default initial - CRC is zero. The algorithm is consistent with the ZIP file - checksum. Since the algorithm is designed for use as a - checksum algorithm, it is not suitable for use as a - general hash algorithm. - - --- - © The Python Software Foundation. - >> https://docs.python.org/3.9/library/binascii.html - """ - ... - -def hexlify(data: Any, sep: Any = ...) -> bytes: - """Convert the bytes in the data object to a hexadecimal - representation. Returns a bytes object. - - If the additional argument *sep* is supplied it is used as - a separator between hexadecimal values. - """ - ... - -def unhexlify(data: Any) -> str: - """Convert hexadecimal data to binary representation. - Returns bytes string. (i.e. inverse of hexlify) - """ - ... - diff --git a/stubs/stdlib/ucollections.pyi b/stubs/stdlib/ucollections.pyi deleted file mode 100644 index 62c36bb..0000000 --- a/stubs/stdlib/ucollections.pyi +++ /dev/null @@ -1,57 +0,0 @@ -""" -Module: 'ucollections' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - - -class OrderedDict(dict): - """``dict`` type subclass which remembers and - preserves the order of keys added. When ordered - dict is iterated over, keys/items are returned - in the order they were added: - """ - - @classmethod - def fromkeys(cls, *args, **kwargs) -> Any: - ... - - -class deque(): - def __init__(self, iterable, maxlen: int, flags: int|Any|None=None) -> None: - """Deques (double-ended queues) are a list-like container that - support O(1) appends and pops from either side of the deque. New - deques are created using the following arguments: - - *iterable* must be the empty tuple, and the new deque is created empty. - - *maxlen* must be specified and the deque will be bounded to this maximum length. Once the deque is full, any new items added will discard items from the opposite end. - - The optional *flags* can be 1 to check for overflow when adding items. - - - As well as supporting ``bool`` and ``len``, deque objects have the following methods - """ - ... - - def append(self, x: Any) -> Any: - """Add x to the right side of the deque. Raises - IndexError if overflow checking is enabled - and there is no more room left. - """ - ... - - def popleft(self) -> Any: - ... - - def __len__(self) -> int: - ... - - def __bool__(self) -> bool: - ... - __nonzero__=__bool__ - - -def namedtuple(name: str, fields: tuple) -> Any: - ... - diff --git a/stubs/stdlib/uerrno.pyi b/stubs/stdlib/uerrno.pyi deleted file mode 100644 index 9f74bf2..0000000 --- a/stubs/stdlib/uerrno.pyi +++ /dev/null @@ -1,23 +0,0 @@ -EACCES = 13 -EADDRINUSE = 112 -EAGAIN = 11 -EALREADY = 120 -EBADF = 9 -ECONNABORTED = 113 -ECONNREFUSED = 111 -ECONNRESET = 104 -EEXIST = 17 -EHOSTUNREACH = 118 -EINPROGRESS = 119 -EINVAL = 22 -EIO = 5 -EISDIR = 21 -ENOBUFS = 105 -ENODEV = 19 -ENOENT = 2 -ENOMEM = 12 -ENOTCONN = 128 -EOPNOTSUPP = 95 -EPERM = 1 -ETIMEDOUT = 116 -errorcode = None diff --git a/stubs/stdlib/uhashlib.pyi b/stubs/stdlib/uhashlib.pyi deleted file mode 100644 index 060f544..0000000 --- a/stubs/stdlib/uhashlib.pyi +++ /dev/null @@ -1,69 +0,0 @@ -""" -Module: 'uhashlib' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - - -class sha1(): - """ - A previous generation algorithm. Not recommended for new - usages, but SHA1 is a part of number of Internet standards - and existing applications, so boards targeting network - connectivity and interoperability will try to provide this. - """ - - def __init__(self, *argv, **kwargs) -> None: - """Create an SHA1 hasher object and optionally feed data into it.""" - ... - - def update(self, data) -> None: - """Feed more binary data into hash.""" - ... - - def digest(self, *args, **kwargs) -> bytes: - """Return hash for all data passed through hash, - as a bytes object. After this method is called, - more data cannot be fed into the hash any longer. - """ - ... - - def hexdigest(self) -> None: - """This method is NOT implemented. - Use ``binascii.hexlify(hash.digest())`` - to achieve a similar effect. - """ - raise NotImplementedError() - - -class sha256(): - """ - The current generation, modern hashing algorithm - (of SHA2 series). It is suitable for - cryptographically-secure purposes. Included - in the MicroPython core and any board is recommended - to provide this, unless it has particular code - size constraints. - """ - - def __init__(self, data: Any = ...) -> None: - """Create an SHA256 hasher object and optionally feed data into it.""" - ... - - def update(self, data) -> None: - """Feed more binary data into hash.""" - ... - - def digest(self) -> bytes: - """Return hash for all data passed through hash, as a - bytes object. After this method is called, more data - cannot be fed into the hash any longer. - """ - ... - - def hexdigest(self) -> None: - """This method is NOT implemented. - Use ``binascii.hexlify(hash.digest())`` - to achieve a similar effect. - """ - raise NotImplementedError() diff --git a/stubs/stdlib/uheapq.pyi b/stubs/stdlib/uheapq.pyi deleted file mode 100644 index 0cebf56..0000000 --- a/stubs/stdlib/uheapq.pyi +++ /dev/null @@ -1,21 +0,0 @@ -""" -Module: 'uheapq' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def heapify(x: list) -> Any: - """Convert the list ``x`` into a heap. This is an in-place operation.""" - ... - -def heappop(heap) -> Any: - """Pop the first item from the ``heap``, and return it. - Raise ``IndexError`` if ``heap`` is empty. - - The returned item will be the smallest item in the ``heap``.""" - ... - -def heappush(heap, item) -> Any: - """Push the ``item`` onto the ``heap``.""" - ... - diff --git a/stubs/stdlib/uio.pyi b/stubs/stdlib/uio.pyi deleted file mode 100644 index 84202ba..0000000 --- a/stubs/stdlib/uio.pyi +++ /dev/null @@ -1,84 +0,0 @@ -""" -Module: 'uio' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def open(name, mode='r', **kwargs) -> Any: - """Open a file. Builtin ``open()`` function is aliased - to this function. All ports (which provide access to file - system) are required to support mode parameter, but support - for other arguments vary by port. - """ - ... - - -class BytesIO(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def readinto(self, *args, **kwargs) -> Any: - ... - - def readline(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - def flush(self, *args, **kwargs) -> Any: - ... - - def getvalue(self) -> Any: - """Get the current contents of the underlying buffer which holds data.""" - ... - - def seek(self, *args, **kwargs) -> Any: - ... - - def tell(self, *args, **kwargs) -> Any: - ... - - -class IOBase(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class StringIO(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def readinto(self, *args, **kwargs) -> Any: - ... - - def readline(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - def flush(self, *args, **kwargs) -> Any: - ... - - def getvalue(self, *args, **kwargs) -> Any: - ... - - def seek(self, *args, **kwargs) -> Any: - ... - - def tell(self, *args, **kwargs) -> Any: - ... - diff --git a/stubs/stdlib/uos.pyi b/stubs/stdlib/uos.pyi deleted file mode 100644 index 9d0740e..0000000 --- a/stubs/stdlib/uos.pyi +++ /dev/null @@ -1,251 +0,0 @@ -""" -Module: 'uos' on micropython-...-rp2 -""" -from typing import Any, Iterator, Optional, Union -from builtins import staticmethod - -def remove(path: str) -> Any: - """Remove a file.""" - ... - - -class VfsFat(): - """Create a filesystem object that uses the - FAT filesystem format. Storage of the FAT - filesystem is provided by ``block_dev``. - Objects created by this constructor can - be mounted using ``mount()``. - """ - - def __init__(self, *argv, **kwargs) -> None: - ... - - def open(self, *args, **kwargs) -> Any: - ... - - def remove(self, *args, **kwargs) -> Any: - ... - - def chdir(self, *args, **kwargs) -> Any: - ... - - def getcwd(self, *args, **kwargs) -> Any: - ... - - def ilistdir(self, *args, **kwargs) -> Any: - ... - - def mkdir(self, *args, **kwargs) -> Any: - ... - - @staticmethod - def mkfs(block_dev) -> Any: - """Build a FAT filesystem on *block_dev*.""" - ... - - def mount(self, *args, **kwargs) -> Any: - ... - - def rename(self, *args, **kwargs) -> Any: - ... - - def rmdir(self, *args, **kwargs) -> Any: - ... - - def stat(self, *args, **kwargs) -> Any: - ... - - def statvfs(self, *args, **kwargs) -> Any: - ... - - def umount(self, *args, **kwargs) -> Any: - ... - - -class VfsLfs2(): - """Filesystem object that uses the littlefs v2 filesystem format""" - - def __init__(self, block_dev, readsize: int=32, progsize: int=32, lookahead: int=32, mtime: bool=True) -> None: - """Create a filesystem object that uses the - littlefs v2 filesystem format. Storage of the - littlefs filesystem is provided by *block_dev*, - which must support the extended interface. - Objects created by this constructor can be - mounted using ``mount()``.""" - ... - - def open(self, *args, **kwargs) -> Any: - ... - - def remove(self, *args, **kwargs) -> Any: - ... - - def chdir(self, *args, **kwargs) -> Any: - ... - - def getcwd(self, *args, **kwargs) -> Any: - ... - - def ilistdir(self, *args, **kwargs) -> Any: - ... - - def mkdir(self, *args, **kwargs) -> Any: - ... - - @staticmethod - def mkfs(block_dev, readsize: int=32, progsize: int=32, lookahead: int=32) -> Any: - """Build a Lfs2 filesystem on *block_dev*.""" - ... - - def mount(self, *args, **kwargs) -> Any: - ... - - def rename(self, *args, **kwargs) -> Any: - ... - - def rmdir(self, *args, **kwargs) -> Any: - ... - - def stat(self, *args, **kwargs) -> Any: - ... - - def statvfs(self, *args, **kwargs) -> Any: - ... - - def umount(self, *args, **kwargs) -> Any: - ... - -def chdir(path: str) -> None: - """Remove a file.""" - ... - -def dupterm(steam_object, index=0,/) -> Any: - """Duplicate or switch the MicroPython terminal (the REPL) on - the given stream-like object. The stream_object argument must - be a native stream object, or derive from io.IOBase and - implement the readinto() and write() methods. The stream - should be in non-blocking mode and readinto() should return - None if there is no data available for reading. - After calling this function all terminal output is repeated - on this stream, and any input that is available on the stream - is passed on to the terminal input. - The index parameter should be a non-negative integer and - specifies which duplication slot is set. A given port may - implement more than one slot (slot 0 will always be available) - and in that case terminal input and output is duplicated on all - the slots that are set. - If None is passed as the stream_object then duplication is - cancelled on the slot given by index. - The function returns the previous stream-like object in the - given slot. - """ - ... - -def getcwd() -> str: - """Get the current directory.""" - ... - -def ilistdir(dir: Optional[str] = None) -> Iterator[Union[tuple[str, int, int], tuple[str, int, int, int]]]: - """This function returns an iterator which then yields - tuples corresponding to the entries in the directory - that it is listing. With no argument it lists the current - directory, otherwise it lists the directory given by dir. - The tuples have the form (name, type, inode[, size]): - - *name* is a string (or bytes if dir is a bytes object) - and is the name of the entry; - - *type* is an integer that specifies the type of the entry, with 0x4000 for directories and 0x8000 for regular files; - - *inode* is an integer corresponding to the inode of the file, and may be 0 for filesystems that don't have such a notion. - - Some platforms may return a 4-tuple that includes the entry's *size*. For file entries, size is an integer representing the size of the file or -1 if unknown. Its meaning is currently undefined for directory entries. - """ - ... - -def listdir(dir: Optional[str] = None) -> list[str]: - """With no argument, list the current directory. - Otherwise list the given directory. - """ - ... - -def mkdir(path: str) -> None: - """Create a new directory.""" - ... - -def mount(fsobj, mount_point, *, readonly: bool) -> Any: - """Mount the filesystem object fsobj at the location in the VFS - given by the mount_point string. fsobj can be a a VFS object that - has a ``mount()`` method, or a block device. If it's a block device - then the filesystem type is automatically detected (an exception - is raised if no filesystem was recognised). mount_point may - be ``'/'`` to mount fsobj at the root, or ``'/'`` to mount - it at a subdirectory under the root. - If readonly is ``True`` then the filesystem is mounted read-only. - During the mount process the method ``mount()`` is called on the filesystem object. - Will raise ``OSError(EPERM)`` if mount_point is already mounted. - """ - ... - -def rename(old_path: str, new_path: str) -> None: - """Rename a file.""" - ... - -def rmdir(path: str) -> Any: - """Remove a directory.""" - ... - -def stat(path: str) -> Any: - """Get the status of a file or directory.""" - ... - -def statvfs(path: str) -> tuple[str, str, str, str, str, str, str, str, str, str]: - """Get the status of a fileystem. - Returns a tuple with the filesystem information in the following order: - - ``f_bsize`` - file system block size - - ``f_frsize`` - fragment size - - ``f_blocks`` - size of fs in f_frsize units - - ``f_bfree`` - number of free blocks - - ``f_bavail`` - number of free blocks for unprivileged users - - ``f_files`` - number of inodes - - ``f_ffree`` - number of free inodes - - ``f_favail`` - number of free inodes for unprivileged users - - ``f_flag`` - mount flags - - ``f_namemax`` - maximum filename length - Parameters related to inodes: ``f_files``, ``f_ffree``, ``f_avail`` - and the ``f_flags`` parameter may return ``0`` as they can be unavailable - in a port-specific implementation. - """ - ... - -def sync(): - """Sync all filesystems. - """ - ... - -def umount(mount_point) -> Any: - """Unmount a filesystem. mount_point can be a string naming - the mount location, or a previously-mounted filesystem object. - During the unmount process the method ``umount()`` is called - on the filesystem object. - Will raise ``OSError(EINVAL)`` if mount_point is not found. - """ - ... - -def uname() -> tuple[str, str, str, str, str]: - """Return a tuple (possibly a named tuple) containing information about - the underlying machine and/or its operating system. The tuple has five - fields in the following order, each of them being a string: - - ``sysname`` - the name of the underlying system - - ``nodename`` - the network name (can be the same as ``sysname``) - - ``release`` - the version of the underlying system - - ``version`` - the MicroPython version and build date - - ``machine`` - an identifier for the underlying hardware (eg board, CPU) - """ - ... - -def unlink(*args, **kwargs) -> Any: - ... - -def urandom(n: int) -> bytes: - """Return a bytes object with n random bytes. Whenever - possible, it is generated by the hardware random - number generator. - """ - ... diff --git a/stubs/stdlib/uplatform.pyi b/stubs/stdlib/uplatform.pyi deleted file mode 100644 index c90179b..0000000 --- a/stubs/stdlib/uplatform.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from typing import Any - -def libc_ver(*args, **kwargs) -> tuple[str, str]: - """ - Tries to determine the libc version against which the MicroPython executable is linked. - Returns a tuple of strings (lib, version) which default to the given parameters in - case the lookup fails. - """ - ... - -def platform(*args, **kwargs) -> str: - """ - Returns a single string identifying the underlying platform with as much useful - information as possible. - """ - ... - -def python_compiler() -> str: - """Returns a string identifying the compiler used for compiling MicroPython.""" - ... diff --git a/stubs/stdlib/urandom.pyi b/stubs/stdlib/urandom.pyi deleted file mode 100644 index 72f9bfa..0000000 --- a/stubs/stdlib/urandom.pyi +++ /dev/null @@ -1,72 +0,0 @@ -""" -Generate pseudo-random numbers. -""" -from collections.abc import Sequence -from typing import TypeVar, overload, Optional - -_T = TypeVar("_T") - -def choice(sequence: Sequence[_T]) -> _T: - """ - Return a random element from the non-empty sequence ``sequence``. - If ``sequence`` is empty, raises ``IndexError``. - """ - ... - -def getrandbits(n: int) -> int: - """ - Returns a python ``long`` int with ``n`` (0 <= n <= 32) random bits. - This method is supplied with the MersenneTwister generator and some - other generators may also provide it as an optional part of the API. - When available, ``getrandbits()`` enables ``randrange()`` to handle - arbitrarily large ranges. - """ - ... - -def randint(a: int, b: int) -> int: - """ - Return a random integer N such that ``a <= N <= b``. - """ - ... - -def random() -> float: - """ - Return the next random floating point number in the range [0.0, 1.0]. - """ - ... - -@overload -def randrange(stop: int) -> int: - ... - -@overload -def randrange(start: int, stop: int, step: int = ...) -> int: - """ - Return a randomly selected element from ``range(start, stop, step)``. This is - equivalent to ``choice(range(start, stop, step))``, but doesn't actually build a - range object. - """ - ... - -def seed(n: Optional[int] =None,/) -> None: - """Initialise the random number generator module with the - seed *n* which should be an integer. When no argument (or ``None``) - is passed in it will (if supported by the port) initialise - the PRNG with a true random number (usually a hardware - generated random number). - - The ``None`` case only works if ``MICROPY_PY_URANDOM_SEED_INIT_FUNC`` - is enabled by the port, otherwise it raises ``ValueError``. - """ - ... - -def uniform(a: float, b: float) -> float: - """ - Return a random floating point number N such that ``a <= N <= b`` for ``a <= b`` - and ``b <= N <= a`` for ``b < a``. - - The end-point value ``b`` may or may not be included in the range depending on - floating-point rounding in the equation ``a + (b-a) * random()``. - """ - ... - diff --git a/stubs/stdlib/ure.pyi b/stubs/stdlib/ure.pyi deleted file mode 100644 index 6040964..0000000 --- a/stubs/stdlib/ure.pyi +++ /dev/null @@ -1,37 +0,0 @@ -""" -Module: 'ure' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def compile(regex_str: str, **kwargs) -> Any: - """Compile regular expression, return regex object.""" - ... - -def match(*args, **kwargs) -> Any: - """Compile regex_str and match against string. Match - always happens from starting position in a string. - """ - ... - -def search(regex_str: str, string: str) -> Any: - """Compile *regex_str* and search it in a *string*. - Unlike ``match``, this will search string for first - position which matches regex (which still may - be 0 if regex is anchored).""" - ... - -def sub(regex_str: str, replace, string: str, count: int=0, flags: int=0, /) -> str: - """Compile *regex_str* and search for it in *string*, replacing all matches with - *replace*, and returning the new string. - - *replace* can be a string or a function. If it is a string then escape - sequences of the form ``\`` and ``\g`` can be used to - expand to the corresponding group (or an empty string for unmatched groups). - If replace is a function then it must take a single argument (the match) - and should return a replacement string. - - If *count* is specified and non-zero then substitution will stop after this many - substitutions are made. The flags argument is ignored. - """ - ... diff --git a/stubs/stdlib/uselect.pyi b/stubs/stdlib/uselect.pyi deleted file mode 100644 index ae13771..0000000 --- a/stubs/stdlib/uselect.pyi +++ /dev/null @@ -1,67 +0,0 @@ -""" -Module: 'uselect' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from collections.abc import Iterator -from typing import Any - -POLLERR = 8 # type: int -POLLHUP = 16 # type: int -POLLIN = 1 # type: int -POLLOUT = 4 # type: int - -class _poll: - """This class does not exist like so in current firmware. - It's only for linting and autocompletion purposes. - - ``uselect.poll()`` returns ```` type with these methods - on current firmware. - """ - - def ipoll(self, timeout: int=-1, flags=0,/) -> Iterator[Any]: - """Like poll.poll(), but instead returns an iterator which - yields a callee-owned tuple. This function provides an - efficient, allocation-free way to poll on streams. - """ - ... - - def modify(self, obj: Any, eventmask: Any) -> Any: - """Modify the eventmask for obj. If obj is not registered, - ``OSError`` is raised with error of ENOENT. - """ - ... - - def poll(self, timeout: int = -1, /) -> Any: - """Wait for at least one of the registered objects to become - ready or have an exceptional condition, with optional timeout - in milliseconds (if timeout arg is not specified or -1, - there is no timeout). - """ - ... - - def register(self, obj: Any, eventmask: int= POLLIN | POLLOUT) -> Any: - """Register stream obj for polling. eventmask is logical OR of: - - - ``select.POLLIN`` - data available for reading - - ``select.POLLOUT`` - more data can be written - """ - ... - - def unregister(self, obj: Any) -> None: - """Unregister obj from polling.""" - ... - - -def poll() -> _poll: - """Create an instance of the Poll class.""" - ... - -def select(rlist, wlist, xlist, timeout: Any = ...) -> Any: - """Wait for activity on a set of objects. - - This function is provided by some MicroPython ports - for compatibility and is not efficient. Usage of - Poll is recommended instead. - """ - ... - diff --git a/stubs/stdlib/usocket.pyi b/stubs/stdlib/usocket.pyi deleted file mode 100644 index 09baa60..0000000 --- a/stubs/stdlib/usocket.pyi +++ /dev/null @@ -1,247 +0,0 @@ -""" -Module: 'usocket' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any, Union, Optional - -AF_INET = 2 # type: int -AF_INET6 = 10 # type: int -IPPROTO_IP = 0 # type: int -IP_ADD_MEMBERSHIP = 1024 # type: int -IP_DROP_MEMBERSHIP = 1025 # type: int -SOCK_DGRAM = 2 # type: int -SOCK_RAW = 3 # type: int -SOCK_STREAM = 1 # type: int -SOL_SOCKET = 1 # type: int -SO_BROADCAST = 32 # type: int -SO_REUSEADDR = 4 # type: int - -def callback(*args, **kwargs) -> Any: - ... - -def getaddrinfo(host, port, af=0, type=0, proto=0, flags=0, /) -> Any: - """Translate the host/port argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. Arguments af, type, and proto (which have the same meaning as for the socket() function) can be used to filter which kind of addresses are returned. If a parameter is not specified or zero, all combinations of addresses can be returned (requiring filtering on the user side). - - The resulting list of 5-tuples has the following structure:: - - (family, type, proto, canonname, sockaddr) - """ - ... - -def print_pcbs(*args, **kwargs) -> Any: - ... - -def reset(*args, **kwargs) -> Any: - ... - - -class socket(): - def __init__(self, af=AF_INET, type=SOCK_STREAM, proto: int=0, /) -> None: - """! NOTE: proto might not default to 0 on all MicroPython implementations - - Create a new socket using the given address family, socket type and - protocol number. Note that specifying proto in most cases is not - required (and not recommended, as some MicroPython ports may omit - ``IPPROTO_*`` constants). Instead, type argument will select needed - protocol automatically: - - Create STREAM TCP socket:: - socket(AF_INET, SOCK_STREAM) - - Create DGRAM UDP socket:: - socket(AF_INET, SOCK_DGRAM) - """ - ... - - def close(self) -> Any: - """Mark the socket closed and release - all resources. Once that happens, all - future operations on the socket object - will fail. The remote end will receive - EOF indication if supported by protocol. - - Sockets are automatically closed when they - are garbage-collected, but it is recommended - to ``close()`` them explicitly as soon you - finished working with them. - """ - ... - - def read(self, size: Optional[int]=None) -> bytes: - """Read up to *size* bytes from the socket. - Return a bytes object. If *size* is not given, - it reads all data available from the socket - until EOF; as such the method will not return - until the socket is closed. This function tries - to read as much data as requested - (no “short reads”). This may be not possible - with non-blocking socket though, and then less - data will be returned. - """ - ... - - def readinto(self, *args, **kwargs) -> Any: - ... - - def readline(self) -> Any: - """Read a line, ending in a newline character. - - Return value: the line read. - """ - ... - - def send(self, bytes) -> Any: - """Send data to the socket. The socket - must be connected to a remote socket. - Returns number of bytes sent, which may - be smaller than the length of - data (“short write”). - """ - ... - - def write(self, buf) -> int: - """Write the buffer of bytes to the socket. - This function will try to write all data to - a socket (no “short writes”). This may be - not possible with a non-blocking socket - though, and returned value will be less - than the length of *buf*. - - Return value: number of bytes written.""" - ... - - def accept(self) -> Any: - """Accept a connection. The socket - must be bound to an address and - listening for connections. The - return value is a pair (conn, address) - where conn is a new socket object - usable to send and receive data on - the connection, and address is the - address bound to the socket on the - other end of the connection. - """ - ... - - def bind(self, address) -> Any: - """Bind the socket to address. The socket must not already be bound.""" - ... - - def connect(self, address: Union[tuple, list]) -> Any: - """Connect to a remote socket at address.""" - ... - - def listen(self, backlog: Optional[int] =None) -> Any: - """Enable a server to accept connections. If - *backlog* is specified, it must be at least 0 - (if it's lower, it will be set to 0); and - specifies the number of unaccepted connections - that the system will allow before refusing new - connections. If not specified, a default - reasonable value is chosen. - """ - ... - - def makefile(self, mode='rb', buffering=0,/) -> Any: - """Return a file object associated with the socket. - The exact returned type depends on the arguments - given to ``makefile()``. The support is limited to - binary modes only ('rb', 'wb', and 'rwb'). CPython's - arguments: encoding, errors and newline are - not supported. - - | NOTE: at the moment firmware 1.19.1, MicroPython does - not support buffered stream, values of *buffering** - parameter are ignored and treated as if it - was 0 (unbuffered). - - | NOTE: Closing the file object returned - by ``makefile()`` WILL close the original - socket as well. - """ - ... - - def recv(self, bufsize) -> Any: - """Receive data from the socket. - The return value is a bytes object - representing the data received. The - maximum amount of data to be received - at once is specified by bufsize. - """ - ... - - def recvfrom(self, bufsize) -> Any: - """Receive data from the socket. The return - value is a pair (bytes, address) where bytes - is a bytes object representing the data received - and address is the address of the socket - sending the data. - """ - ... - - def sendall(self, bytes) -> Any: - """Send all data to the socket. The socket - must be connected to a remote socket. Unlike - send(), this method will try to send all of - data, by sending data chunk by chunk consecutively. - - The behaviour of this method on non-blocking - sockets is undefined. Due to this, on MicroPython, - it's recommended to use ``write()`` method instead, - which has the same “no short writes” policy for - blocking sockets, and will return number of bytes - sent on non-blocking sockets. - """ - ... - - def sendto(self, bytes, address) -> Any: - """Send data to the socket. The socket should not be - connected to a remote socket, since the destination - socket is specified by address. - """ - ... - - def setblocking(self, flag) -> Any: - """Set blocking or non-blocking mode of the socket: - if flag is false, the socket is set to non-blocking, - else to blocking mode. - - This method is a shorthand for certain - ``settimeout()`` calls: - - - ``sock.setblocking(True)`` is equivalent - to ``sock.settimeout(None)`` - - - ``sock.setblocking(False)`` is equivalent - to ``sock.settimeout(0)`` - """ - ... - - def setsockopt(self, level, optname, value) -> Any: - """Set the value of the given socket option. The - needed symbolic constants are defined in the socket - module (SO_* etc.). The value can be an integer or - a bytes-like object representing a buffer. - """ - ... - - def settimeout(self, value) -> None: - """Note: Not every port supports this method, see below. - - Set a timeout on blocking socket operations. The value - argument can be a nonnegative floating point number - expressing seconds, or None. If a non-zero value is given, - subsequent socket operations will raise an ``OSError`` - exception if the timeout period value has elapsed before - the operation has completed. If zero is given, the socket - is put in non-blocking mode. If None is given, the socket - is put in blocking mode. - - Not every MicroPython port supports this method. A more - portable and generic solution is to use ``select.poll`` - object. This allows to wait on multiple objects at the - same time (and not just on sockets, but on generic - ``stream`` objects which support polling). - """ - ... - diff --git a/stubs/stdlib/ussl.pyi b/stubs/stdlib/ussl.pyi deleted file mode 100644 index c395a9c..0000000 --- a/stubs/stdlib/ussl.pyi +++ /dev/null @@ -1,84 +0,0 @@ -""" -Module: 'ssl' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from usocket import socket - -CERT_NONE = 0 # type: int -"""Supported value for cert_reqs parameter""" -CERT_OPTIONAL = 1 # type: int -"""Supported value for cert_reqs parameter""" -CERT_REQUIRED = 2 # type: int -"""Supported value for cert_reqs parameter""" -PROTOCOL_TLS_CLIENT = 0 # type: int -PROTOCOL_TLS_SERVER = 1 # type: int - -class SSLContext(): - def __init__(self, protocol: int, /) -> None: - """ - Create a new SSLContext instance. The protocol argument must be one of the PROTOCOL_* constants. - """ - ... - - def wrap_socket( - self, - sock, - *, - server_side=False, - do_handshake_on_connect=True, - server_hostname=None) -> SSLContext: - """ - Takes a stream sock (usually socket.socket instance of SOCK_STREAM type), and returns - an instance of ssl.SSLSocket, wrapping the underlying stream. The returned object has the - usual stream interface methods like read(), write(), etc. - - - `server_side` selects whether the wrapped socket is on the server or client side. - A server-side SSL socket should be created from a normal socket returned from accept() - on a non-SSL listening server socket. - - - `do_handshake_on_connect` determines whether the handshake is done as part of the - `wrap_socket` or whether it is deferred to be done as part of the initial reads or - writes For blocking sockets doing the handshake immediately is standard. For - non-blocking sockets (i.e. when the sock passed into `wrap_socket` is in - non-blocking mode) the handshake should generally be deferred because otherwise - `wrap_socket` blocks until it completes. Note that in AXTLS the handshake can be - deferred until the first read or write but it then blocks until completion. - - - `server_hostname` is for use as a client, and sets the hostname to check - against the received server certificate. It also sets the name for Server - Name Indication (SNI), allowing the server to present the proper certificate. - """ - ... - -def wrap_socket( - sock, - server_side=False, - keyfile=None, - certfile=None, - cert_reqs=CERT_NONE, - cadata=None, - server_hostname=None, - do_handshake=True - ) -> socket: - """ - Wrap the given sock and return a new wrapped-socket object. - The implementation of this function is to first create an `SSLContext` - and then call the SSLContext.wrap_socket method on that context object. - The arguments sock, server_side and server_hostname are passed through - unchanged to the method call. The argument do_handshake is passed through - as `do_handshake_on_connect`. The remaining arguments have the following - behaviour: - - - cert_reqs determines whether the peer (server or client) must present - a valid certificate. Note that for mbedtls based ports, `ssl.CERT_NONE` - and `ssl.CERT_OPTIONAL` will not validate any certificate, - only `ssl.CERT_REQUIRED` will. - - - `cadata` is a bytes object containing the CA certificate chain - (in DER format) that will validate the peer’s certificate. - Currently only a single DER-encoded certificate is supported. - - Depending on the underlying module implementation in a particular - MicroPython port, some or all keyword arguments above may be not supported. - """ - ... diff --git a/stubs/stdlib/ustruct.pyi b/stubs/stdlib/ustruct.pyi deleted file mode 100644 index 41aeeb9..0000000 --- a/stubs/stdlib/ustruct.pyi +++ /dev/null @@ -1,36 +0,0 @@ -""" -Module: 'ustruct' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def calcsize(fmt: str) -> int: - """Return the number of bytes needed to store the given *fmt*.""" - ... - -def pack(fmt: str, v1: Any, *vn: Any) -> Any: - """Pack the values v1, v2, … according to the format - string fmt. The return value is a bytes object - encoding the values. - """ - ... - -def pack_into(fmt: str, buffer: Any, offset: int, v1: Any, *vn: Any) -> Any: - """Pack the values v1, v2, … according to the format string fmt into a buffer - starting at offset. offset may be negative to count from the end of buffer. - """ - ... - -def unpack(fmt: str, data: Any) -> tuple[Any]: - """Unpack from the data according to the format string *fmt*. - The return value is a tuple of the unpacked values. - """ - ... - -def unpack_from(fmt: str, data: Any, offset=0, /) -> Any: - """Unpack from the *data* starting at offset according to the - format string *fmt*. offset may be negative to count from the - end of buffer. The return value is a tuple of the unpacked - values. - """ - ... diff --git a/stubs/stdlib/usys.pyi b/stubs/stdlib/usys.pyi deleted file mode 100644 index 6aaaaf9..0000000 --- a/stubs/stdlib/usys.pyi +++ /dev/null @@ -1,71 +0,0 @@ -from typing import Any - -argv = [] # type: list -"""A mutable list of arguments the current program was started with.""" -byteorder = 'little' # type: str -"""The byte order of the system (``"little"`` or ``"big"``).""" - -def exit(retval=0,/) -> Any: - """Terminate current program with a given - exit code. Underlyingly, this function - raise as ``SystemExit`` exception. If an - argument is given, its value given as - an argument to ``SystemExit``. - """ - ... - -implementation = () # type: tuple -"""Object with information about the current Python -implementation. For MicroPython, it has following attributes: - -- *name* - string “micropython” -- *version* - tuple (major, minor, micro), e.g. (1, 7, 0) -- *_machine* - string describing the underlying machine -- *_mpy* - supported mpy file-format version (optional attribute) - -This object is the recommended way to distinguish MicroPython -from other Python implementations (note that it still may not -exist in the very minimal ports). -""" -maxsize = 2147483647 # type: int -"""Maximum value which a native integer type can hold on the -current platform, or maximum value representable by -MicroPython integer type, if it's smaller than platform max -value (that is the case for MicroPython ports without long -int support). -""" -modules = {} # type: dict -"""Dictionary of loaded modules. On some ports, -it may not include builtin modules. -""" -path = [] # type: list -"""A mutable list of directories to search for imported modules.""" -platform = 'rp2' # type: str -"""The platform that MicroPython is running on.""" - -def print_exception(exc, file=stdout, /) -> Any: - """Print exception with a traceback to a file-like - object file (or ``usys.stdout`` by default). - """ - ... - -ps1 = '>>> ' # type: str -"""Mutable attributes holding strings, which are used -for the REPL prompt. The defaults give the standard -Python prompt of ``>>> `` and ``.... `` -""" -ps2 = '... ' # type: str -"""Mutable attributes holding strings, which are used -for the REPL prompt. The defaults give the standard -Python prompt of ``>>> `` and ``.... `` -""" -stderr : Any ## = -"""Standard error ``stream``.""" -stdin : Any ## = -"""Standard input ``stream``.""" -stdout : Any ## = -"""Standard output ``stream``.""" -version = '3.4.0; MicroPython v1.21.0 on 2023-10-06' # type: str -"""Python language version that this implementation conforms to, as a string.""" -version_info = () # type: tuple -"""Python language version that this implementation conforms to, as a tuple of ints.""" diff --git a/stubs/stdlib/utime.pyi b/stubs/stdlib/utime.pyi deleted file mode 100644 index 805edef..0000000 --- a/stubs/stdlib/utime.pyi +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright (c) 2019, Digi International, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -from typing import Union, Optional - -def gmtime(secs: Optional[int]=None) -> tuple: - """ - Converts a time expressed in seconds since the Epoch into an 8-tuple which - contains: - - * ``year`` - * ``month`` - * ``mday`` - * ``hour`` - * ``minute`` - * ``second`` - * ``weekday`` - * ``yearday`` - - :param secs: The time to convert. If not provided or ``None``, then the - current time from the RTC is used. - - :return: The tuple containing the converted time. - """ - ... - -def localtime(secs: Optional[int]=None) -> tuple: - """ - Converts a time expressed in seconds since the Epoch into an 8-tuple which - contains: - - * ``year`` - * ``month`` - * ``mday`` - * ``hour`` - * ``minute`` - * ``second`` - * ``weekday`` - * ``yearday`` - - :param secs: The time to convert. If not provided or ``None``, then the - current time from the RTC is used. - - :return: The tuple containing the converted time. - """ - ... - -def mktime(local_time: tuple) -> int: - """ - This is inverse function of localtime. Its argument is a full 8-tuple - which expresses a time as per localtime. It returns an integer which is - the number of seconds since Jan 1, 2000. - - :param local_time: Full 8-tuple which expresses a time as per localtime. - - :return: Amount of seconds since Epoch for the given time. - """ - ... - -def time() -> int: - """ - Returns the number of seconds, as an integer, since the Epoch, assuming - that underlying RTC is set and maintained. If an RTC is not set, this - function returns number of seconds since a port-specific reference point - in time (for embedded boards without a battery-backed RTC, usually since - power up or reset). - - If you want to develop portable MicroPython application, you should not - rely on this function to provide higher than second precision. If you need - higher precision, use ``ticks_ms()`` and ``ticks_us()`` functions, if you - need calendar time, ``localtime()`` without an argument is a better choice. - - :return: Number of seconds, as an integer, since the Epoch. - """ - ... - -def time_ns() -> int: - """ - Returns the number of nanoseconds, as an integer, since the Epoch, assuming - that underlying RTC is set and maintained. If an RTC is not set, this - function returns number of seconds since a port-specific reference point - in time (for embedded boards without a battery-backed RTC, usually since - power up or reset). - - If you want to develop portable MicroPython application, you should not - rely on this function to provide higher than second precision. If you need - higher precision, use ``ticks_ms()`` and ``ticks_us()`` functions, if you - need calendar time, ``localtime()`` without an argument is a better choice. - - :return: Number of seconds, as an integer, since the Epoch. - """ - ... - -def sleep(seconds: Union[int, float]) -> None: - """ - Sleeps for the given number of seconds. Some boards may accept seconds - as a floating-point number to sleep for a fractional number of seconds. - Note that other boards may not accept a floating-point argument, for - compatibility with them use ``sleep_ms()`` and ``sleep_us()`` functions. - - :param seconds: Amount of time to sleep for. - """ - ... - -def sleep_ms(ms: int) -> None: - """ - Delays for given number of milliseconds, should be positive or 0. - - :param ms: Delay in milliseconds. - """ - ... - -def sleep_us(us: int) -> None: - """ - Delays for given number of microseconds, should be positive or 0. - - :param us: Delay in microseconds - """ - ... - -def ticks_ms() -> int: - """ - Returns the uptime of the XBee module in milliseconds. - - :return: The uptime of the module in milliseconds. - """ - ... - -def ticks_us() -> int: - """ - Returns the uptime of the XBee module in microseconds. - - :return: The uptime of the module in microseconds. - """ - ... - -def ticks_cpu() -> int: - """ - Returns the uptime of the module in microseconds but with a higher - resolution (faster). - - :return: The uptime of the module in microseconds. - """ - ... - -def ticks_add(ticks: int, delta: int) -> int: - """ - Offsets ticks value by a given number, which can be either positive or - negative. Given a ticks value, this function allows to calculate ticks - value delta ticks before or after it, following modular-arithmetic - definition of tick values (see ``ticks_ms()``). - - This method is useful for calculating deadlines for events/tasks. - - **Note**: You must use ``ticks_diff()`` function to work with deadlines. - - :param ticks: Number obtained from a direct result of call to - ``ticks_ms()``, ``ticks_us()``, or ``ticks_cpu()`` functions (or from - previous call to ``ticks_add()``) - :param delta: Arbitrary integer number or numeric expression. - - :return: Returns the result of the add operation. - """ - ... - -def ticks_diff(ticks1: int, ticks2: int) -> int: - """ - Measures the period (ticks) difference between values returned from - ``ticks_ms()``, ``ticks_us()``, or ``ticks_cpu()`` functions, as a signed - value which may wrap around, so directly subtracting them is not supported. - - The argument order is the same as for subtraction operator, - ``ticks_diff(ticks1, ticks2)`` has the same meaning as ``ticks1 - ticks2``. - - :param ticks1: Ticks that precede in time the value of ``ticks2``. - :param ticks2: Second (newer) ticks value. - - :return: The difference between the given ticks values. - """ - ... diff --git a/stubs/stubs/aioble/__init__.py b/stubs/stubs/aioble/__init__.py deleted file mode 100644 index cc218c4..0000000 --- a/stubs/stubs/aioble/__init__.py +++ /dev/null @@ -1,110 +0,0 @@ -""" -Module: 'aioble.__init__' on micropython-v1.20-441-rp2 -""" -# MCU: {'ver': 'v1.20-441', 'build': '441', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.20.0', 'release': '1.20.0', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -# Stubber: 1.5.7 -from typing import Any - -def const(*args, **kwargs) -> Any: - ... - -def stop(*args, **kwargs) -> Any: - ... - -def config(*args, **kwargs) -> Any: - ... - - -class scan(): - def __init__(self, *argv, **kwargs) -> None: - ... - - cancel : Any ## = - -class Device(): - def __init__(self, *argv, **kwargs) -> None: - ... - - connect : Any ## = - def addr_hex(self, *args, **kwargs) -> Any: - ... - - -class DeviceDisconnectedError(Exception): - ... -def log_info(*args, **kwargs) -> Any: - ... - -def log_warn(*args, **kwargs) -> Any: - ... - -def log_error(*args, **kwargs) -> Any: - ... - - -class GattError(Exception): - ... -advertise : Any ## = - -class Service(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class Characteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - - def notify(self, *args, **kwargs) -> Any: - ... - - indicate : Any ## = - -class BufferedCharacteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - - def notify(self, *args, **kwargs) -> Any: - ... - - indicate : Any ## = - -class Descriptor(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - -def register_services(*args, **kwargs) -> Any: - ... - -ADDR_PUBLIC = 0 # type: int -ADDR_RANDOM = 1 # type: int diff --git a/stubs/stubs/aioble/central.py b/stubs/stubs/aioble/central.py deleted file mode 100644 index 713f8ff..0000000 --- a/stubs/stubs/aioble/central.py +++ /dev/null @@ -1,70 +0,0 @@ -from typing import Any, Optional -from ubluetooth import BLE - -def const(*args, **kwargs) -> Any: - ... - - -class scan(): - def __init__(self, duration_ms, interval_us=None, window_us=None, active=False): - ... - - async def cancel(self) -> None: - ... - -def log_info(*args, **kwargs) -> Any: - ... - -def log_warn(*args, **kwargs) -> Any: - ... - -def log_error(*args, **kwargs) -> Any: - ... - -def ensure_active(*args, **kwargs) -> Any: - ... - -def register_irq_handler(*args, **kwargs) -> Any: - ... - -ble : BLE - -class DeviceTimeout(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class DeviceConnection(): - def __init__(self, *argv, **kwargs) -> None: - ... - - disconnect : Any ## = - def timeout(self, *args, **kwargs) -> Any: - ... - - device_task : Any ## = - disconnected : Any ## = - def is_connected(self, *args, **kwargs) -> Any: - ... - - service : Any ## = - def services(self, *args, **kwargs) -> Any: - ... - - pair : Any ## = - exchange_mtu : Any ## = - l2cap_accept : Any ## = - l2cap_connect : Any ## = - -class ScanResult(): - def __init__(self, device) -> None: - ... - - def name(self) -> Optional[str]: - ... - - def services(self) -> Any: - ... - - def manufacture(self, filter=None) -> Any: - ... diff --git a/stubs/stubs/aioble/client.py b/stubs/stubs/aioble/client.py deleted file mode 100644 index f194600..0000000 --- a/stubs/stubs/aioble/client.py +++ /dev/null @@ -1,92 +0,0 @@ -""" -Module: 'aioble.client' on micropython-v1.20-441-rp2 -""" -# MCU: {'ver': 'v1.20-441', 'build': '441', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.20.0', 'release': '1.20.0', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -# Stubber: 1.5.7 -from typing import Any - -def const(*args, **kwargs) -> Any: - ... - - -class deque(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def append(self, *args, **kwargs) -> Any: - ... - - def popleft(self, *args, **kwargs) -> Any: - ... - - -class GattError(Exception): - ... -def register_irq_handler(*args, **kwargs) -> Any: - ... - -ble : Any ## = - -class DeviceConnection(): - def __init__(self, *argv, **kwargs) -> None: - ... - - disconnect : Any ## = - def timeout(self, *args, **kwargs) -> Any: - ... - - device_task : Any ## = - disconnected : Any ## = - def is_connected(self, *args, **kwargs) -> Any: - ... - - service : Any ## = - def services(self, *args, **kwargs) -> Any: - ... - - pair : Any ## = - exchange_mtu : Any ## = - l2cap_accept : Any ## = - l2cap_connect : Any ## = - -class ClientDiscover(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class ClientService(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def characteristics(self, *args, **kwargs) -> Any: - ... - - characteristic : Any ## = - -class BaseClientCharacteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - read : Any ## = - write : Any ## = - -class ClientCharacteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - read : Any ## = - write : Any ## = - def descriptors(self, *args, **kwargs) -> Any: - ... - - descriptor : Any ## = - notified : Any ## = - indicated : Any ## = - subscribe : Any ## = - -class ClientDescriptor(): - def __init__(self, *argv, **kwargs) -> None: - ... - - read : Any ## = - write : Any ## = diff --git a/stubs/stubs/aioble/core.py b/stubs/stubs/aioble/core.py deleted file mode 100644 index 113c2a8..0000000 --- a/stubs/stubs/aioble/core.py +++ /dev/null @@ -1,32 +0,0 @@ -from typing import Any -from ubluetooth import BLE - -def stop() -> None: - ... - -def config(*args, **kwargs) -> Any: - ... - -def log_info(*args, **kwargs) -> Any: - ... - -def log_warn(*args, **kwargs) -> Any: - ... - -def log_error(*args, **kwargs) -> Any: - ... - - -class GattError(Exception): - ... -def ensure_active(*args, **kwargs) -> Any: - ... - -def register_irq_handler(irq, shutdown) -> None: - ... - -def ble_irq(event, data) -> Any: - ... - -log_level = 1 # type: int -ble: BLE diff --git a/stubs/stubs/aioble/device.py b/stubs/stubs/aioble/device.py deleted file mode 100644 index 22d1f89..0000000 --- a/stubs/stubs/aioble/device.py +++ /dev/null @@ -1,50 +0,0 @@ -from typing import Any - -def const(*args, **kwargs) -> Any: - ... - - -class Device(): - def __init__(self, *argv, **kwargs) -> None: - ... - - connect : Any ## = - def addr_hex(self, *args, **kwargs) -> Any: - ... - - -class DeviceDisconnectedError(Exception): - ... - -def log_error(*args, **kwargs) -> Any: - ... - -def register_irq_handler(*args, **kwargs) -> Any: - ... - -class DeviceTimeout(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class DeviceConnection(): - def __init__(self, *argv, **kwargs) -> None: - ... - - disconnect : Any ## = - def timeout(self, *args, **kwargs) -> Any: - ... - - device_task : Any ## = - disconnected : Any ## = - def is_connected(self, *args, **kwargs) -> Any: - ... - - service : Any ## = - def services(self, *args, **kwargs) -> Any: - ... - - pair : Any ## = - exchange_mtu : Any ## = - l2cap_accept : Any ## = - l2cap_connect : Any ## = diff --git a/stubs/stubs/aioble/l2cap.py b/stubs/stubs/aioble/l2cap.py deleted file mode 100644 index 4aac066..0000000 --- a/stubs/stubs/aioble/l2cap.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -Module: 'aioble.l2cap' on micropython-v1.20-441-rp2 -""" -# MCU: {'ver': 'v1.20-441', 'build': '441', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.20.0', 'release': '1.20.0', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -# Stubber: 1.5.7 -from typing import Any - -def const(*args, **kwargs) -> Any: - ... - -accept : Any ## = -connect : Any ## = -def log_error(*args, **kwargs) -> Any: - ... - -def register_irq_handler(*args, **kwargs) -> Any: - ... - -ble : Any ## = - -class DeviceConnection(): - def __init__(self, *argv, **kwargs) -> None: - ... - - disconnect : Any ## = - def timeout(self, *args, **kwargs) -> Any: - ... - - device_task : Any ## = - disconnected : Any ## = - def is_connected(self, *args, **kwargs) -> Any: - ... - - service : Any ## = - def services(self, *args, **kwargs) -> Any: - ... - - pair : Any ## = - exchange_mtu : Any ## = - l2cap_accept : Any ## = - l2cap_connect : Any ## = - -class L2CAPDisconnectedError(Exception): - ... - -class L2CAPConnectionError(Exception): - ... - -class L2CAPChannel(): - def __init__(self, *argv, **kwargs) -> None: - ... - - send : Any ## = - disconnect : Any ## = - flush : Any ## = - disconnected : Any ## = - recvinto : Any ## = - def available(self, *args, **kwargs) -> Any: - ... - diff --git a/stubs/stubs/aioble/peripheral.py b/stubs/stubs/aioble/peripheral.py deleted file mode 100644 index f9f3568..0000000 --- a/stubs/stubs/aioble/peripheral.py +++ /dev/null @@ -1,63 +0,0 @@ -""" -Module: 'aioble.peripheral' on micropython-v1.20-441-rp2 -""" -# MCU: {'ver': 'v1.20-441', 'build': '441', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.20.0', 'release': '1.20.0', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -# Stubber: 1.5.7 -from typing import Any - -def const(*args, **kwargs) -> Any: - ... - - -class Device(): - def __init__(self, *argv, **kwargs) -> None: - ... - - connect : Any ## = - def addr_hex(self, *args, **kwargs) -> Any: - ... - -def log_info(*args, **kwargs) -> Any: - ... - -def log_warn(*args, **kwargs) -> Any: - ... - -def log_error(*args, **kwargs) -> Any: - ... - -advertise : Any ## = -def ensure_active(*args, **kwargs) -> Any: - ... - -def register_irq_handler(*args, **kwargs) -> Any: - ... - -ble : Any ## = - -class DeviceTimeout(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class DeviceConnection(): - def __init__(self, *argv, **kwargs) -> None: - ... - - disconnect : Any ## = - def timeout(self, *args, **kwargs) -> Any: - ... - - device_task : Any ## = - disconnected : Any ## = - def is_connected(self, *args, **kwargs) -> Any: - ... - - service : Any ## = - def services(self, *args, **kwargs) -> Any: - ... - - pair : Any ## = - exchange_mtu : Any ## = - l2cap_accept : Any ## = - l2cap_connect : Any ## = diff --git a/stubs/stubs/aioble/server.py b/stubs/stubs/aioble/server.py deleted file mode 100644 index b228e52..0000000 --- a/stubs/stubs/aioble/server.py +++ /dev/null @@ -1,143 +0,0 @@ -""" -Module: 'aioble.server' on micropython-v1.20-441-rp2 -""" -# MCU: {'ver': 'v1.20-441', 'build': '441', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.20.0', 'release': '1.20.0', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -# Stubber: 1.5.7 -from typing import Any - -def const(*args, **kwargs) -> Any: - ... - - -class deque(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def append(self, *args, **kwargs) -> Any: - ... - - def popleft(self, *args, **kwargs) -> Any: - ... - -def log_info(*args, **kwargs) -> Any: - ... - -def log_warn(*args, **kwargs) -> Any: - ... - -def log_error(*args, **kwargs) -> Any: - ... - - -class GattError(Exception): - ... - -class Service(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class Characteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - - def notify(self, *args, **kwargs) -> Any: - ... - - indicate : Any ## = - -class BufferedCharacteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - - def notify(self, *args, **kwargs) -> Any: - ... - - indicate : Any ## = - -class Descriptor(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - -def register_services(*args, **kwargs) -> Any: - ... - -def ensure_active(*args, **kwargs) -> Any: - ... - -def register_irq_handler(*args, **kwargs) -> Any: - ... - -ble : Any ## = - -class DeviceTimeout(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class DeviceConnection(): - def __init__(self, *argv, **kwargs) -> None: - ... - - disconnect : Any ## = - def timeout(self, *args, **kwargs) -> Any: - ... - - device_task : Any ## = - disconnected : Any ## = - def is_connected(self, *args, **kwargs) -> Any: - ... - - service : Any ## = - def services(self, *args, **kwargs) -> Any: - ... - - pair : Any ## = - exchange_mtu : Any ## = - l2cap_accept : Any ## = - l2cap_connect : Any ## = - -class BaseCharacteristic(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - written : Any ## = - def on_read(self, *args, **kwargs) -> Any: - ... - diff --git a/stubs/stubs/bluetooth/bluetooth.pyi b/stubs/stubs/bluetooth/bluetooth.pyi deleted file mode 100644 index 0e4ba35..0000000 --- a/stubs/stubs/bluetooth/bluetooth.pyi +++ /dev/null @@ -1 +0,0 @@ -from ubluetooth import * diff --git a/stubs/stubs/dht/dht.pyi b/stubs/stubs/dht/dht.pyi deleted file mode 100644 index fe209dc..0000000 --- a/stubs/stubs/dht/dht.pyi +++ /dev/null @@ -1,48 +0,0 @@ -""" -Module: 'dht' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def dht_readinto(*args, **kwargs) -> Any: - """This function will be redirected by micropython - the the rp2 module containing dht_readinto implementation for rp2 boards. - """ - ... - - -class DHTBase(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def measure(self, *args, **kwargs) -> Any: - ... - - -class DHT11(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def measure(self, *args, **kwargs) -> Any: - ... - - def humidity(self, *args, **kwargs) -> Any: - ... - - def temperature(self, *args, **kwargs) -> Any: - ... - - -class DHT22(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def measure(self, *args, **kwargs) -> Any: - ... - - def humidity(self, *args, **kwargs) -> Any: - ... - - def temperature(self, *args, **kwargs) -> Any: - ... - diff --git a/stubs/stubs/ds18x20/ds18x20.pyi b/stubs/stubs/ds18x20/ds18x20.pyi deleted file mode 100644 index ffdd2d7..0000000 --- a/stubs/stubs/ds18x20/ds18x20.pyi +++ /dev/null @@ -1,54 +0,0 @@ -"""DS18x20 temperature sensor driver -""" - -from onewire import OneWire - -class DS18X20: - def __init__(self, onewire: OneWire) -> None: - ... - - def convert_temp(self) -> float: - """ - Convert the raw temperature data into degrees celsius and return as a fixed point with 2 decimal places. - """ - ... - - def read_scratch(self, rom: bytearray) -> bytearray: - """ - Read the scratchpad memory of the addressed device. 9 bytes of data will be returned - """ - ... - - def read_temp(self, rom: bytearray) -> int: - """ - Get the temperature reading of the addressed device as degree Celsuis. In - case of an CRC error, None is returned. - - Warning: After power up and before a conversion cycle has been performed, - the DS18x20 sensors will return the value 85°C. Since this is also a valid - return value, the calling app must decide, whether it is a reasonable value - in the given context. - """ - ... - - def scan(self) -> list: - """ - Return the list of DS18x2x devices on the bus. Only devices with - rom type 0x10, 0x22 and 0x22 are selected. - """ - ... - - def write_scratch(self, rom: bytearray, buf: bytearray) -> None: - """ - Write to the scratchpad of the addressed devices. data shall be three bytes. - The first two bytes are the high and low alarm temperature. The third by is - the configuration. See the DS18B20 data sheet for details. - """ - ... - - -def const(expr: ...): - """ - See `from micropython import const`. - """ - ... diff --git a/stubs/stubs/framebuf/framebuf.pyi b/stubs/stubs/framebuf/framebuf.pyi deleted file mode 100644 index 8854f79..0000000 --- a/stubs/stubs/framebuf/framebuf.pyi +++ /dev/null @@ -1,142 +0,0 @@ -"""Frame buffer manipulation - -This module provides a general frame buffer which can be used to create -bitmap images, which can then be sent to a display. -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Optional, Any - -class FrameBuffer: - """ - The FrameBuffer class provides a pixel buffer which can be drawn upon with - pixels, lines, rectangles, text and even other FrameBuffer's. It is useful - when generating output for displays. - - For example:: - - import framebuf - - # FrameBuffer needs 2 bytes for every RGB565 pixel - fbuf = FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565) - - fbuf.fill(0) - fbuf.text('MicroPython!', 0, 0, 0xffff) - fbuf.hline(0, 10, 96, 0xffff) - """ - - def __init__(self, buffer: ..., width: int, height: int, format: int, - stride: int = 0) -> None: - """ - Construct a FrameBuffer object. The parameters are: - - - *buffer* is an object with a buffer protocol which must be large - enough to contain every pixel defined by the width, height and - format of the FrameBuffer. - - *width* is the width of the FrameBuffer in pixels - - *height* is the height of the FrameBuffer in pixels - - *format* specifies the type of pixel used in the FrameBuffer; - permissible values are listed under Constants below. These set the - number of bits used to encode a color value and the layout of these - bits in *buffer*. - Where a color value c is passed to a method, c is a small integer - with an encoding that is dependent on the format of the FrameBuffer. - - *stride* is the number of pixels between each horizontal line - of pixels in the FrameBuffer. This defaults to *width* but may - need adjustments when implementing a FrameBuffer within another - larger FrameBuffer or screen. The *buffer* size must accommodate - an increased step size. - - One must specify valid *buffer*, *width*, *height*, *format* and - optionally *stride*. Invalid *buffer* size or dimensions may lead to - unexpected errors. - """ - ... - - def fill(self, c: int) -> None: - """Fill the entire FrameBuffer with the specified color.""" - ... - - def pixel(self, x: int, y: int, c: int=...) -> None: - """Set the specified pixel to the given color.""" - ... - - def hline(self, x: int, y: int, w: int, c: int) -> None: - """ - Draw a horizontal line from a set of coordinates using the given color and - a thickness of 1 pixel. - """ - ... - - def vline(self, x: int, y: int, h: int, c: int) -> None: - """ - Draw a vertical line from a set of coordinates using the given color and - a thickness of 1 pixel. - """ - ... - - def line(self, x1: int, y1: int, x2: int, y2: int, c: int) -> None: - """ - Draw a line from a set of coordinates using the given color and - a thickness of 1 pixel. - """ - ... - - def rect(self, x: int, y: int, w: int, h: int, c: int) -> None: - """Draw a rectangle at the given location, size and color.""" - ... - - def fill_rect(self, x: int, y: int, w: int, h: int, c: int) -> None: - """Fill a rectangle at the given location, size and color.""" - ... - - def text(self, s: str, x: int, y: int, c: int = 1) -> None: - """ - Write text to the FrameBuffer using the the coordinates as the upper-left - corner of the text. The color of the text can be defined by the optional - argument but is otherwise a default value of 1. All characters have - dimensions of 8x8 pixels and there is currently no way to change the font. - """ - ... - - def scroll(self, xstep: int , ystep: int) -> None: - """ - Shift the contents of the FrameBuffer by the given vector. This may - leave a footprint of the previous colors in the FrameBuffer. - """ - ... - - def blit(self, fbuf: FrameBuffer, x: int, y: int, key: Optional[int] = None) -> None: - """ - Draw another FrameBuffer on top of the current one at the given coordinates. - - If *key* is specified then it should be a color integer and the - corresponding color will be considered transparent: all pixels with that - color value will not be drawn. - - This method works between FrameBuffer instances utilising different formats, - but the resulting colors may be unexpected due to the mismatch in color - formats. - """ - ... - - def ellipse(self, *args, **kwargs) -> Any: - ... - - def poly(self, *args, **kwargs) -> Any: - ... - - -def FrameBuffer1(self, buffer: ..., width: int, height: int, stride: int = 0) -> None: - """ - Old FrameBuffer1 class. - """ - ... - -GS2_HMSB = 5 # type: int -GS4_HMSB = 2 # type: int -GS8 = 6 # type: int -MONO_HLSB = 3 # type: int -MONO_HMSB = 4 # type: int -MONO_VLSB = 0 # type: int -MVLSB = 0 # type: int -RGB565 = 1 # type: int diff --git a/stubs/stubs/json/json.pyi b/stubs/stubs/json/json.pyi deleted file mode 100644 index bc3cd3e..0000000 --- a/stubs/stubs/json/json.pyi +++ /dev/null @@ -1 +0,0 @@ -from ujson import * diff --git a/stubs/stubs/lwip/lwip.pyi b/stubs/stubs/lwip/lwip.pyi deleted file mode 100644 index 60226ab..0000000 --- a/stubs/stubs/lwip/lwip.pyi +++ /dev/null @@ -1,91 +0,0 @@ -""" -Module: 'lwip' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} - -from typing import Any - - -AF_INET = 2 # type: int -AF_INET6 = 10 # type: int -IPPROTO_IP = 0 # type: int -IP_ADD_MEMBERSHIP = 1024 # type: int -IP_DROP_MEMBERSHIP = 1025 # type: int -SOCK_DGRAM = 2 # type: int -SOCK_RAW = 3 # type: int -SOCK_STREAM = 1 # type: int -SOL_SOCKET = 1 # type: int -SO_BRODCAST = 32 # type: int -SO_REUSEADDR = 4 # type: int - -def callback() -> Any: - ... - -def getaddrinfo(*args, **kwargs) -> Any: - ... - -def print_pcbs(*args, **kwargs) -> Any: - ... - -def reset(*args, **kwargs) -> Any: - ... - - -class socket(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def readinto(self, *args, **kwargs) -> Any: - ... - - def readline(self, *args, **kwargs) -> Any: - ... - - def send(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - def accept(self, *args, **kwargs) -> Any: - ... - - def bind(self, *args, **kwargs) -> Any: - ... - - def connect(self, *args, **kwargs) -> Any: - ... - - def listen(self, *args, **kwargs) -> Any: - ... - - def makefile(self, *args, **kwargs) -> Any: - ... - - def recv(self, *args, **kwargs) -> Any: - ... - - def recvfrom(self, *args, **kwargs) -> Any: - ... - - def sendall(self, *args, **kwargs) -> Any: - ... - - def sendto(self, *args, **kwargs) -> Any: - ... - - def setblocking(self, *args, **kwargs) -> Any: - ... - - def setsockopt(self, *args, **kwargs) -> Any: - ... - - def settimeout(self, *args, **kwargs) -> Any: - ... - diff --git a/stubs/stubs/machine/machine.pyi b/stubs/stubs/machine/machine.pyi deleted file mode 100644 index 8825688..0000000 --- a/stubs/stubs/machine/machine.pyi +++ /dev/null @@ -1 +0,0 @@ -from umachine import * diff --git a/stubs/stubs/micropython/micropython.pyi b/stubs/stubs/micropython/micropython.pyi deleted file mode 100644 index ee5e4b5..0000000 --- a/stubs/stubs/micropython/micropython.pyi +++ /dev/null @@ -1,154 +0,0 @@ -"""Access and control MicroPython internals.""" - -from collections.abc import Callable -from typing import TypeVar - - -_T = TypeVar('_T') - - -def const(expr: ...) -> ...: - """Used to declare that the expression is a constant so that the compile can - optimise it. The use of this function should be as follows:: - - from micropython import const - - CONST_X = const(123) - CONST_Y = const(2 * CONST_X + 1) - - Constants declared this way are still accessible as global variables from - outside the module they are declared in. On the other hand, if a constant - begins with an underscore then it is hidden, it is not available as a global - variable, and does not take up any memory during execution. - - This `const` function is recognised directly by the MicroPython parser and is - provided as part of the :mod:`micropython` module mainly so that scripts can be - written which run under both CPython and MicroPython, by following the above - pattern. - """ - ... - - -def opt_level(level: int=...) -> int: - """If *level* is given then this function sets the optimisation level for subsequent - compilation of scripts, and returns ``None``. Otherwise it returns the current - optimisation level. - """ - ... - - -def alloc_emergency_exception_buf(size: int) -> None: - """Allocate *size* bytes of RAM for the emergency exception buffer (a good - size is around 100 bytes). The buffer is used to create exceptions in cases - when normal RAM allocation would fail (eg within an interrupt handler) and - therefore give useful traceback information in these situations. - - A good way to use this function is to put it at the start of your main script - (eg ``boot.py`` or ``main.py``) and then the emergency exception buffer will be active - for all the code following it. - """ - ... - - -def mem_info(verbose: ...=...) -> None: - """Print information about currently used memory. If the *verbose* argument - is given then extra information is printed. - - The information that is printed is implementation dependent, but currently - includes the amount of stack and heap used. In verbose mode it prints out - the entire heap indicating which blocks are used and which are free. - """ - ... - - -def qstr_info(verbose=...) -> None: - """Print information about currently interned strings. If the *verbose* - argument is given then extra information is printed. - - The information that is printed is implementation dependent, but currently - includes the number of interned strings and the amount of RAM they use. In - verbose mode it prints out the names of all RAM-interned strings. - """ - ... - - -def stack_use() -> int: - """Return an integer representing the current amount of stack that is being - used. The absolute value of this is not particularly useful, rather it - should be used to compute differences in stack usage at different points. - """ - ... - - -def heap_lock() -> None: - """Lock the heap. When locked no memory allocation can occur and a - `MemoryError` will be raised if any heap allocation is attempted. - - These functions can be nested, ie `heap_lock()` can be called multiple times - in a row and the lock-depth will increase, and then `heap_unlock()` must be - called the same number of times to make the heap available again. - """ - ... - - - -def heap_unlock() -> None: - """Unlock the heap. When locked no memory allocation can occur and a - `MemoryError` will be raised if any heap allocation is attempted. - - These functions can be nested, ie `heap_lock()` can be called multiple times - in a row and the lock-depth will increase, and then `heap_unlock()` must be - called the same number of times to make the heap available again. - """ - ... - - - -def kbd_intr(chr: int) -> None: - """Set the character that will raise a `KeyboardInterrupt` exception. By - default this is set to 3 during script execution, corresponding to Ctrl-C. - Passing -1 to this function will disable capture of Ctrl-C, and passing 3 - will restore it. - - This function can be used to prevent the capturing of Ctrl-C on the - incoming stream of characters that is usually used for the REPL, in case - that stream is used for other purposes. - """ - ... - - -def schedule(func: Callable[[_T], ...], arg: _T) -> None: - """Schedule the function *func* to be executed "very soon". The function - is passed the value *arg* as its single argument. "Very soon" means that - the MicroPython runtime will do its best to execute the function at the - earliest possible time, given that it is also trying to be efficient, and - that the following conditions hold: - - - A scheduled function will never preempt another scheduled function. - - Scheduled functions are always executed "between opcodes" which means - that all fundamental Python operations (such as appending to a list) - are guaranteed to be atomic. - - A given port may define "critical regions" within which scheduled - functions will never be executed. Functions may be scheduled within - a critical region but they will not be executed until that region - is exited. An example of a critical region is a preempting interrupt - handler (an IRQ). - - A use for this function is to schedule a callback from a preempting IRQ. - Such an IRQ puts restrictions on the code that runs in the IRQ (for example - the heap may be locked) and scheduling a function to call later will lift - those restrictions. - - Note: If `schedule()` is called from a preempting IRQ, when memory - allocation is not allowed and the callback to be passed to `schedule()` is - a bound method, passing this directly will fail. This is because creating a - reference to a bound method causes memory allocation. A solution is to - create a reference to the method in the class constructor and to pass that - reference to `schedule()`. This is discussed in detail here - :ref:`reference documentation ` under "Creation of Python - objects". - - There is a finite stack to hold the scheduled functions and `schedule()` - will raise a `RuntimeError` if the stack is full. - """ - ... diff --git a/stubs/stubs/neopixel/neopixel.pyi b/stubs/stubs/neopixel/neopixel.pyi deleted file mode 100644 index 1366b96..0000000 --- a/stubs/stubs/neopixel/neopixel.pyi +++ /dev/null @@ -1,47 +0,0 @@ -""" -Module: 'neopixel' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any -from machine import Pin - -def bitstream(*args, **kwargs) -> Any: - ... - - -class NeoPixel(): - def __init__(self, pin: Pin, n: int, *, bpp: int=3, timing=1) -> None: - """Construct an NeoPixel object. The parameters are: - - ``pin`` is a machine.Pin instance. - - ``n`` is the number of LEDs in the strip. - - ``bpp`` is 3 for RGB LEDs, and 4 for RGBW LEDs. - - ``timing`` is 0 for 400KHz, and 1 for 800kHz LEDs (most are 800kHz). - """ - ... - - def write(self) -> Any: - """Writes the current pixel data to the strip.""" - ... - - def fill(self, pixel) -> Any: - """Sets the value of all pixels to the - specified pixel value (i.e. an RGB/RGBW tuple).""" - ... - - ORDER = () # type: tuple - - def __len__(self) -> int: - """Returns the number of LEDs in the strip.""" - ... - - def __setitem__(self, index, val) -> Any: - """Set the pixel at index to the value, which is an RGB/RGBW tuple.""" - ... - - def __getitem__(self, index) -> Any: - """Returns the pixel at index as an RGB/RGBW tuple.""" - ... diff --git a/stubs/stubs/network/network.pyi b/stubs/stubs/network/network.pyi deleted file mode 100644 index f3f06b7..0000000 --- a/stubs/stubs/network/network.pyi +++ /dev/null @@ -1,201 +0,0 @@ -""" -Module: 'network' on micropython-v1.19.1-rp2 -""" -from typing import Union, Optional - -AP_IF: int = 1 # type: int -STAT_CONNECTING: int = 1 # type: int -STAT_CONNECT_FAIL: int = -1 # type: int -STAT_GOT_IP: int = 3 # type: int -STAT_IDLE: int = 0 # type: int -STAT_NO_AP_FOUND: int = -2 # type: int -STAT_WRONG_PASSWORD: int = -3 # type: int -STA_IF: int = 0 # type: int - -class WLAN(): - def __init__(self, interface_id: int): - """Create a WLAN network interface object. Supported interfaces - are ``network.STA_IF`` (station aka client, connects to upstream WiFi - access points) and ``network.AP_IF`` (access point, allows other WiFi - clients to connect). Availability of the methods below depends on - interface type. For example, only STA interface may ``WLAN.connect()`` - to an access point. - """ - ... - - PM_NONE = 16 # type: int - PM_PERFORMANCE = 10555714 # type: int - PM_POWERSAVE = 17 # type: int - def active(self, is_active: bool=...) -> bool: - """Activate (“up”) or deactivate (“down”) network interface, if boolean - argument is passed. Otherwise, query current state if no argument is provided. - Most other methods require active interface. - """ - ... - - def config(self, parameter:str="config('ssid') for example", mac: Optional[bytes] = None, essid: Optional[str] =None, ssid: Optional[str]=None, channel: Optional[int] =None, security: Optional[int]=None, key: Optional[str]=None, password: Optional[str]=None, txpower: Optional[Union[int, float]] =None) -> None: - """DOT NOT USE config(paramter=...) this is just for config('...') to work - - Get or set general network interface parameters. - These methods allow to work with additional parameters - beyond standard IP configuration (as dealt with by - ``WLAN.ifconfig()``). These include network-specific and - hardware-specific parameters. For setting parameters, - keyword argument syntax should be used, multiple - parameters can be set at once. For querying, - parameters name should be quoted as a string, - and only one parameter can be queries at time: - - Set WiFi access point name (formally known as SSID) and WiFi channel:: - - ap.config(ssid='My AP', channel=11) - - Query params one by one:: - - print(ap.config('ssid')) ; print(ap.config('channel')) - Following are commonly supported parameters (availability of a specific parameter depends on network technology type, driver, and MicroPython port). - - Parameter | Description - - mac | MAC address (bytes) - - essid/ssid | WiFi access point name (string) - - channel | WiFi channel (integer) - - security | Security protocol supported (enumeration, see module constants) - - key / password | Access key (string) - - txpower | Maximum transmit power in dBm (integer or float) - """ - ... - - def connect(self, ssid: Optional[str] = None, key: Optional[str] = None, *, bssid: ...=None) -> ...: - """Connect to the specified wireless network, using the specified key. - If bssid is given then the connection will be restricted to the access-point - with that MAC address (the ssid must also be specified in this case). - """ - ... - - def deinit(self, *args, **kwargs) -> ...: - ... - - def disconnect(self) -> None: - """Disconnect from the currently connected wireless network.""" - ... - - def ifconfig(self, arg: tuple[str, str, str, str]=...) -> tuple[str, str, str, str]: - """Get/set IP-level network interface parameters: - IP address, subnet mask, gateway and DNS server. - When called with no arguments, this method returns - a 4-tuple with the above information. To set the - above values, pass a 4-tuple with the required - information. For example:: - - nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '1.1.1.1')) - """ - ... - - def ioctl(self, *args, **kwargs) -> ...: - ... - - def isconnected(self) -> bool: - """In case of STA mode, returns ``True`` if connected to a - WiFi access point and has a valid IP address. In AP mode - returns ``True`` when a station is connected. Returns ``False`` - otherwise. - """ - ... - - def scan(self) -> list[tuple[bytes, bytes, int, int, int, int]]: - """Scan for the available wireless networks. Hidden networks – where the SSID is - not broadcast – will also be scanned if the WLAN interface allows it. - - Scanning is only possible on STA interface. Returns list of tuples with the - information about WiFi access points: - - (ssid, bssid, channel, RSSI, security, hidden) - - bssid is hardware address of an access point, in binary form, returned as bytes - object. You can use binascii.hexlify() to convert it to ASCII form. - - There are five values for security: - - 0 – open - - 1 – WEP - - 2 – WPA-PSK - - 3 – WPA2-PSK - - 4 – WPA/WPA2-PSK - - and two for hidden: - - 0 – visible - - 1 – hidden - """ - ... - - def send_ethernet(self, *args, **kwargs) -> ...: - ... - - def status(self, param: str=...) -> int: - """Return the current status of the wireless connection. - -When called with no argument the return value describes the network link status. -The possible statuses are defined as constants: - -``STAT_IDLE`` – no connection and no activity, - -``STAT_CONNECTING`` – connecting in progress, - -``STAT_WRONG_PASSWORD`` – failed due to incorrect password, - -``STAT_NO_AP_FOUND`` – failed because no access point replied, - -``STAT_CONNECT_FAIL`` – failed due to other problems, - -``STAT_GOT_IP`` – connection successful. - -When called with one argument param should be a string naming the status -parameter to retrieve. Supported parameters in WiFI STA mode are: ``'rssi'``. - """ - ... - -def country(code: str = "") -> str: - """ - Get or set the two-letter ISO 3166-1 Alpha-2 country code to be used for radio compliance. - - If the code parameter is provided, the country will be set to this value. If the function is called without parameters, it returns the current country. - - The default code `XX` represents the “worldwide” region. - """ - ... - -def hostname(name: str = "") -> str: - """ - Get or set the hostname that will identify this - device on the network. It is applied to all - interfaces. - - This hostname is used for: - - Sending to the DHCP server in the client - request. (If using DHCP) - - - Broadcasting via mDNS. (If enabled) - - If the name parameter is provided, the hostname - will be set to this value. If the function is - called without parameters, it returns the - current hostname. - - The default hostname is typically the name of the board. - """ - ... - -def route() -> list: - ... diff --git a/stubs/stubs/ntptime/ntptime.pyi b/stubs/stubs/ntptime/ntptime.pyi deleted file mode 100644 index 63326cf..0000000 --- a/stubs/stubs/ntptime/ntptime.pyi +++ /dev/null @@ -1,20 +0,0 @@ -""" -Module: 'ntptime' -""" - -def time() -> int: - """Retrieve time from NTP server and return it expressed in seconds since the Epoch.""" - ... - -timeout = 1 # type: int -host = 'pool.ntp.org' # type: str -"""host constant set as default on micropython raspberry pi pico w firmware""" - -def settime() -> None: - """Get time from ``ntptime.time()`` and parse it into ``machine.RTC().datetime()`` module. - - NOTE: There is currently not timezone support in MicroPython, - and the RTC is set in UTC time. - """ - ... - diff --git a/stubs/stubs/onewire/onewire.pyi b/stubs/stubs/onewire/onewire.pyi deleted file mode 100644 index 8acf87b..0000000 --- a/stubs/stubs/onewire/onewire.pyi +++ /dev/null @@ -1,64 +0,0 @@ -from machine import Pin -from collections.abc import Sequence -from typing import Union - -class OneWire: - """ - OneWire library for MicroPython - """ - MATCH_ROM = 85 - SEARCH_ROM = 240 - SKIP_ROM = 204 - - def __init__(self, pin : Pin): - ... - - def _search_rom(self, l_rom: bytearray, diff: int) -> tuple[bytearray, int]: - ... - - def crc8(self, data:bytearray) -> int: - """ - Compute CRC - """ - ... - - def readbit(self) -> int: - ... - - def readbyte(self) -> int: - ... - - def readinto(self, buf: bytearray): - ... - - def reset(self, required:bool = False) -> Union[bool, int]: - """ - Perform the onewire reset function. - """ - ... - - def scan(self) -> Sequence[bytearray]: - """ - Return a list of ROMs for all attached devices. - Each ROM is returned as a bytes object of 8 bytes. - """ - ... - - def select_rom(self, rom:bytearray): - """ - Select a specific device to talk to. Pass in rom as a bytearray (8 bytes). - """ - ... - - def write(self, buf: Union[bytearray, str]): - ... - - def writebit(self, value:int) -> None: - ... - - def writebyte(self, value:int) -> None: - ... - - -class OneWireError(Exception): - ... diff --git a/stubs/stubs/requests/requests.pyi b/stubs/stubs/requests/requests.pyi deleted file mode 100644 index bc62418..0000000 --- a/stubs/stubs/requests/requests.pyi +++ /dev/null @@ -1 +0,0 @@ -from urequests import * diff --git a/stubs/stubs/rp2/rp2.pyi b/stubs/stubs/rp2/rp2.pyi deleted file mode 100644 index b941f95..0000000 --- a/stubs/stubs/rp2/rp2.pyi +++ /dev/null @@ -1,467 +0,0 @@ -from uarray import array -from machine import Pin -from typing import Any, overload, Union, Optional - -class Flash: - # Determined from: https://github.com/raspberrypi/micropython/blob/1196871a0f2f974b03915e08cfcc0433de4b8a64/ports/rp2/rp2_flash.c - # Documentation put together via research and may be flawed! And also from micropython docs rp2.Flash.html - """ - Flash storage functionality. - """ - - CMD_INIT = 1 - CMD_DEINIT = 2 - CMD_SYNC = 3 - CMD_BLOCK_COUNT = 4 - CMD_BLOCK_SIZE = 5 - CMD_BLOCK_ERASE = 6 - - # offsetBlocks: int = None changed to arg: Any - def ioctl(self, cmd: int, arg: Any): - """ - Send a command to the Flash storage controller. - """ - ... - - def readblocks(self, offsetBlocks: int, buffer: bytearray, offset: Optional[Union[int, Any]]=None): - """ - Read data from the Flash storage. - """ - ... - - def writeblocks(self, offsetBlocks: int, buffer: bytearray, offset: Optional[Union[int, Any]]=None): - """ - Write data to the Flash storage. - """ - ... - -class PIO: - # Determined from: https://github.com/raspberrypi/micropython/blob/1196871a0f2f974b03915e08cfcc0433de4b8a64/ports/rp2/rp2_pio.c - # Documentation put together via research and may be flawed! - """ - Programmable I/O (PIO) functionality. - - The Pico has two PIO blocks that each have four state machines. - These are really stripped-down processing cores that can be used - to handle data coming in or out of the microcontroller, and - offload some of the processing requirement for implementing - communications protocols. - """ - - IN_HIGH = 1 # type: int - IN_LOW = 0 # type: int - IRQ_SM0 = 256 # type: int - IRQ_SM1 = 512 # type: int - IRQ_SM2 = 1024 # type: int - IRQ_SM3 = 2048 # type: int - JOIN_NONE = 0 # type: int - JOIN_RX = 2 # type: int - JOIN_TX = 1 # type: int - OUT_HIGH = 3 # type: int - OUT_LOW = 2 # type: int - SHIFT_LEFT = 0 # type: int - SHIFT_RIGHT = 1 # type: int - - def __init__(self, id: int) -> None: - """Gets the PIO instance numbered id. The - RP2040 has two PIO instances, numbered 0 and 1. - - Raises a ``ValueError`` if any other argument is provided.""" - ... - - def add_program(self, program): - """ - Add the program to the instruction memory of this PIO instance. - - The amount of memory available for programs on each PIO instance - is limited. If there isn't enough space left in the PIO's program - memory this method will raise ``OSError(ENOMEM)``. - """ - ... - - def irq(self, handler=None, trigger= IRQ_SM0 | IRQ_SM1 | IRQ_SM2 | IRQ_SM3, hard=False): - """ - Returns the IRQ object for this PIO instance. - - MicroPython only uses IRQ 0 on each PIO instance. IRQ 1 is not available. - - Optionally configure it. - """ - ... - - def remove_program(self, prog = None): - """ - Remove program from the instruction memory of this PIO instance. - - If no program is provided, it removes all programs. - - It is not an error to remove a program which has already been removed. - """ - ... - - def state_machine(self, id: int, program: Optional[Any] = None, freq: Optional[int]=-1, *args, **kwargs) -> StateMachine: - """ - Returns the StateMachine object. - - Gets the state machine numbered id. - On the RP2040, each PIO instance has - four state machines, numbered 0 to 3. - """ - ... - -class PIOASMError(Exception): - ... - -class PIOASMEmit: - def __init__(self) -> None: - ... - - def start_pass(self, pass_: Any) -> None: - ... - - def __getitem__(self, key: Any) -> Any: - ... - - def delay(self, value: int) -> Any: - """This is a modifier which can be applied to any - instruction, and specifies how many cycles to delay - for after the instruction executes. - - - *value*: cycles to delay, 0-31 (maximum value reduced - if side-set pins are used) - """ - ... - - def side(self, value: Any) -> Any: - """This is a modifier which can be applied to any instruction, - and is used to control side-set pin values. - - - *value*: the value (bits) to output on the side-set pins - """ - ... - - def wrap_target(self) -> None: - """Specify the location where execution - continues after program wrapping. By - default this is the start of the PIO routine. - """ - ... - - def wrap(self) -> None: - """Specify the location where the program finishes - and wraps around. If this directive is not used then - it is added automatically at the end of the PIO routine. - Wrapping does not cost any execution cycles. - """ - ... - - def label(self, label: Any) -> None: - """Define a label called label at the current location. - label can be a string or integer. - """ - ... - - def word(self, instr: Any, label: Any=None) -> Any: - """Insert an arbitrary 16-bit word in the assembled - output. - - *instr*: the 16-bit value - - *label*: if given, look up the label and logical-or - the label's value with *instr* - """ - ... - - def nop(self) -> Any: - """This is a pseudoinstruction that assembles - to ``mov(y, y)`` and has no side effect. - """ - ... - - def jmp(self, cond: Any, label: Any=None) -> Any: - """This instruction takes two forms: - jmp(label) - - label: label to jump to unconditionally - - jmp(cond, label) - - *cond*: the condition to check, one of: - - ``not_x``, ``not_y``: true if register is zero - - ``x_dec``, ``y_dec``: true if register is non-zero, and do post decrement - - ``x_not_y``: true if X is not equal to Y - - ``pin``: true if the input pin is set - - ``not_osre``: true if OSR is not empty (hasn't reached its threshold) - - - *label*: label to jump to if condition is true - """ - ... - - def wait(self, polarity: int, src: Any, index: int) -> Any: - """Block, waiting for high/low on a pin or IRQ line. - - - *polarity*: 0 or 1, whether to wait for a low or high value - - - *src*: one of: gpio (absolute pin), pin (pin relative to StateMachine's in_base argument), irq - - - *index*: 0-31, the index for src""" - ... - - def in_(self, src: Any, data: Any) -> Any: - """Shift data in from src to ISR. - - - *src*: one of: ``pins``, ``x``, ``y``, ``null``, ``isr``, ``osr`` - - *bit_count*: number of bits to shift in (1-32)""" - ... - - def out(self, dest: Any, bit_count: int) -> Any: - """Shift data out from OSR to dest. - - - *dest*: one of: ``pins``, ``x``, ``y``, ``pindirs``, ``pc``, ``isr``, ``exec`` - - *bit_count*: number of bits to shift out (1-32)""" - ... - - def push(self, value: Any=0, value2: Any=0) -> Any: - """Push ISR to the RX FIFO, then clear ISR to zero. - This instruction takes the following forms: - - - push() - - push(block) - - push(noblock) - - push(iffull) - - push(iffull, block) - - push(iffull, noblock) - - If ``block`` is used then the instruction stalls if the - RX FIFO is full. The default is to block. If ``iffull`` - is used then it only pushes if the input shift count - has reached its threshold. - """ - ... - - def pull(self, value: Any=0, value2: Any=0) -> Any: - """Pull from the TX FIFO into OSR. This instruction - takes the following forms: - - - pull() - - pull(block) - - pull(noblock) - - pull(ifempty) - - pull(ifempty, block) - - pull(ifempty, noblock) - - If ``block`` is used then the instruction stalls if the - TX FIFO is empty. The default is to block. If ``ifempty`` - is used then it only pulls if the output shift count - has reached its threshold. - """ - ... - - def mov(self, dest: Any, src: Any) -> Any: - """Move into dest the value from src. - - - *dest*: one of: pins, ``x``, ``y``, ``exec``, ``pc``, ``isr``, ``osr`` - - *src*: one of: ``pins``, ``x``, ``y``, ``null``, ``status``, ``isr``, ``osr`` - ; this argument can be optionally modified by wrapping it in ``invert()`` - or ``reverse()`` (but not both together) - """ - ... - - @overload - def irq(self, mode: str, index: Any) -> Any: - ... - - @overload - def irq(self, index: Any) -> Any: - """Set or clear an IRQ flag. This instruction - takes two forms: - - irq(index) - - index: 0-7, or rel(0) to rel(7) - - irq(mode, index) - - mode: one of: block, clear - - index: 0-7, or rel(0) to rel(7) - - If block is used then the instruction stalls - until the flag is cleared by another entity. - If clear is used then the flag is cleared - instead of being set. Relative IRQ indices - add the state machine ID to the IRQ index with - modulo-4 addition. IRQs 0-3 are visible from to - the processor, 4-7 are internal to the state - machines. - """ - ... - - def set(self, dest: Any, data: int) -> Any: - """Set dest with the value data. - - - dest: ``pins, ``x``, ``y``, ``pindirs`` - - data: value (0-31) - """ - ... - - -class StateMachine: - # Determined from: https://github.com/raspberrypi/micropython/blob/1196871a0f2f974b03915e08cfcc0433de4b8a64/ports/rp2/rp2_pio.c - # Documentation put together via research and may be flawed! - def __init__(self, id, prog, freq: int=-1, *, in_base: Optional[Pin] =None, out_base: Optional[Pin] =None, set_base: Optional[Pin] =None, jmp_pin: Optional[Pin] =None, sideset_base: Optional[Pin] =None, in_shiftdir: Optional[int] =None, out_shiftdir: Optional[int] =None, push_thresh: Optional[int] =None, pull_thresh: Optional[int] =None): - """ - Create a new StateMachine containing two First-In-First-Out (FIFO) - structures: one for incoming data and another for outgoing data. - - The input FIFO is known as the RX FIFO and the output FIFO is known - as the TX FIFO. - - Each FIFO can contain up to four words of data (each 32 bits) and can - be linked to Direct Memory Access (DMA). - - The FIFO structures are linked to the state machine via the input and - output shift registers called X and Y. These are for storing temporary - data. - - A Pico board has 8 available state machines. - - - *id* should be a number between 0 and 7 (the Pico has 8 machines). - - *prog* is the assembly code to execute (decorated by ``@asm_pio``). - - *freq* is the frequency at which the code should be executed (in milliseconds). - """ - ... - - def init(self, id, prog, freq: int=-1, *, in_base: Optional[Pin]=None, out_base: Optional[Pin]=None, set_base: Optional[Pin]=None, jmp_pin: Optional[Pin]=None, sideset_base: Optional[Pin]=None, in_shiftdir: Optional[int]=None, out_shiftdir: Optional[int]=None, push_thresh: Optional[int]=None, pull_thresh: Optional[int]=None): - """ - Create a new StateMachine containing two First-In-First-Out (FIFO) - structures: one for incoming data and another for outgoing data. - - The input FIFO is known as the RX FIFO and the output FIFO is known - as the TX FIFO. - - Each FIFO can contain up to four words of data (each 32 bits) and can - be linked to Direct Memory Access (DMA). - - The FIFO structures are linked to the state machine via the input and - output shift registers called X and Y. These are for storing temporary - data. - - A Pico board has 8 available state machines. - - - *id* should be a number between 0 and 7 (the Pico has 8 machines). - - *prog* is the assembly code to execute (decorated by ``@asm_pio``). - - *freq* is the frequency at which the code should be executed (in milliseconds). - """ - ... - - def exec(self, instr: str): - """ - Run an execution instruction. - """ - ... - - def irq(self, handler=None, trigger=0|1, hard=False): - """ - Set an IRQ handler. - """ - ... - - def active(self, value: int): - """ - Set the ``StateMachine`` to be active. - - - *value* should be 1 for active. - """ - ... - - def get(self, buf: Optional[bytes]=None, shift: int=0): - """ - Get data from the ``StateMachine``. - - - *buf* are optional bytes - - *shift* is an optional number of places to shift. - """ - ... - - def put(self, value: Union[bytes, int, array[int]], shift: int=0): - """ - Sets data within the ``StateMachine``. - - - *buf* are optional bytes - - *shift* is an optional number of places to shift. - """ - ... - - def restart(self): - """ - ``Restarts`` the state machine. - - - it resets the statemachine to the initial state without the need to re-instantiation. - - It also makes PIO code easier, because then stalling as error state can be unlocked. - """ - ... - - def rx_fifo(self) -> int: - """ - Return the number of ``RX FIFO`` items. 0 if empty - - - rx_fifo() is also useful, for MP code to check for data & timeout if no data arrived. - """ - ... - - def tx_fifo(self) -> int: - """ - Return the number of ``TX FIFO`` items. 0 if empty - - - tx_fifo() can be useful to check states where data is not processed. - """ - ... - -def asm_pio( - out_init: Optional[int] = None, - set_init: Optional[int] = None, - sideset_init: Optional[int] = None, - in_shiftdir: int = 0, - out_shiftdir: int = 0, - autopush: bool = False, - autopull: bool = False, - push_thresh: int = 32, - pull_thresh: int = 32, - fifo_join=0, -) -> Any: - """ - This decorator lets MicroPython know that the method is written in PIO assembly. - - You should disable linting since the content isn't written in Python. - - In Pylance, move any assembly code into a separate file and ensure the first - line of that file reads: ``# type: ignore``. - - In Pylint, add a comment that reads ``# pylint: disable=E,W,C,R`` at the beginning of - the method. - """ - ... - - -def asm_pio_encode(instr: str, sideset_count: int, sideset_opt=False) -> Any: - """Assemble a single PIO instruction. You usually want to use ``asm_pio()`` instead.""" - ... - -def bootsel_button() -> int: - """ - Temporarily turns the QSPI_SS pin into an input and reads its value, returning 1 for - low and 0 for high. On a typical RP2040 board with a BOOTSEL button, a return value - of 1 indicates that the button is pressed. - - Since this function temporarily disables access to the external flash memory, it - also temporarily disables interrupts and the other core to prevent them from trying - to execute code from flash. - """ - ... - -def const(value: Any) -> Any: - ... - -def country(*args, **kwargs) -> Any: - ... diff --git a/stubs/stubs/typing_extensions/typing_extensions.pyi b/stubs/stubs/typing_extensions/typing_extensions.pyi deleted file mode 100644 index fb2272c..0000000 --- a/stubs/stubs/typing_extensions/typing_extensions.pyi +++ /dev/null @@ -1,273 +0,0 @@ -# This file is from https://github.com/python/typeshed as of commit sha b6d28acb2368cdd8c87554e01e22e134061997d6 -# Copyright github.com/python/typeshed project contributors - -import _typeshed -import abc -import collections -import sys -from _collections_abc import dict_items, dict_keys, dict_values -from _typeshed import IdentityFunction -from collections.abc import Iterable -from typing import ( # noqa: Y022,Y027,Y039 - TYPE_CHECKING as TYPE_CHECKING, - Any, - AsyncContextManager as AsyncContextManager, - AsyncGenerator as AsyncGenerator, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - Callable, - ChainMap as ChainMap, - ClassVar as ClassVar, - ContextManager as ContextManager, - Coroutine as Coroutine, - Counter as Counter, - DefaultDict as DefaultDict, - Deque as Deque, - Mapping, - NewType as NewType, - NoReturn as NoReturn, - Sequence, - Text as Text, - Type as Type, - TypeVar, - _Alias, - overload as overload, - type_check_only, -) - -__all__ = [ - "ClassVar", - "Concatenate", - "Final", - "LiteralString", - "ParamSpec", - "ParamSpecArgs", - "ParamSpecKwargs", - "Self", - "Type", - "TypeVarTuple", - "Unpack", - "Awaitable", - "AsyncIterator", - "AsyncIterable", - "Coroutine", - "AsyncGenerator", - "AsyncContextManager", - "ChainMap", - "ContextManager", - "Counter", - "Deque", - "DefaultDict", - "NamedTuple", - "OrderedDict", - "TypedDict", - "SupportsIndex", - "Annotated", - "assert_never", - "assert_type", - "dataclass_transform", - "final", - "IntVar", - "is_typeddict", - "Literal", - "NewType", - "overload", - "Protocol", - "reveal_type", - "runtime", - "runtime_checkable", - "Text", - "TypeAlias", - "TypeGuard", - "TYPE_CHECKING", - "Never", - "NoReturn", - "Required", - "NotRequired", - "clear_overloads", - "get_args", - "get_origin", - "get_overloads", - "get_type_hints", -] - -_T = TypeVar("_T") -_F = TypeVar("_F", bound=Callable[..., Any]) -_TC = TypeVar("_TC", bound=Type[object]) - -# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype -class _SpecialForm: - def __getitem__(self, parameters: Any) -> object: ... - if sys.version_info >= (3, 10): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... - -# Do not import (and re-export) Protocol or runtime_checkable from -# typing module because type checkers need to be able to distinguish -# typing.Protocol and typing_extensions.Protocol so they can properly -# warn users about potential runtime exceptions when using typing.Protocol -# on older versions of Python. -Protocol: _SpecialForm = ... - -def runtime_checkable(cls: _TC) -> _TC: ... - -# This alias for above is kept here for backwards compatibility. -runtime = runtime_checkable -Final: _SpecialForm - -def final(f: _F) -> _F: ... - -Literal: _SpecialForm - -def IntVar(name: str) -> Any: ... # returns a new TypeVar - -# Internal mypy fallback type for all typed dicts (does not exist at runtime) -# N.B. Keep this mostly in sync with typing._TypedDict/mypy_extensions._TypedDict -@type_check_only -class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): - __required_keys__: ClassVar[frozenset[str]] - __optional_keys__: ClassVar[frozenset[str]] - __total__: ClassVar[bool] - def copy(self: _typeshed.Self) -> _typeshed.Self: ... - # Using Never so that only calls using mypy plugin hook that specialize the signature - # can go through. - def setdefault(self, k: Never, default: object) -> object: ... - # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. - def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse] - def update(self: _T, __m: _T) -> None: ... - def items(self) -> dict_items[str, object]: ... - def keys(self) -> dict_keys[str, object]: ... - def values(self) -> dict_values[str, object]: ... - def __delitem__(self, k: Never) -> None: ... - if sys.version_info >= (3, 9): - def __or__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ... - def __ior__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ... - -# TypedDict is a (non-subscriptable) special form. -TypedDict: object - -OrderedDict = _Alias() - -def get_type_hints( - obj: Callable[..., Any], - globalns: dict[str, Any] | None = ..., - localns: dict[str, Any] | None = ..., - include_extras: bool = ..., -) -> dict[str, Any]: ... -def get_args(tp: Any) -> tuple[Any, ...]: ... -def get_origin(tp: Any) -> Any | None: ... - -Annotated: _SpecialForm -_AnnotatedAlias: Any # undocumented - -@runtime_checkable -class SupportsIndex(Protocol, metaclass=abc.ABCMeta): - @abc.abstractmethod - def __index__(self) -> int: ... - -# New things in 3.10 -if sys.version_info >= (3, 10): - from typing import ( - Concatenate as Concatenate, - ParamSpec as ParamSpec, - ParamSpecArgs as ParamSpecArgs, - ParamSpecKwargs as ParamSpecKwargs, - TypeAlias as TypeAlias, - TypeGuard as TypeGuard, - is_typeddict as is_typeddict, - ) -else: - class ParamSpecArgs: - __origin__: ParamSpec - def __init__(self, origin: ParamSpec) -> None: ... - - class ParamSpecKwargs: - __origin__: ParamSpec - def __init__(self, origin: ParamSpec) -> None: ... - - class ParamSpec: - __name__: str - __bound__: type[Any] | None - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *, bound: None | type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... - ) -> None: ... - @property - def args(self) -> ParamSpecArgs: ... - @property - def kwargs(self) -> ParamSpecKwargs: ... - Concatenate: _SpecialForm - TypeAlias: _SpecialForm - TypeGuard: _SpecialForm - def is_typeddict(tp: object) -> bool: ... - -# New things in 3.11 -# NamedTuples are not new, but the ability to create generic NamedTuples is new in 3.11 -if sys.version_info >= (3, 11): - from typing import ( - LiteralString as LiteralString, - NamedTuple as NamedTuple, - Never as Never, - NotRequired as NotRequired, - Required as Required, - Self as Self, - TypeVarTuple as TypeVarTuple, - Unpack as Unpack, - assert_never as assert_never, - assert_type as assert_type, - clear_overloads as clear_overloads, - dataclass_transform as dataclass_transform, - get_overloads as get_overloads, - reveal_type as reveal_type, - ) -else: - Self: _SpecialForm - Never: _SpecialForm = ... - def reveal_type(__obj: _T) -> _T: ... - def assert_never(__arg: Never) -> Never: ... - def assert_type(__val: _T, __typ: Any) -> _T: ... - def clear_overloads() -> None: ... - def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ... - - Required: _SpecialForm - NotRequired: _SpecialForm - LiteralString: _SpecialForm - Unpack: _SpecialForm - - @final - class TypeVarTuple: - __name__: str - def __init__(self, name: str) -> None: ... - def __iter__(self) -> Any: ... # Unpack[Self] - - def dataclass_transform( - *, - eq_default: bool = ..., - order_default: bool = ..., - kw_only_default: bool = ..., - field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ..., - **kwargs: object, - ) -> IdentityFunction: ... - - class NamedTuple(tuple[Any, ...]): - if sys.version_info < (3, 8): - _field_types: collections.OrderedDict[str, type] - elif sys.version_info < (3, 9): - _field_types: dict[str, type] - _field_defaults: dict[str, Any] - _fields: tuple[str, ...] - _source: str - @overload - def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ... - @overload - def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ... - @classmethod - def _make(cls: type[_typeshed.Self], iterable: Iterable[Any]) -> _typeshed.Self: ... - if sys.version_info >= (3, 8): - def _asdict(self) -> dict[str, Any]: ... - else: - def _asdict(self) -> collections.OrderedDict[str, Any]: ... - - def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ... diff --git a/stubs/stubs/uasyncio/__init__.pyi b/stubs/stubs/uasyncio/__init__.pyi deleted file mode 100644 index c823fc3..0000000 --- a/stubs/stubs/uasyncio/__init__.pyi +++ /dev/null @@ -1,215 +0,0 @@ -""" -Module: 'uasyncio.__init__' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - - -class CancelledError(Exception): - ... - -class Task(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class TaskQueue(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def pop(self, *args, **kwargs) -> Any: - ... - - def remove(self, *args, **kwargs) -> Any: - ... - - def peek(self, *args, **kwargs) -> Any: - ... - - def push(self, *args, **kwargs) -> Any: - ... - -def sleep(*args, **kwargs) -> Any: - ... - -def sleep_ms(*args, **kwargs) -> Any: - ... - -def ticks_add(*args, **kwargs) -> Any: - ... - -def ticks_diff(*args, **kwargs) -> Any: - ... - -wait_for : Any ## = -gather : Any ## = - -class Event(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def clear(self, *args, **kwargs) -> Any: - ... - - def set(self, *args, **kwargs) -> Any: - ... - - wait : Any ## = - def is_set(self, *args, **kwargs) -> Any: - ... - - -class Lock(): - def __init__(self, *argv, **kwargs) -> None: - ... - - acquire : Any ## = - def locked(self, *args, **kwargs) -> Any: - ... - - def release(self, *args, **kwargs) -> Any: - ... - -def wait_for_ms(*args, **kwargs) -> Any: - ... - - -class ThreadSafeFlag(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def clear(self, *args, **kwargs) -> Any: - ... - - def set(self, *args, **kwargs) -> Any: - ... - - def ioctl(self, *args, **kwargs) -> Any: - ... - - wait : Any ## = -open_connection : Any ## = -start_server : Any ## = - -class StreamReader(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - read : Any ## = - readinto : Any ## = - readline : Any ## = - def write(self, *args, **kwargs) -> Any: - ... - - wait_closed : Any ## = - aclose : Any ## = - awrite : Any ## = - awritestr : Any ## = - drain : Any ## = - def get_extra_info(self, *args, **kwargs) -> Any: - ... - - readexactly : Any ## = - -class StreamWriter(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - read : Any ## = - readinto : Any ## = - readline : Any ## = - def write(self, *args, **kwargs) -> Any: - ... - - wait_closed : Any ## = - aclose : Any ## = - awrite : Any ## = - awritestr : Any ## = - drain : Any ## = - def get_extra_info(self, *args, **kwargs) -> Any: - ... - - readexactly : Any ## = - -class TimeoutError(Exception): - ... - -class SingletonGenerator(): - def __init__(self, *argv, **kwargs) -> None: - ... - - -class IOQueue(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def remove(self, *args, **kwargs) -> Any: - ... - - def wait_io_event(self, *args, **kwargs) -> Any: - ... - - def queue_read(self, *args, **kwargs) -> Any: - ... - - def queue_write(self, *args, **kwargs) -> Any: - ... - - -class Loop(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - def stop(self, *args, **kwargs) -> Any: - ... - - def create_task(self, *args, **kwargs) -> Any: - ... - - def run_until_complete(self, *args, **kwargs) -> Any: - ... - - def call_exception_handler(self, *args, **kwargs) -> Any: - ... - - def run_forever(self, *args, **kwargs) -> Any: - ... - - def set_exception_handler(self, *args, **kwargs) -> Any: - ... - - def get_exception_handler(self, *args, **kwargs) -> Any: - ... - - def default_exception_handler(self, *args, **kwargs) -> Any: - ... - -def create_task(*args, **kwargs) -> Any: - ... - -def run_until_complete(*args, **kwargs) -> Any: - ... - -def run(*args, **kwargs) -> Any: - ... - -def get_event_loop(*args, **kwargs) -> Any: - ... - -def current_task(*args, **kwargs) -> Any: - ... - -def new_event_loop(*args, **kwargs) -> Any: - ... - -def ticks(*args, **kwargs) -> Any: - ... diff --git a/stubs/stubs/uasyncio/core.pyi b/stubs/stubs/uasyncio/core.pyi deleted file mode 100644 index 5bdf9c8..0000000 --- a/stubs/stubs/uasyncio/core.pyi +++ /dev/null @@ -1,146 +0,0 @@ -from typing import Any - - -class CancelledError(BaseException): ... -class TimeoutError(Exception): ... - -class SingletonGenerator: - def __init__(self) -> None: ... - def __iter__(self) -> Any: ... - # 0: return self - # ? 0: return self - def __next__(self) -> None: ... -def sleep_ms(t: Any, sgen: Any=SingletonGenerator()) -> Any: ... - # 0: return sgen - # ? 0: return sgen -def sleep(t: Any) -> Any: ... - # 0: return sleep_ms(int(t*)) - # ? 0: return sleep_ms(int(t*)) -class IOQueue: - def __init__(self) -> None: ... - def _enqueue(self, s: Any, idx: Any) -> None: ... - def _dequeue(self, s: Any) -> None: ... - def queue_read(self, s: Any) -> None: ... - def queue_write(self, s: Any) -> None: ... - def remove(self, task: Any) -> None: ... - def wait_io_event(self, dt: Any) -> None: ... -def _promote_to_task(aw: Any) -> Any: ... -def create_task(coro: Any) -> Any: ... - # 0: return t - # ? 0: return t -def run_until_complete(main_task: Any) -> Any: ... - # 0: return - # 0: return - # 1: return er.value - # ? 1: return er.value -def run(coro: Any) -> Any: - # 0: return run_until_complete(create_task(coro)) - # ? 0: return run_until_complete(create_task(coro)) - ... - -class Loop: - def create_task(self, coro: Any) -> Any: - # 0: return create_task(coro) - # ? 0: return create_task(coro) - ... - - def run_forever(self) -> None: - ... - - def run_until_complete(self, aw: Any) -> Any: - # 0: return run_until_complete(_promote_to_task(aw)) - # ? 0: return run_until_complete(_promote_to_task(aw)) - ... - - def stop(self) -> None: - ... - - def close(self) -> None: - ... - - def set_exception_handler(self, handler: Any) -> None: - ... - - def get_exception_handler(self) -> Any: - # 0: return Loop._exc_handler - # ? 0: return Loop._exc_handler - ... - - def default_exception_handler(self, loop: Any, context: Any) -> None: - ... - - def call_exception_handler(self, context: Any) -> None: - ... - -def get_event_loop(runq_len: Any, waitq_len: Any) -> Any: ... - # 0: return Loop - # ? 0: return Loop -def new_event_loop() -> Any: ... - # 0: return Loop - # ? 0: return Loop - -class TaskQueue: - '' - def __init__(self): - ... - - def peek(self) -> Any: - ... - - def push_sorted(self, v, key): - ... - - def push_head(self, v): - ... - - def pop_head(self) -> Any: - ... - - def remove(self, v): - ... - - -def ticks() -> int: - """ - Returns the uptime of the module in milliseconds. - - :return: The uptime of the module in milliseconds. - """ - ... - -def ticks_add(ticks: int, delta: int) -> int: - """ - Offsets ticks value by a given number, which can be either positive or - negative. Given a ticks value, this function allows to calculate ticks - value delta ticks before or after it, following modular-arithmetic - definition of tick values (see ``ticks_ms()``). - - This method is useful for calculating deadlines for events/tasks. - - **Note**: You must use ``ticks_diff()`` function to work with deadlines. - - :param ticks: Number obtained from a direct result of call to - ``ticks_ms()``, ``ticks_us()``, or ``ticks_cpu()`` functions (or from - previous call to ``ticks_add()``) - :param delta: Arbitrary integer number or numeric expression. - - :return: Returns the result of the add operation. - """ - ... - -def ticks_diff(ticks1: int, ticks2: int) -> int: - """ - Measures the period (ticks) difference between values returned from - ``ticks_ms()``, ``ticks_us()``, or ``ticks_cpu()`` functions, as a signed - value which may wrap around, so directly subtracting them is not supported. - - The argument order is the same as for subtraction operator, - ``ticks_diff(ticks1, ticks2)`` has the same meaning as ``ticks1 - ticks2``. - - :param ticks1: Ticks that precede in time the value of ``ticks2``. - :param ticks2: Second (newer) ticks value. - - :return: The difference between the given ticks values. - """ - ... - diff --git a/stubs/stubs/uasyncio/event.pyi b/stubs/stubs/uasyncio/event.pyi deleted file mode 100644 index 5349ebd..0000000 --- a/stubs/stubs/uasyncio/event.pyi +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Any - -class Event: - def __init__(self) -> None: - ... - - def clear(self) -> None: - ... - - def set(self) -> None: - ... - - def is_set(self) -> Any: - ... - - wait : Any ## = - -class ThreadSafeFlag(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def clear(self, *args, **kwargs) -> Any: - ... - - def set(self): - """ - Set the flag. If there is a task waiting on the event, it will be scheduled to run. - """ - ... - - def ioctl(self): - ... - - wait : Any ## = diff --git a/stubs/stubs/uasyncio/funcs.pyi b/stubs/stubs/uasyncio/funcs.pyi deleted file mode 100644 index 2251ca2..0000000 --- a/stubs/stubs/uasyncio/funcs.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import Any - -def wait_for_ms(aw: Any, timeout: int) -> Any: - # 0: return wait_for(aw,timeout,core.sleep_ms) - # ? 0: return wait_for(aw, timeout, core.sleep_ms) - ... diff --git a/stubs/stubs/uasyncio/lock.pyi b/stubs/stubs/uasyncio/lock.pyi deleted file mode 100644 index d109fd0..0000000 --- a/stubs/stubs/uasyncio/lock.pyi +++ /dev/null @@ -1,10 +0,0 @@ -# make_stub_files: Wed 03 Feb 2021 at 08:14:26 -class Lock: - def __init__(self) -> None: - ... - - def locked(self) -> bool: - ... - - def release(self) -> None: - ... diff --git a/stubs/stubs/uasyncio/stream.pyi b/stubs/stubs/uasyncio/stream.pyi deleted file mode 100644 index c327ddc..0000000 --- a/stubs/stubs/uasyncio/stream.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Any - -class Stream: - def __init__(self, s: Any, e: Any={}) -> None: - ... - - def get_extra_info(self, v: Any) -> Any: - # 0: return self.e[v] - # ? 0: return self.e[v] - ... - - def close(self) -> None: ... - def write(self, buf: Any) -> None: - ... - -class StreamReader: - def __init__(self, s: Any, e: Any={}) -> None: - ... - - def get_extra_info(self, v: Any) -> Any: - # 0: return self.e[v] - # ? 0: return self.e[v] - ... - - def close(self) -> None: ... - def write(self, buf: Any) -> None: - ... - -class StreamWriter: - def __init__(self, s: Any, e: Any={}) -> None: - ... - - def get_extra_info(self, v: Any) -> Any: - # 0: return self.e[v] - # ? 0: return self.e[v] - ... - - def close(self) -> None: - ... - - def write(self, buf: Any) -> None: - ... - -class Server: - def close(self) -> None: ... diff --git a/stubs/stubs/uasyncio/task.pyi b/stubs/stubs/uasyncio/task.pyi deleted file mode 100644 index 1e61f26..0000000 --- a/stubs/stubs/uasyncio/task.pyi +++ /dev/null @@ -1,71 +0,0 @@ -from typing import Any - -def ph_meld(h1: Any, h2: Any) -> Any: - # 0: return h2 - # ? 0: return h2 - # 1: return h1 - # ? 1: return h1 - # 2: return h1 - # ? 2: return h1 - # 3: return h2 - # ? 3: return h2 - ... - -def ph_pairing(child: Any) -> Any: - # 0: return heap - # ? 0: return heap - ... - -def ph_delete(heap: Any, node: Any) -> Any: - # 0: return ph_pairing(child) - # ? 0: return ph_pairing(child) - # 1: return heap - # ? 1: return heap - # 2: return heap - # ? 2: return heap - ... - -class TaskQueue: - def __init__(self) -> None: - ... - - def peek(self) -> Any: - # 0: return self.heap - # ? 0: return self.heap - ... - - - def push_sorted(self, v: Any, key: Any) -> None: - ... - - def push_head(self, v: Any) -> None: - ... - - def pop_head(self) -> Any: - # 0: return v - # ? 0: return v - ... - - def remove(self, v: Any) -> None: - ... - -class Task: - def __init__(self, coro: Any, globals: Any) -> None: - ... - - def __iter__(self) -> Any: - # 0: return self - # ? 0: return self - ... - - def __next__(self) -> None: - ... - - def done(self) -> bool: - ... - - def cancel(self) -> None: - ... - - def throw(self, value: Any) -> None: - ... diff --git a/stubs/stubs/ubluetooth/ubluetooth.pyi b/stubs/stubs/ubluetooth/ubluetooth.pyi deleted file mode 100644 index 67ec3cd..0000000 --- a/stubs/stubs/ubluetooth/ubluetooth.pyi +++ /dev/null @@ -1,98 +0,0 @@ -from typing import Any - - -class BLE(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def active(self, active: bool=..., /) -> bool: - ... - - def config(self, *args, **kwargs) -> Any: - """ - Get or set configuration values of the BLE interface. - To get a value the parameter name should be quoted as a string, - and just one parameter is queried at a time. To set values use - the keyword syntax, and one or more parameter can be set at a time. - """ - ... - - def gap_advertise(self, interval_us, adv_data=None, *, resp_data=None, connectable=True) -> Any: - """ - Starts advertising at the specified interval (in microseconds). - This interval will be rounded down to the nearest 625us. To stop - advertising, set interval_us to None. - """ - ... - - def gap_connect(self, addr_type, addr, scan_duration_ms=2000, min_conn_interval_us=None, max_conn_interval_us=None, /) -> Any: - ... - - def gap_disconnect(self, conn_handle, /) -> bool: - ... - - def gap_scan(self, duration_ms, interval_us=1280000, window_us=11250, active=False, /) -> Any: - ... - - def gattc_discover_characteristics(self, conn_handle, start_handle, end_handle, uuid=None, /) -> Any: - ... - - def gattc_discover_descriptors(self, conn_handle, start_handle, end_handle, /) -> Any: - ... - - def gattc_discover_services(self, conn_handle, uuid=None, /) -> Any: - ... - - def gattc_exchange_mtu(self, conn_handle, /) -> Any: - ... - - def gattc_read(self, conn_handle, value_handle, /) -> Any: - ... - - def gattc_write(self, conn_handle, value_handle, data, mode=0, /) -> Any: - ... - - def gatts_indicate(self, conn_handle, value_handle, data=None, /) -> Any: - ... - - def gatts_notify(self, conn_handle, value_handle, data=None, /) -> Any: - ... - - def gatts_read(self, value_handle, /) -> Any: - """ - Reads the local value for this handle (which has either been written by - `gatts_write` or by a remote client). - """ - ... - - def gatts_register_services(self, services_definition, /) -> Any: - ... - - def gatts_set_buffer(self, *args, **kwargs) -> Any: - ... - - def gatts_write(self, value_handle, data, send_update=False, /) -> Any: - ... - - def irq(self, *args, **kwargs) -> Any: - """Registers a callback for events from the BLE stack.""" - ... - -FLAG_INDICATE = 32 # type: int -FLAG_NOTIFY = 16 # type: int -FLAG_READ = 2 # type: int -FLAG_WRITE = 8 # type: int -FLAG_WRITE_NO_RESPONSE = 4 # type: int - -class UUID(): - def __init__(self, value, /) -> None: - """ - Creates a UUID instance with the specified value. - - The value can be either: - - - A 16-bit integer. e.g. `0x2908`. - - - A 128-bit UUID string. e.g. `'6E400001-B5A3-F393-E0A9-E50E24DCCA9E'`. - """ - ... diff --git a/stubs/stubs/ucryptolib/ucryptolib.pyi b/stubs/stubs/ucryptolib/ucryptolib.pyi deleted file mode 100644 index c0963f8..0000000 --- a/stubs/stubs/ucryptolib/ucryptolib.pyi +++ /dev/null @@ -1,44 +0,0 @@ -""" -Module: 'ucryptolib' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any, Optional - - -class aes(): - - def __init__(self, key: bytes, mode: int, IV: Any = None) -> None: - """Initialize cipher object, suitable for encryption/decryption. Note: after initialization, cipher object can be use only either for encryption or decryption. Running decrypt() operation after encrypt() or vice versa is not supported. - - Parameters are: - - - *key* is an encryption/decryption key (bytes-like). - - - *mode* is: - - -- ``1`` for Electronic Code Book (ECB). - - -- ``2`` for Cipher Block Chaining (CBC). - - -- ``6`` for Counter mode (CTR). - - - *IV* is an initialization vector for CBC mode. - - For Counter mode, IV is the initial value for the counter. - """ - ... - - def decrypt(self, in_buf: Any, out_buf: Any = None) -> Optional[bytes]: - """Like ``encrypt()``, but for decryption.""" - ... - - def encrypt(self, in_buf: Any, out_buf: Any = None) -> Optional[bytes]: - """Encrypt in_buf. If no out_buf is given - result is returned as a newly allocated ``bytes`` - object. Otherwise, result is written into mutable - buffer out_buf. in_buf and out_buf can also refer - to the same mutable buffer, in which case data - is encrypted in-place. - """ - ... - diff --git a/stubs/stubs/uctypes/uctypes.pyi b/stubs/stubs/uctypes/uctypes.pyi deleted file mode 100644 index fad50bb..0000000 --- a/stubs/stubs/uctypes/uctypes.pyi +++ /dev/null @@ -1,95 +0,0 @@ -""" -Access binary data in a structured way. - -This module implements "foreign data interface" for MicroPython. The idea -behind it is similar to CPython's ``ctypes`` modules, but the actual API is -different, streamlined and optimized for small size. The basic idea of the -module is to define data structure layout with about the same power as the -C language allows, and then access it using familiar dot-syntax to reference -sub-fields. - -.. warning:: - - ``uctypes`` module allows access to arbitrary memory addresses of the - machine (including I/O and control registers). Uncareful usage of it - may lead to crashes, data loss, and even hardware malfunction. - -.. seealso:: - - Module :mod:`ustruct` - Standard Python way to access binary data structures (doesn't scale - well to large and complex structures). -""" - -from typing import Any - -ARRAY = -1073741824 -BFINT16 = -671088640 -BFINT32 = -402653184 -BFINT8 = -939524096 -BFUINT16 = -805306368 -BFUINT32 = -536870912 -BFUINT8 = -1073741824 -BF_LEN = 22 -BF_POS = 17 -BIG_ENDIAN = 1 -FLOAT32 = -268435456 -FLOAT64 = -134217728 -INT = 671088640 -INT16 = 402653184 -INT32 = 671088640 -INT64 = 939524096 -INT8 = 134217728 -LITTLE_ENDIAN = 0 -LONG = 671088640 -LONGLONG = 939524096 -NATIVE = 2 -PTR = 536870912 -SHORT = 402653184 -UINT = 536870912 -UINT16 = 268435456 -UINT32 = 536870912 -UINT64 = 805306368 -UINT8 = 0 -ULONG = 536870912 -ULONGLONG = 805306368 -USHORT = 268435456 -VOID = 0 - -def addressof(value: Any) -> int: - """ - Return address of an object. Argument should be bytes, bytearray or - other object supporting buffer protocol (and address of this buffer - is what actually returned). - """ - -def bytearray_at(addr:int, size:int) -> bytearray: - """ - Capture memory at the given address and size as bytearray object. - Unlike the bytes_at() function, memory is captured by reference, - so it can be both written too, and you will access current value - at the given memory address. - """ - -def bytes_at(addr:int, size:int) -> bytes: - """ - Capture memory at the given address and size as bytes object. As bytes - object is immutable, memory is actually duplicated and copied into - bytes object, so if memory contents change later, created object - retains original value. - """ - -def sizeof(struct:Any, layout_type:int=NATIVE, /) -> int: - """ - Return size of data structure in bytes. The *struct* argument can be - either a structure class or a specific instantiated structure object - (or its aggregate field). - """ - - -class struct: - def __init__(self, addr:int, descriptor:Any, layout_type:int=NATIVE, /): - """ - Instantiate a "foreign data structure" object based on structure address in - memory, descriptor (encoded as a dictionary), and layout type. - """ diff --git a/stubs/stubs/ujson/ujson.pyi b/stubs/stubs/ujson/ujson.pyi deleted file mode 100644 index 9aa98c1..0000000 --- a/stubs/stubs/ujson/ujson.pyi +++ /dev/null @@ -1,25 +0,0 @@ -""" -Module: 'ujson' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -def dump(obj, stream, separators=None) -> str: - """Serialise obj to a JSON string, writing it to the given *stream*.""" - ... - -def dumps(obj, separators=None) -> str: - ... - -def load(stream) -> Any: - """Parse the given stream, interpreting it as a JSON string and - deserialising the data to a Python object. The - resulting object is returned. - """ - ... - -def loads(str: str) -> Any: - """Parse the JSON str and return an object. - Raises ``ValueError`` if the string is not correctly formed. - """ - ... diff --git a/stubs/stubs/umachine/umachine.pyi b/stubs/stubs/umachine/umachine.pyi deleted file mode 100644 index d9465f1..0000000 --- a/stubs/stubs/umachine/umachine.pyi +++ /dev/null @@ -1,1980 +0,0 @@ -""" - -Functions related to the hardware. - -Descriptions taken from -`https://raw.githubusercontent.com/micropython/micropython/master/docs/library/machine.rst`, etc. - -==================================================== - -.. module:: machine - :synopsis: functions related to the hardware - - - - The ``machine`` module contains specific functions related to the hardware - on a particular board. Most functions in this module allow to achieve direct - and unrestricted access to and control of hardware blocks on a system - (like CPU, timers, buses, etc.). Used incorrectly, this can lead to - malfunction, lockups, crashes of your board, and in extreme cases, hardware - damage. - - .. _machine_callbacks: - - A note of callbacks used by functions and class methods of :mod:`machine` module: - all these callbacks should be considered as executing in an interrupt context. - This is true for both physical devices with IDs >= 0 and "virtual" devices - with negative IDs like -1 (these "virtual" devices are still thin shims on - top of real hardware and real hardware interrupts). See :ref:`isr_rules`. - -""" -from collections.abc import Callable, Sequence -from typing import overload, NoReturn, ClassVar, Any, Literal, Optional, Union - - -class ADC: - """ - The ADC class provides an interface to analog-to-digital convertors, and - represents a single endpoint that can sample a continuous voltage and - convert it to a discretised value. - - Example usage:: - - import machine - - adc = machine.ADC(pin) # create an ADC object acting on a pin - val = adc.read_u16() # read a raw analog value in the range 0-65535 - """ - - def __init__(self, pin: Union[int, Pin], /): - """ - Access the ADC associated with a source identified by *id*. This - *id* may be an integer (usually specifying a channel number), a - :ref:`Pin ` object, or other value supported by the - underlying machine. - """ - ... - - def read_u16(self) -> int: - """ - Take an analog reading and return an integer in the range 0-65535. - The return value represents the raw reading taken by the ADC, scaled - such that the minimum value is 0 and the maximum value is 65535. - """ - ... - - -class Pin: - """ - A pin is the basic object to control I/O pins. It has methods to set - the mode of the pin (input, output, etc) and methods to get and set the - digital logic level. For analog control of a pin, see the ADC class. - """ - - ALT = 3 # type: int - ALT_GPCK = 8 # type: int - ALT_I2C = 3 # type: int - ALT_PIO0 = 6 # type: int - ALT_PIO1 = 7 # type: int - ALT_PWM = 4 # type: int - ALT_SIO = 5 # type: int - ALT_SPI = 1 # type: int - ALT_UART = 2 # type: int - ALT_USB = 9 # type: int - IN = 0 # type: int - IRQ_FALLING = 4 # type: int - IRQ_RISING = 8 # type: int - OPEN_DRAIN = 2 # type: int - OUT = 1 # type: int - PULL_DOWN = 2 # type: int - PULL_UP = 1 # type: int - - class board(): - GP0 : Pin - """ = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP1 : Pin - """ = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP10 : Pin - """ = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP11 : Pin - """ = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP12 : Pin - """ = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP13 : Pin - """ = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP14 : Pin - """ = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP15 : Pin - """ = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP16 : Pin - """ = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP17 : Pin - """ = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP18 : Pin - """ = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP19 : Pin - """ = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP2 : Pin - """ = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP20 : Pin - """ = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP21 : Pin - """ = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP22 : Pin - """ = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP26 : Pin - """ = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP27 : Pin - """ = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP28 : Pin - """ = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP3 : Pin - """ = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP4 : Pin - """ = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP5 : Pin - """ = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP6 : Pin - """ = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP7 : Pin - """ = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP8 : Pin - """ = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) """ - GP9 : Pin - """ = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) """ - LED : Pin - """ = Pin(EXT_GPIO0, mode=IN) """ - WL_GPIO0 : Pin - """ = Pin(EXT_GPIO0, mode=IN) """ - WL_GPIO1 : Pin - """ = Pin(EXT_GPIO1, mode=IN) """ - WL_GPIO2 : Pin - """ = Pin(EXT_GPIO2, mode=IN) """ - - class cpu(): - - EXT_GPIO0 : Pin - """ = Pin(EXT_GPIO0, mode=IN) """ - EXT_GPIO1 : Pin - """ = Pin(EXT_GPIO1, mode=IN) """ - EXT_GPIO2 : Pin - """ = Pin(EXT_GPIO2, mode=IN) """ - GPIO0 : Pin - """ = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO1 : Pin - """ = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO10 : Pin - """ = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO11 : Pin - """ = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO12 : Pin - """ = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO13 : Pin - """ = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO14 : Pin - """ = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO15 : Pin - """ = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO16 : Pin - """ = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO17 : Pin - """ = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO18 : Pin - """ = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO19 : Pin - """ = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO2 : Pin - """ = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO20 : Pin - """ = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO21 : Pin - """ = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO22 : Pin - """ = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO23 : Pin - """ = Pin(GPIO23, mode=ALT, alt=31) """ - GPIO24 : Pin - """ = Pin(GPIO24, mode=ALT, alt=31) """ - GPIO25 : Pin - """ = Pin(GPIO25, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO26 : Pin - """ = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO27 : Pin - """ = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO28 : Pin - """ = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO29 : Pin - """ = Pin(GPIO29, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO3 : Pin - """ = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO4 : Pin - """ = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO5 : Pin - """ = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO6 : Pin - """ = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO7 : Pin - """ = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO8 : Pin - """ = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) """ - GPIO9 : Pin - """ = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) """ - - def __init__(self, id: Union[int, str, tuple[Any,Any]], mode: int = -1, pull: Optional[int] = -1, *, value: Optional[int] = None, drive: int = 0, alt: int = -1): - """ - Access the pin peripheral (GPIO pin) associated with the given id. If additional arguments are - given in the constructor then they are used to initialise the pin. Any settings that are not - specified will remain in their previous state. - -The arguments are: - -- `id` is mandatory and can be an arbitrary object. Among possible value types are: int -(an internal Pin identifier), str (a Pin name), and tuple (pair of [port, pin]). -- `mode` specifies the pin mode, which can be one of: - - `Pin.IN` - Pin is configured for input. If viewed as an output the pin is in high-impedance state. - - `Pin.OUT` - Pin is configured for (normal) output. - - `Pin.OPEN_DRAIN` - Pin is configured for open-drain output. Open-drain output works in the - following way: if the output value is set to 0 the pin is active at a low level; if the output - value is 1 the pin is in a high-impedance state. Not all ports implement this mode, or some might only on certain pins. - - `Pin.ALT` - Pin is configured to perform an alternative function, which is port specific. For - a pin configured in such a way any other Pin methods (except Pin.init()) are not applicable - (calling them will lead to undefined, or a hardware-specific, result). Not all ports implement this mode. - - `Pin.ALT_OPEN_DRAIN` - The Same as `Pin.ALT`, but the pin is configured as open-drain. Not all - ports implement this mode. - - `Pin.ANALOG` - Pin is configured for analog input, see the ADC class. -- `pull` specifies if the pin has a (weak) pull resistor attached, and can be one of: - - `None` - No pull up or down resistor. - - `Pin.PULL_UP` - Pull up resistor enabled. - - `Pin.PULL_DOWN` - Pull down resistor enabled. -- `value` is valid only for `Pin.OUT` and `Pin.OPEN_DRAIN` modes and specifies initial output pin value if -given, otherwise the state of the pin peripheral remains unchanged. -- `drive` specifies the output power of the pin and can be one of: `Pin.DRIVE_0`, `Pin.DRIVE_1`, etc., -increasing in drive strength. The actual current driving capabilities are port dependent. Not all ports implement this argument. -- `alt` specifies an alternate function for the pin and the values it can take are port dependent. This -argument is valid only for `Pin.ALT` and `Pin.ALT_OPEN_DRAIN` modes. It may be used when a pin supports -more than one alternate function. If only one pin alternate function is supported the this argument is -not required. Not all ports implement this argument. - -As specified above, the Pin class allows to set an alternate function for a particular pin, but it does not specify any -further operations on such a pin. Pins configured in alternate-function mode are usually not used as GPIO but are instead -driven by other hardware peripherals. The only operation supported on such a pin is re-initialising, by calling the -constructor or `Pin.init()` method. If a pin that is configured in alternate-function mode is re-initialised -with `Pin.IN`, `Pin.OUT`, or `Pin.OPEN_DRAIN`, the alternate function will be removed from the pin. - - (Source: https://docs.micropython.org/en/latest/library/machine.Pin.html, Copyright: 2014-2023 Damien P. George, Paul Sokolovsky, and contributors.) - """ - ... - - def high(self): - """ - Sets the pin to high. - """ - ... - - def init(self, mode: int = -1, pull: Optional[int] = -1, *, value: Optional[int] = None, drive: int = 0, alt: int = -1): - """ - Re-initialise the pin using the given parameters. Only those arguments that are specified will be set. The rest - of the pin peripheral state will remain unchanged. See the constructor documentation for details of the arguments. - """ - ... - - def irq(self, handler: Callable, trigger: int, hard: bool = False) -> Callable: - """ - Sets an interrupt for when the pin is rising or falling. - - - ``handler`` the code to execute when the interrupt happens. - - ``trigger`` either ``IRQ_RISING`` or ``IRQ_FALLING`` - - ``hard`` if true a hardware interrupt is used. This reduces the delay between the pin change and the handler being called. - """ - ... - - def low(self): - """ - Sets the pin to low. - """ - ... - - def off(self): - """ - Sets the pin to be off. - """ - ... - - def on(self): - """ - Sets the pin to be on. - """ - ... - - def toggle(self): - """ - Sets the pin to high if it's currently low, and vice versa. - """ - ... - - def value(self, value: Any=..., /) -> Optional[Literal[0, 1]]: - """ - Get or set the digital logic level of the pin: - - - With no argument, return 0 or 1 depending on the logic level of the pin. - - With ``value`` given, set the logic level of the pin. `value` can be - anything that converts to a boolean. If it converts to `True`, the pin - is set high, otherwise it is set low. - """ - ... - - -class RTC(): - """The RTC is an independent clock that keeps track of the date and time.""" - - def __init__(self, *argv, **kwargs) -> None: - ... - - def datetime(self, *args, **kwargs) -> Any: - """ - Get or set the date and time of the RTC. - - With no arguments, this method returns an 8-tuple with the - current date and time. With 1 argument (being an 8-tuple) - it sets the date and time. - - The 8-tuple has the following format: - - (year, month, day, weekday, hours, minutes, seconds, subseconds) - - The meaning of the `subseconds` field is hardware dependent. - """ - ... - - -class SPI: - """ - SPI is a synchronous serial protocol that is driven by a master. At the - physical level, a bus consists of 3 lines: SCK, MOSI, MISO. Multiple devices - can share the same bus. Each device should have a separate, 4th signal, - SS (Slave Select), to select a particular device on a bus with which - communication takes place. Management of an SS signal should happen in - user code (via machine.Pin class). - - Both hardware and software SPI implementations exist via the - :ref:`machine.SPI ` and `machine.SoftSPI` classes. Hardware SPI uses underlying - hardware support of the system to perform the reads/writes and is usually - efficient and fast but may have restrictions on which pins can be used. - Software SPI is implemented by bit-banging and can be used on any pin but - is not as efficient. These classes have the same methods available and - differ primarily in the way they are constructed. - """ - - MSB: ClassVar[int] = ... - """ - set the first bit to be the most significant bit - """ - - LSB: ClassVar[int] = ... - """ - set the first bit to be the least significant bit - """ - - @overload - def __init__(self, id: int, /): - """ - Construct an SPI object on the given bus, *id*. Values of *id* depend - on a particular port and its hardware. Values 0, 1, etc. are commonly used - to select hardware SPI block #0, #1, etc. - - With no additional parameters, the SPI object is created but not - initialised (it has the settings from the last initialisation of - the bus, if any). If extra arguments are given, the bus is initialised. - See ``init`` for parameters of initialisation. - """ - ... - - @overload - def __init__( - self, - id: int, - /, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - sck: Optional[Pin] = None, - mosi: Optional[Pin] = None, - miso: Optional[Pin] = None, - ): - """ - Construct an SPI object on the given bus, *id*. Values of *id* depend - on a particular port and its hardware. Values 0, 1, etc. are commonly used - to select hardware SPI block #0, #1, etc. - - With no additional parameters, the SPI object is created but not - initialised (it has the settings from the last initialisation of - the bus, if any). If extra arguments are given, the bus is initialised. - See ``init`` for parameters of initialisation. - """ - ... - - @overload - def __init__( - self, - id: int, - /, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - pins: Optional[tuple[Pin, Pin, Pin]] = None, - ): - """ - Construct an SPI object on the given bus, *id*. Values of *id* depend - on a particular port and its hardware. Values 0, 1, etc. are commonly used - to select hardware SPI block #0, #1, etc. - - With no additional parameters, the SPI object is created but not - initialised (it has the settings from the last initialisation of - the bus, if any). If extra arguments are given, the bus is initialised. - See ``init`` for parameters of initialisation. - """ - ... - - @overload - def init( - self, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - sck: Optional[Pin] = None, - mosi: Optional[Pin] = None, - miso: Optional[Pin] = None, - ) -> None: - """ - Initialise the SPI bus with the given parameters: - - - ``baudrate`` is the SCK clock rate. - - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. - - ``phase`` can be 0 or 1 to sample data on the first or second clock edge - respectively. - - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. - - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. - - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most - hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed - and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for - a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver - (``id`` = -1). - - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to - specify them as a tuple of ``pins`` parameter. - - In the case of hardware SPI the actual clock frequency may be lower than the - requested baudrate. This is dependant on the platform hardware. The actual - rate may be determined by printing the SPI object. - """ - ... - - @overload - def init( - self, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - pins: Optional[tuple[Pin, Pin, Pin]] = None, - ) -> None: - """ - Initialise the SPI bus with the given parameters: - - - ``baudrate`` is the SCK clock rate. - - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. - - ``phase`` can be 0 or 1 to sample data on the first or second clock edge - respectively. - - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. - - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. - - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most - hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed - and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for - a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver - (``id`` = -1). - - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to - specify them as a tuple of ``pins`` parameter. - - In the case of hardware SPI the actual clock frequency may be lower than the - requested baudrate. This is dependant on the platform hardware. The actual - rate may be determined by printing the SPI object. - """ - ... - - def deinit(self) -> None: - """ - Turn off the SPI bus. - """ - ... - - def read(self, nbytes: int, write: int = 0x00, /) -> bytes: - """ - Read a number of bytes specified by ``nbytes`` while continuously writing - the single byte given by ``write``. - Returns a ``bytes`` object with the data that was read. - """ - ... - - def readinto(self, buf: bytes, write: int = 0x00, /) -> Optional[int]: - """ - Read into the buffer specified by ``buf`` while continuously writing the - single byte given by ``write``. - Returns ``None``. - - Note: on WiPy this function returns the number of bytes read. - """ - ... - - def write(self, buf: bytes, /) -> Optional[int]: - """ - Write the bytes contained in ``buf``. - Returns ``None``. - - Note: on WiPy this function returns the number of bytes written. - """ - ... - - def write_readinto(self, write_buf: bytes, read_buf: bytes, /) -> Optional[int]: - """ - Write the bytes from ``write_buf`` while reading into ``read_buf``. The - buffers can be the same or different, but both buffers must have the - same length. - Returns ``None``. - - Note: on WiPy this function returns the number of bytes written. - """ - ... - - -class SoftSPI: - """ - SPI is a synchronous serial protocol that is driven by a master. At the - physical level, a bus consists of 3 lines: SCK, MOSI, MISO. Multiple devices - can share the same bus. Each device should have a separate, 4th signal, - SS (Slave Select), to select a particular device on a bus with which - communication takes place. Management of an SS signal should happen in - user code (via machine.Pin class). - - Both hardware and software SPI implementations exist via the - :ref:`machine.SPI ` and `machine.SoftSPI` classes. Hardware SPI uses underlying - hardware support of the system to perform the reads/writes and is usually - efficient and fast but may have restrictions on which pins can be used. - Software SPI is implemented by bit-banging and can be used on any pin but - is not as efficient. These classes have the same methods available and - differ primarily in the way they are constructed. - """ - - MSB: ClassVar[int] = ... - """ - set the first bit to be the most significant bit - """ - - LSB: ClassVar[int] = ... - """ - set the first bit to be the least significant bit - """ - - @overload - def __init__( - self, - id: int, - /, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - sck: Optional[Pin] = None, - mosi: Optional[Pin] = None, - miso: Optional[Pin] = None, - ): - """ - Construct an SPI object on the given bus, *id*. Values of *id* depend - on a particular port and its hardware. Values 0, 1, etc. are commonly used - to select hardware SPI block #0, #1, etc. - - With no additional parameters, the SPI object is created but not - initialised (it has the settings from the last initialisation of - the bus, if any). If extra arguments are given, the bus is initialised. - See ``init`` for parameters of initialisation. - """ - ... - - @overload - def __init__( - self, - id: int, - /, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - pins: Optional[tuple[Pin, Pin, Pin]] = None, - ): - """ - Construct an SPI object on the given bus, *id*. Values of *id* depend - on a particular port and its hardware. Values 0, 1, etc. are commonly used - to select hardware SPI block #0, #1, etc. - - With no additional parameters, the SPI object is created but not - initialised (it has the settings from the last initialisation of - the bus, if any). If extra arguments are given, the bus is initialised. - See ``init`` for parameters of initialisation. - """ - ... - - @overload - def init( - self, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - sck: Optional[Pin] = None, - mosi: Optional[Pin] = None, - miso: Optional[Pin] = None, - ) -> None: - """ - Initialise the SPI bus with the given parameters: - - - ``baudrate`` is the SCK clock rate. - - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. - - ``phase`` can be 0 or 1 to sample data on the first or second clock edge - respectively. - - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. - - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. - - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most - hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed - and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for - a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver - (``id`` = -1). - - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to - specify them as a tuple of ``pins`` parameter. - - In the case of hardware SPI the actual clock frequency may be lower than the - requested baudrate. This is dependant on the platform hardware. The actual - rate may be determined by printing the SPI object. - """ - ... - - @overload - def init( - self, - baudrate: int = 1_000_000, - *, - polarity: int = 0, - phase: int = 0, - bits: int = 8, - firstbit: int = MSB, - pins: Optional[tuple[Pin, Pin, Pin]] = None, - ) -> None: - """ - Initialise the SPI bus with the given parameters: - - - ``baudrate`` is the SCK clock rate. - - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. - - ``phase`` can be 0 or 1 to sample data on the first or second clock edge - respectively. - - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. - - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. - - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most - hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed - and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for - a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver - (``id`` = -1). - - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to - specify them as a tuple of ``pins`` parameter. - - In the case of hardware SPI the actual clock frequency may be lower than the - requested baudrate. This is dependant on the platform hardware. The actual - rate may be determined by printing the SPI object. - """ - ... - - def deinit(self) -> None: - """ - Turn off the SPI bus. - """ - ... - - def read(self, nbytes: int, write: int = 0x00, /) -> bytes: - """ - Read a number of bytes specified by ``nbytes`` while continuously writing - the single byte given by ``write``. - Returns a ``bytes`` object with the data that was read. - """ - ... - - def readinto(self, buf: bytes, write: int = 0x00, /) -> Optional[int]: - """ - Read into the buffer specified by ``buf`` while continuously writing the - single byte given by ``write``. - Returns ``None``. - - Note: on WiPy this function returns the number of bytes read. - """ - ... - - def write(self, buf: bytes, /) -> Optional[int]: - """ - Write the bytes contained in ``buf``. - Returns ``None``. - - Note: on WiPy this function returns the number of bytes written. - """ - ... - - def write_readinto(self, write_buf: bytes, read_buf: bytes, /) -> Optional[int]: - """ - Write the bytes from ``write_buf`` while reading into ``read_buf``. The - buffers can be the same or different, but both buffers must have the - same length. - Returns ``None``. - - Note: on WiPy this function returns the number of bytes written. - """ - ... - - -class I2C: - """ - I2C is a two-wire protocol for communicating between devices. At the physical - level it consists of 2 wires: SCL and SDA, the clock and data lines respectively. - - I2C objects are created attached to a specific bus. They can be initialised - when created, or initialised later on. - - Printing the I2C object gives you information about its configuration. - - Both hardware and software I2C implementations exist via the - :ref:`machine.I2C ` and `machine.SoftI2C` classes. Hardware I2C uses - underlying hardware support of the system to perform the reads/writes and is - usually efficient and fast but may have restrictions on which pins can be used. - Software I2C is implemented by bit-banging and can be used on any pin but is not - as efficient. These classes have the same methods available and differ primarily - in the way they are constructed. - - Example usage:: - - from machine import I2C - - # create I2C peripheral at frequency of 400kHz - i2c = I2C(freq=400000) - # depending on the port, extra parameters may be required - # to select the peripheral and/or pins to use - - i2c.scan() # scan for slaves, returning a list of 7-bit addresses - - # write 3 bytes to slave with 7-bit address 42 - i2c.writeto(42, b'123') - # read 4 bytes from slave with 7-bit address 42 - i2c.readfrom(42, 4) - - i2c.readfrom_mem(42, 8, 3) # read 3 bytes from memory of slave 42, - # starting at memory-address 8 in the slave - i2c.writeto_mem(42, 2, b'\x10') # write 1 byte to memory of slave 42 - # starting at address 2 in the slave - """ - - @overload - def __init__(self, id: int, /, *, freq: int = 400_000): - """ - Construct and return a new I2C object using the following parameters: - - - *id* identifies a particular I2C peripheral. Allowed values for - depend on the particular port/board - - *scl* should be a pin object specifying the pin to use for SCL. - - *sda* should be a pin object specifying the pin to use for SDA. - - *freq* should be an integer which sets the maximum frequency - for SCL. - - Note that some ports/boards will have default values of *scl* and *sda* - that can be changed in this constructor. Others will have fixed values - of *scl* and *sda* that cannot be changed. - """ - ... - - @overload - def __init__(self, id: int, /, *, scl: Pin, sda: Pin, freq: int = 400_000): - """ - Construct and return a new I2C object using the following parameters: - - - *id* identifies a particular I2C peripheral. Allowed values for - depend on the particular port/board - - *scl* should be a pin object specifying the pin to use for SCL. - - *sda* should be a pin object specifying the pin to use for SDA. - - *freq* should be an integer which sets the maximum frequency - for SCL. - - Note that some ports/boards will have default values of *scl* and *sda* - that can be changed in this constructor. Others will have fixed values - of *scl* and *sda* that cannot be changed. - """ - ... - - def init(self, *, scl: Pin, sda: Pin, freq: int = 400_000) -> None: - """ - Initialise the I2C bus with the given arguments: - - - *scl* is a pin object for the SCL line - - *sda* is a pin object for the SDA line - - *freq* is the SCL clock rate - """ - ... - - def scan(self) -> list[int]: - """ - Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of - those that respond. A device responds if it pulls the SDA line low after - its address (including a write bit) is sent on the bus. - """ - ... - - def start(self) -> None: - """ - Generate a START condition on the bus (SDA transitions to low while SCL is high). - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def stop(self) -> None: - """ - Generate a STOP condition on the bus (SDA transitions to high while SCL is high). - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def readinto(self, buf: bytes, nack: bool = True, /) -> None: - """ - Reads bytes from the bus and stores them into *buf*. The number of bytes - read is the length of *buf*. An ACK will be sent on the bus after - receiving all but the last byte. After the last byte is received, if *nack* - is true then a NACK will be sent, otherwise an ACK will be sent (and in this - case the slave assumes more bytes are going to be read in a later call). - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def write(self, buf: bytes, /) -> int: - """ - Write the bytes from *buf* to the bus. Checks that an ACK is received - after each byte and stops transmitting the remaining bytes if a NACK is - received. The function returns the number of ACKs that were received. - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def readfrom(self, addr: int, nbytes: int, stop: bool = True, /) -> bytes: - """ - Read *nbytes* from the slave specified by *addr*. - If *stop* is true then a STOP condition is generated at the end of the transfer. - Returns a `bytes` object with the data read. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def readfrom_into(self, addr: int, buf: bytes, stop: bool = True, /) -> None: - """ - Read into *buf* from the slave specified by *addr*. - The number of bytes read will be the length of *buf*. - If *stop* is true then a STOP condition is generated at the end of the transfer. - - The method returns ``None``. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def writeto(self, addr: int, buf: bytes, stop: bool = True, /) -> int: - """ - Write the bytes from *buf* to the slave specified by *addr*. If a - NACK is received following the write of a byte from *buf* then the - remaining bytes are not sent. If *stop* is true then a STOP condition is - generated at the end of the transfer, even if a NACK is received. - The function returns the number of ACKs that were received. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def writevto( - self, - addr: int, - vector: Sequence[bytes], - stop: bool = True, - / - ) -> int: - """ - Write the bytes contained in *vector* to the slave specified by *addr*. - *vector* should be a tuple or list of objects with the buffer protocol. - The *addr* is sent once and then the bytes from each object in *vector* - are written out sequentially. The objects in *vector* may be zero bytes - in length in which case they don't contribute to the output. - - If a NACK is received following the write of a byte from one of the - objects in *vector* then the remaining bytes, and any remaining objects, - are not sent. If *stop* is true then a STOP condition is generated at - the end of the transfer, even if a NACK is received. The function - returns the number of ACKs that were received. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def readfrom_mem(self, addr: int, memaddr: int, nbytes: int, /, *, addrsize: int = 8) -> bytes: - """ - Read *nbytes* from the slave specified by *addr* starting from the memory - address specified by *memaddr*. - The argument *addrsize* specifies the address size in bits. - Returns a `bytes` object with the data read. - - - Memory operations - ----------------- - - Some I2C devices act as a memory device (or set of registers) that can be read - from and written to. In this case there are two addresses associated with an - I2C transaction: the slave address and the memory address. The following - methods are convenience functions to communicate with such devices. - """ - ... - - def readfrom_mem_into( - self, - addr: int, - memaddr: int, - buf: bytes, - /, - *, - addrsize: int = 8 - ) -> None: - """ - Read into *buf* from the slave specified by *addr* starting from the - memory address specified by *memaddr*. The number of bytes read is the - length of *buf*. - The argument *addrsize* specifies the address size in bits (on ESP8266 - this argument is not recognised and the address size is always 8 bits). - - The method returns ``None``. - - - Memory operations - ----------------- - - Some I2C devices act as a memory device (or set of registers) that can be read - from and written to. In this case there are two addresses associated with an - I2C transaction: the slave address and the memory address. The following - methods are convenience functions to communicate with such devices. - """ - ... - - def writeto_mem(self, addr: int, memaddr: int, buf: bytes, /, *, addrsize: int = 8) -> None: - """ - Write *buf* to the slave specified by *addr* starting from the - memory address specified by *memaddr*. - The argument *addrsize* specifies the address size in bits (on ESP8266 - this argument is not recognised and the address size is always 8 bits). - - The method returns ``None``. - - Memory operations - ----------------- - - Some I2C devices act as a memory device (or set of registers) that can be read - from and written to. In this case there are two addresses associated with an - I2C transaction: the slave address and the memory address. The following - methods are convenience functions to communicate with such devices. - """ - ... - - -class I2S(): - """ - I2S is a synchronous serial protocol used to connect digital audio devices. - At the physical level, a bus consists of 3 lines: SCK, WS, SD. The I2S class - supports controller operation. Peripheral operation is not supported. - - The I2S class is currently available as a Technical Preview. During the preview - period, feedback from users is encouraged. Based on this feedback, the I2S class - API and implementation may be changed. - """ - - def __init__(self, *argv, **kwargs) -> None: - """ - Construct an I2S object of the given id: - - id identifies a particular I2S bus; it is board and port specific - - Keyword-only parameters that are supported on all ports: - - - `sck` is a pin object for the serial clock line - - - `ws` is a pin object for the word select line - - - `sd` is a pin object for the serial data line - - - `mck` is a pin object for the master clock line; master clock frequency is sampling rate * 256 - - - `mode` specifies receive or transmit - - - `bits` specifies sample size (bits), 16 or 32 - - - `format` specifies channel format, STEREO or MONO - - - `rate` specifies audio sampling rate (Hz); this is the frequency of the ws signal - - - `ibuf` specifies internal buffer length (bytes) - """ - ... - - def readinto(self, buf) -> int: - """ - Read audio samples into the buffer specified by `buf`. `buf` must - support the buffer protocol, such as bytearray or array. "buf" - byte ordering is little-endian. For Stereo format, left channel - sample precedes right channel sample. For Mono format, the left - channel sample data is used. Returns number of bytes read - """ - ... - - def write(self, buf) -> int: - """ - Write audio samples contained in `buf`. `buf` must support the buffer protocol, - such as bytearray or array. “buf” byte ordering is little-endian. For Stereo - format, left channel sample precedes right channel sample. For Mono format, - the sample data is written to both the right and left channels. - Returns number of bytes written - """ - ... - - MONO = 0 # type: int - RX = 0 # type: int - STEREO = 1 # type: int - TX = 1 # type: int - - def deinit(self, *args, **kwargs) -> Any: - """Deinitialize the I2S bus""" - ... - - def init(self, *args, **kwargs) -> Any: - ... - - def irq(self, handler) -> Any: - """ - Set a callback. `handler` is called when `buf` is - emptied (`write` method) or becomes full - (`readinto` method). Setting a callback changes - the `write` and `readinto` methods to non-blocking - operation. `handler` is called in the context - of the MicroPython scheduler. - """ - ... - - def shift(self, buf, bits, shift: int) -> Any: - """ - bitwise shift of all samples contained in `buf`. `bits` - specifies sample size in bits. `shift` specifies the number - of bits to shift each sample. Positive for left shift, - negative for right shift. Typically used for volume control. - Each bit shift changes sample volume by 6dB. - """ - ... - - -class PWM: - """ - Pulse width modulation (PWM), allows you to give analogue behaviours to digital - devices, such as LEDs. This means that rather than an LED being simply on or - off, you can control its brightness. - - Example usage:: - - from machine import PWM - - pwm = PWM(pin) # create a PWM object on a pin - pwm.duty_u16(32768) # set duty to 50% - - # reinitialise with a period of 200us, duty of 5us - pwm.init(freq=5000, duty_ns=5000) - - pwm.duty_ns(3000) # set pulse width to 3us - - pwm.deinit() - """ - - def __init__(self, pin: Pin): - """ - Construct and return a new PWM object using the following parameters: - - - *pin* should be the pin to use. - """ - ... - - def deinit(self) -> None: - """ - Disable the PWM output. - """ - ... - - def freq(self, frequency: Optional[int]=...): - """ - With no arguments the frequency in Hz is returned. - - With a single *value* argument the frequency is set to that value in Hz. The method may raise a ``ValueError`` if the frequency is outside the valid range. - """ - ... - - def duty_u16(self, duration: Optional[int]=...): - """ - Get or Set the current duty cycle of the PWM output, as an unsigned 16-bit value in the range 0 to 65535 inclusive. - - With no arguments the duty cycle is returned. - - With a single *value* argument the duty cycle is set to that value, measured as the ratio ``value / 65535``. - """ - ... - - def duty_ns(self, duration: Optional[int]=...): - """ - Get or Set the current pulse width of the PWM output, as a value in nanoseconds. - - With no arguments the pulse width in nanoseconds is returned. - - With a single *value* argument the pulse width is set to that value. - """ - ... - - -class Signal: - """ - The ``Signal`` class is a simple extension of the ``Pin`` class. Unlike Pin, which can - be only in “absolute” 0 and 1 states, a Signal can be in “asserted” (on) or - “deasserted” (off) states, while being inverted (active-low) or not. - - In other words, it adds logical inversion support to Pin functionality. - - While this may seem a simple addition, it is exactly what is needed to support - wide array of simple digital devices in a way portable across different boards, - which is one of the major MicroPython goals. - - Regardless of whether different users have an active-high or active-low LED, a - normally open or normally closed relay - you can develop a single, nicely looking - application which works with each of them, and capture hardware configuration - differences in few lines in the config file of your app. - """ - - @overload - def __init__(self, pin_obj: Pin, invert: bool = False): - """ - Create a ``Signal`` object by wrapping existing ``Pin`` object. - """ - ... - - @overload - def __init__(self, id: Union[int, str], /, mode: int = Pin.IN, pull: int = Pin.PULL_UP, af: Union[str, int] = -1, invert: bool = False): - """ - Create a ``Signal`` object by passing required ``Pin`` parameters directly - to ``Signal`` constructor, skipping the need to create intermediate ``Pin`` object. - """ - ... - - def off(self): - """ - Deactivate signal. - """ - ... - - def on(self): - """ - Activate signal. - """ - ... - - def value(self, x: Any): - """ - This method allows to set and get the value of the signal, depending on whether - the argument ``x`` is supplied or not. - - If the argument is omitted then this method gets the signal level, ``1`` meaning signal - is asserted (active) and ``0`` meaning signal inactive. - - If the argument is supplied then this method sets the signal level. The argument ``x`` can - be anything that converts to a boolean. If it converts to ``True``, the signal is active, - otherwise it is inactive. - - Correspondence between signal being active and actual logic level on the underlying pin - depends on whether signal is inverted (active-low) or not. For non-inverted signal, - active status corresponds to logical ``1``, inactive to logical ``0``. For - inverted/active-low signal, active status corresponds to logical ``0``, while inactive - corresponds to logical ``1``. - """ - ... - - -class SoftI2C: - """ - I2C is a two-wire protocol for communicating between devices. At the physical - level it consists of 2 wires: SCL and SDA, the clock and data lines respectively. - - I2C objects are created attached to a specific bus. They can be initialised - when created, or initialised later on. - - Printing the I2C object gives you information about its configuration. - - Both hardware and software I2C implementations exist via the - :ref:`machine.I2C ` and `machine.SoftI2C` classes. Hardware I2C uses - underlying hardware support of the system to perform the reads/writes and is - usually efficient and fast but may have restrictions on which pins can be used. - Software I2C is implemented by bit-banging and can be used on any pin but is not - as efficient. These classes have the same methods available and differ primarily - in the way they are constructed. - """ - - def __init__(self, scl: Pin, sda: Pin, *, freq: int = 400_000, timeout: int = 50_000): - """ - Construct and return a new software I2C object using the following parameters: - - - *scl* should be a pin object specifying the pin to use for SCL. - - *sda* should be a pin object specifying the pin to use for SDA. - - *freq* should be an integer which sets the maximum frequency - for SCL. - - *timeout* is the maximum time in microseconds to wait for clock - stretching (SCL held low by another device on the bus), - after which an `OSError(ETIMEDOUT)` exception is raised. - """ - ... - - def init(self, scl: Pin, sda: Pin, *, freq: int = 400_000, timeout: int = 50_000) -> None: - """ - Initialise the I2C bus with the given arguments: - - - *scl* is a pin object for the SCL line - - *sda* is a pin object for the SDA line - - *freq* is the SCL clock rate - """ - ... - - def scan(self) -> list[int]: - """ - Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of - those that respond. A device responds if it pulls the SDA line low after - its address (including a write bit) is sent on the bus. - """ - ... - - def start(self) -> None: - """ - Generate a START condition on the bus (SDA transitions to low while SCL is high). - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def stop(self) -> None: - """ - Generate a STOP condition on the bus (SDA transitions to high while SCL is high). - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def readinto(self, buf: bytes, nack: bool = True, /) -> None: - """ - Reads bytes from the bus and stores them into *buf*. The number of bytes - read is the length of *buf*. An ACK will be sent on the bus after - receiving all but the last byte. After the last byte is received, if *nack* - is true then a NACK will be sent, otherwise an ACK will be sent (and in this - case the slave assumes more bytes are going to be read in a later call). - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def write(self, buf: bytes, /) -> int: - """ - Write the bytes from *buf* to the bus. Checks that an ACK is received - after each byte and stops transmitting the remaining bytes if a NACK is - received. The function returns the number of ACKs that were received. - - - Primitive I2C operations - ------------------------ - - The following methods implement the primitive I2C master bus operations and can - be combined to make any I2C transaction. They are provided if you need more - control over the bus, otherwise the standard methods (see below) can be used. - - These methods are only available on the `machine.SoftI2C` class. - """ - ... - - def readfrom(self, addr: int, nbytes: int, stop: bool = True, /) -> bytes: - """ - Read *nbytes* from the slave specified by *addr*. - If *stop* is true then a STOP condition is generated at the end of the transfer. - Returns a `bytes` object with the data read. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def readfrom_into(self, addr: int, buf: bytes, stop: bool = True, /) -> None: - """ - Read into *buf* from the slave specified by *addr*. - The number of bytes read will be the length of *buf*. - If *stop* is true then a STOP condition is generated at the end of the transfer. - - The method returns ``None``. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def writeto(self, addr: int, buf: bytes, stop: bool = True, /) -> int: - """ - Write the bytes from *buf* to the slave specified by *addr*. If a - NACK is received following the write of a byte from *buf* then the - remaining bytes are not sent. If *stop* is true then a STOP condition is - generated at the end of the transfer, even if a NACK is received. - The function returns the number of ACKs that were received. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def writevto( - self, - addr: int, - vector: Sequence[bytes], - stop: bool = True, - / - ) -> int: - """ - Write the bytes contained in *vector* to the slave specified by *addr*. - *vector* should be a tuple or list of objects with the buffer protocol. - The *addr* is sent once and then the bytes from each object in *vector* - are written out sequentially. The objects in *vector* may be zero bytes - in length in which case they don't contribute to the output. - - If a NACK is received following the write of a byte from one of the - objects in *vector* then the remaining bytes, and any remaining objects, - are not sent. If *stop* is true then a STOP condition is generated at - the end of the transfer, even if a NACK is received. The function - returns the number of ACKs that were received. - - - Standard bus operations - ----------------------- - - The following methods implement the standard I2C master read and write - operations that target a given slave device. - """ - ... - - def readfrom_mem(self, addr: int, memaddr: int, nbytes: int, /, *, addrsize: int = 8) -> bytes: - """ - Read *nbytes* from the slave specified by *addr* starting from the memory - address specified by *memaddr*. - The argument *addrsize* specifies the address size in bits. - Returns a `bytes` object with the data read. - - - Memory operations - ----------------- - - Some I2C devices act as a memory device (or set of registers) that can be read - from and written to. In this case there are two addresses associated with an - I2C transaction: the slave address and the memory address. The following - methods are convenience functions to communicate with such devices. - """ - ... - - def readfrom_mem_into( - self, - addr: int, - memaddr: int, - buf: bytes, - /, - *, - addrsize: int = 8 - ) -> None: - """ - Read into *buf* from the slave specified by *addr* starting from the - memory address specified by *memaddr*. The number of bytes read is the - length of *buf*. - The argument *addrsize* specifies the address size in bits (on ESP8266 - this argument is not recognised and the address size is always 8 bits). - - The method returns ``None``. - - - Memory operations - ----------------- - - Some I2C devices act as a memory device (or set of registers) that can be read - from and written to. In this case there are two addresses associated with an - I2C transaction: the slave address and the memory address. The following - methods are convenience functions to communicate with such devices. - """ - ... - - def writeto_mem(self, addr: int, memaddr: int, buf: bytes, /, *, addrsize: int = 8) -> None: - """ - Write *buf* to the slave specified by *addr* starting from the - memory address specified by *memaddr*. - The argument *addrsize* specifies the address size in bits (on ESP8266 - this argument is not recognised and the address size is always 8 bits). - - The method returns ``None``. - - Memory operations - ----------------- - - Some I2C devices act as a memory device (or set of registers) that can be read - from and written to. In this case there are two addresses associated with an - I2C transaction: the slave address and the memory address. The following - methods are convenience functions to communicate with such devices. - """ - ... - - -class Timer: - """ - Hardware timers deal with timing of periods and events. Timers are perhaps - the most flexible and heterogeneous kind of hardware in MCUs and SoCs, - differently greatly from a model to a model. MicroPython's Timer class - defines a baseline operation of executing a callback with a given period - (or once after some delay), and allow specific boards to define more - non-standard behavior (which thus won't be portable to other boards). - - See discussion of :ref:`important constraints ` on - Timer callbacks. - - .. note:: - - Memory can't be allocated inside irq handlers (an interrupt) and so - exceptions raised within a handler don't give much information. See - :func:`micropython.alloc_emergency_exception_buf` for how to get around this - limitation. - - If you are using a WiPy board please refer to :ref:`machine.TimerWiPy ` - instead of this class. - """ - - ONE_SHOT: ClassVar[int] = ... - """ - Timer operating mode. - """ - - PERIODIC: ClassVar[int] = ... - """ - Timer operating mode. - """ - - def __init__( - self, - id: Optional[int] = None, - /, - *, - mode: int = PERIODIC, - freq: Optional[float] = None, - period: int = -1, - callback: Optional[Callable[["Timer"], None]] = None, - ): - """ - Construct a new timer object of the given id. Id of -1 constructs a - virtual timer (if supported by a board). - - See ``init`` for parameters of initialisation. - """ - ... - - def init( - self, - *, - mode: int = PERIODIC, - freq: Optional[float] = None, - period: int = -1, - callback: Optional[Callable[["Timer"], None]] = None, - ) -> None: - """ - Initialise the timer. Example:: - - # periodic with 100ms period - tim.init(period=100) - # one shot firing after 1000ms - tim.init(mode=Timer.ONE_SHOT, period=1000) - - Keyword arguments: - - - ``mode`` can be one of: - - - ``Timer.ONE_SHOT`` - The timer runs once until the configured - period of the channel expires. - - ``Timer.PERIODIC`` - The timer runs periodically at the configured - frequency of the channel. - """ - ... - - def deinit(self) -> None: - """ - Deinitialises the timer. Stops the timer, and disables the timer peripheral. - """ - ... - - -class UART: - """ - UART implements the standard UART/USART duplex serial communications protocol. At - the physical level it consists of 2 lines: RX and TX. The unit of communication - is a character (not to be confused with a string character) which can be 8 or 9 - bits wide. - """ - - CTS = 1 # type: int - INV_RX = 2 # type: int - INV_TX = 1 # type: int - RTS = 2 # type: int - - def __init__(self, id: int, baudrate: int = 9600, bits: int = 8, parity: Optional[int] = None, stop: int = 1, tx: Optional[Pin] = None, rx: Optional[Pin] = None): - """ - Construct a UART object of the given id and initialise the UART - bus with the given parameters: - - - *baudrate* is the clock rate. - - *bits* is the number of bits per character, 7, 8 or 9. - - *parity* is the parity, ``None``, 0 (even) or 1 (odd). - - *stop* is the number of stop bits, 1 or 2. - - *tx* specifies the TX pin to use. - - *rx* specifies the RX pin to use. - """ - ... - - def deinit(self) -> None: - """ - Turn off the UART bus. - - Note: - You will not be able to call `init()` on the object - after `deinit()`. A new instance needs to be created - in that case. - """ - ... - - def init(self, baudrate: int = 9600, bits: int = 8, parity: Optional[int] = None, stop: int = 1, **kwargs) -> Any: - ... - - def any(self) -> int: - """ - Returns the number of bytes waiting (may be 0). - """ - ... - - def read(self, nbytes: Optional[int]=None) -> Optional[bytes]: - """ - Read characters. If ``nbytes`` is specified then read at most that many bytes. - If ``nbytes`` are available in the buffer, returns immediately, otherwise returns - when sufficient characters arrive or the timeout elapses. - - If ``nbytes`` is not given then the method reads as much data as possible. It - returns after the timeout has elapsed. - - *Note:* for 9 bit characters each character takes two bytes, ``nbytes`` must - be even, and the number of characters is ``nbytes/2``. - - Return value: a bytes object containing the bytes read in. Returns ``None`` - on timeout. - """ - ... - - def readinto(self, buf: bytes, nbytes: Optional[int]=None, /) -> Optional[int]: - """ - Read bytes into the ``buf``. If ``nbytes`` is specified then read at most - that many bytes. Otherwise, read at most ``len(buf)`` bytes. - - Return value: number of bytes read and stored into ``buf`` or ``None`` on - timeout. - """ - ... - - def readline(self) -> Optional[str]: - """ - Read a line, ending in a newline character. If such a line exists, return is - immediate. If the timeout elapses, all available data is returned regardless - of whether a newline exists. - - Return value: the line read or ``None`` on timeout if no data is available. - """ - ... - - def write(self, buf: bytes, /) -> Optional[int]: - """ - Write the buffer of bytes to the bus. If characters are 7 or 8 bits wide - then each byte is one character. If characters are 9 bits wide then two - bytes are used for each character (little endian), and ``buf`` must contain - an even number of bytes. - - Return value: number of bytes written. If a timeout occurs and no bytes - were written returns ``None``. - """ - ... - - def sendbreak(self) -> None: - """ - Send a break condition on the bus. This drives the bus low for a duration - of 13 bits. - Return value: ``None``. - """ - ... - - def flush(self) -> Any: - """ - Waits until all data has been sent. In case of a - timeout, an exception is raised. The timeout duration - depends on the tx buffer size and the baud rate. - Unless flow control is enabled, a timeout should - not occur. - - Note: - For the `rp2`, `esp8266` and `nrf` ports the call returns - while the last byte is sent. If required, a one character - wait time has to be added in the calling script. - """ - ... - - def txdone(self) -> bool: - """ - Tells whether all data has been sent or no data transfer - is happening. In this case, it returns `True`. If a data - transmission is ongoing it returns False. - - Note: - For the `rp2`, `esp8266` and `nrf` ports the call may - return `True` even if the last byte of a transfer is still - being sent. If required, a one character wait time has to be - added in the calling script. - """ - ... - - -class WDT: - """ - The WDT is used to restart the system when the application crashes and ends - up into a non recoverable state. Once started it cannot be stopped or - reconfigured in any way. After enabling, the application must "feed" the - watchdog periodically to prevent it from expiring and resetting the system. - - Example usage:: - - from machine import WDT - wdt = WDT(timeout=2000) # enable it with a timeout of 2s - wdt.feed() - - Availability of this class: pyboard, WiPy, esp8266, esp32, rp2. - """ - - def __init__(self, *, id: int = 0, timeout: int = 5000): - """ - Create a WDT object and start it. The timeout must be given in milliseconds. - Once it is running the timeout cannot be changed and the WDT cannot be stopped either. - """ - ... - - def feed(self) -> None: - """ - Feed the WDT to prevent it from resetting the system. The application - should place this call in a sensible place ensuring that the WDT is - only fed after verifying that everything is functioning correctly. - """ - ... - - -WDT_RESET = 3 - - -def bootloader() -> NoReturn: - """ - Activate the bootloader. - """ - ... - - -def deepsleep(time_ms: Optional[int] = None) -> None: - """ - Stops execution in an attempt to enter a low power state. - - If *time_ms* is specified then this will be the maximum time in milliseconds that - the sleep will last for. Otherwise the sleep can last indefinitely. - - With or without a timeout, execution may resume at any time if there are events - that require processing. Such events, or wake sources, should be configured before - sleeping, like ``Pin`` change or ``RTC`` timeout. - - The precise behaviour and power-saving capabilities of deepsleep are - highly dependent on the underlying hardware, but the general properties are: - - * A deepsleep may not retain RAM or any other state of the system (for example - peripherals or network interfaces). Upon wake execution is resumed from the main - script, similar to a hard or power-on reset. The `reset_cause()` function will - return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake - from other resets. - """ - ... - - -def lightsleep(time_ms: Optional[int] = None) -> None: - """ - Stops execution in an attempt to enter a low power state. - - If *time_ms* is specified then this will be the maximum time in milliseconds that - the sleep will last for. Otherwise the sleep can last indefinitely. - - With or without a timeout, execution may resume at any time if there are events - that require processing. Such events, or wake sources, should be configured before - sleeping, like ``Pin`` change or ``RTC`` timeout. - - The precise behaviour and power-saving capabilities of lightsleep are - highly dependent on the underlying hardware, but the general properties are: - - * A lightsleep has full RAM and state retention. Upon wake execution is resumed - from the point where the sleep was requested, with all subsystems operational. - """ - ... - - -def freq(): - """ - Returns CPU frequency in hertz. - """ - ... - - -def disable_irq() -> int: - """ - Disable interrupt requests. - Returns the previous IRQ state which should be considered an opaque value. - This return value should be passed to the ``enable_irq()`` function to restore - interrupts to their original state, before ``disable_irq()`` was called. - """ - ... - - -def enable_irq(state: int): - """ - Re-enable interrupt requests. - The *state* parameter should be the value that was returned from the most - recent call to the ``disable_irq()`` function. - """ - ... - - -def idle(): - """ - Gates the clock to the CPU, useful to reduce power consumption at any time during - short or long periods. Peripherals continue working and execution resumes as soon - as any interrupt is triggered (on many ports this includes system timer - interrupt occurring at regular intervals on the order of millisecond). - """ - ... - -class mem: - """Don't use this class/type! It's only for type annotations. And does not exist at runtime!""" - def __getitem__(self, address: int) -> int: ... - def __setitem__(self, address: int, value: int) -> None: ... - -mem16: mem -"""Read/write 16 bits of memory. - -Use subscript notation `[...]` to index these objects with the address of interest. -Note that the address is the byte address, regardless of the size of memory being accessed. -""" - -mem32: mem -"""Read/write 32 bits of memory. - -Use subscript notation `[...]` to index these objects with the address of interest. -Note that the address is the byte address, regardless of the size of memory being accessed. -""" - -mem8: mem -"""Read/write 8 bits of memory. - -Use subscript notation `[...]` to index these objects with the address of interest. -Note that the address is the byte address, regardless of the size of memory being accessed. -""" - -def reset(): - """ - Resets the device in a manner similar to pushing the external RESET - button. - """ - ... - - -def reset_cause(): - """ - Get the reset cause. - """ - ... - - -def soft_reset(): - """ - Performs a soft reset of the interpreter, deleting all Python objects and - resetting the Python heap. It tries to retain the method by which the user - is connected to the MicroPython REPL (eg serial, USB, Wifi). - """ - ... - - -def time_pulse_us(pin: Pin, pulse_level: int, timeout_us: int = 1000000, /) -> int: - """ - Time a pulse on the given *pin*, and return the duration of the pulse in - microseconds. The *pulse_level* argument should be 0 to time a low pulse - or 1 to time a high pulse. - - If the current input value of the pin is different to *pulse_level*, - the function first (*) waits until the pin input becomes equal to *pulse_level*, - then (**) times the duration that the pin is equal to *pulse_level*. - If the pin is already equal to *pulse_level* then timing starts straight away. - - The function will return -2 if there was timeout waiting for condition marked - (*) above, and -1 if there was timeout during the main measurement, marked (**) - above. The timeout is the same for both cases and given by *timeout_us* (which - is in microseconds). - """ - ... - - -def unique_id() -> str: - """ - Returns a byte string with a unique identifier of a board/SoC. It will vary - from a board/SoC instance to another, if underlying hardware allows. Length - varies by hardware (so use substring of a full value if you expect a short - ID). In some MicroPython ports, ID corresponds to the network MAC address. - """ - ... - - -############### -# NOTE: added # - - -def dht_readinto(*args, **kwargs) -> Any: - """ - Reads the temperature and humidity from the DHT sensor. - - (this function is also the redirection target of dth.dth_readinto() on the rp2040) - """ - ... diff --git a/stubs/stubs/urequests/urequests.pyi b/stubs/stubs/urequests/urequests.pyi deleted file mode 100644 index f82f668..0000000 --- a/stubs/stubs/urequests/urequests.pyi +++ /dev/null @@ -1,79 +0,0 @@ -""" -Module: 'urequests' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any, Union, Optional - -def get(url: str, **kwargs) -> Any: - ... - -def put(url: str, **kwargs) -> Any: - ... - - -class Response(): - def __init__(self, f) -> None: - ... - - def close(self) -> None: - ... - - @property - def status_code(self) -> Optional[int]: - """The status code of the response. Defaults to `None`""" - ... - - @property - def encoding(self) -> Optional[str]: - """The encoding of the response content. Defaults to `utf-8`""" - ... - - @property - def reason(self) -> Optional[bytes]: - """Like string representation of the status_code in bytes form. Defaults to `None`""" - ... - - @property - def headers(self) -> Optional[dict[str, str]]: - """The response headers. Defaults to `None`""" - ... - - @property - def text(self) -> Optional[str]: - ... - - def json(self) -> Optional[str]: - """requires `ujson` module""" - ... - - @property - def content(self) -> Optional[bytes]: - """The response content in bytes. Defaults to `None`""" - ... - -def request( - method: str, - url: str, - data=None, - json=None, - headers={}, - stream=None, - auth=None, - timeout=None, - parse_headers: bool=True, - ) -> Optional[Response]: - """Could raise at least NotImplementedError, ValueError and OSErro""" - ... - -def head(url: str, **kwargs) -> Any: - ... - -def post(url: str, **kwargs) -> Any: - ... - -def patch(url: str, **kwargs) -> Any: - ... - -def delete(url: str, **kwargs) -> Any: - ... - diff --git a/stubs/stubs/uwebsocket/uwebsocket.pyi b/stubs/stubs/uwebsocket/uwebsocket.pyi deleted file mode 100644 index c5a595a..0000000 --- a/stubs/stubs/uwebsocket/uwebsocket.pyi +++ /dev/null @@ -1,27 +0,0 @@ -""" -Module: 'uwebsocket' on micropython-v1.19.1-rp2 -""" -# MCU: {'ver': 'v1.19.1', 'build': '', 'sysname': 'rp2', 'platform': 'rp2', 'version': '1.19.1', 'release': '1.19.1', 'port': 'rp2', 'family': 'micropython', 'name': 'micropython', 'machine': 'Raspberry Pi Pico W with RP2040', 'nodename': 'rp2'} -from typing import Any - -class websocket(): - def __init__(self, *argv, **kwargs) -> None: - ... - - def close(self, *args, **kwargs) -> Any: - ... - - def read(self, *args, **kwargs) -> Any: - ... - - def readinto(self, *args, **kwargs) -> Any: - ... - - def readline(self, *args, **kwargs) -> Any: - ... - - def write(self, *args, **kwargs) -> Any: - ... - - def ioctl(self, *args, **kwargs) -> Any: - ... diff --git a/stubs/stubs/websocket/websocket.pyi b/stubs/stubs/websocket/websocket.pyi deleted file mode 100644 index c4b5b37..0000000 --- a/stubs/stubs/websocket/websocket.pyi +++ /dev/null @@ -1 +0,0 @@ -from uwebsocket import * diff --git a/stubs/version.json b/stubs/version.json deleted file mode 100644 index b1742eb..0000000 --- a/stubs/version.json +++ /dev/null @@ -1 +0,0 @@ -{"version": "1.21.0"} \ No newline at end of file