From 761bd6e6b45bffbf919302ba2e1f1c0066a1ac44 Mon Sep 17 00:00:00 2001 From: Nick Crews Date: Sat, 24 Apr 2021 14:56:55 -0600 Subject: [PATCH] Add stubs for `docopt` package (#5248) * Add stubs for `docopt` package Add the single stub for the simple, but fairly well-used [docopt](https://github.com/docopt/docopt) package. It looks like that project is not very well maintained, so I thought it would be easier to add the type annotations here, as opposed to there, upstream. This has even been requested a few times in https://github.com/docopt/docopt/issues/471. It appeared to me that only the `docopt()` function is the public API, so I didn't include the rest of the module's functions and attributes. --- stubs/docopt/METADATA.toml | 3 +++ stubs/docopt/docopt.pyi | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 stubs/docopt/METADATA.toml create mode 100644 stubs/docopt/docopt.pyi diff --git a/stubs/docopt/METADATA.toml b/stubs/docopt/METADATA.toml new file mode 100644 index 000000000..c7567c225 --- /dev/null +++ b/stubs/docopt/METADATA.toml @@ -0,0 +1,3 @@ +# Prior to v0.6, docopt() had only 3 optional args +version = "0.6" +python2 = true \ No newline at end of file diff --git a/stubs/docopt/docopt.pyi b/stubs/docopt/docopt.pyi new file mode 100644 index 000000000..15c7f7d08 --- /dev/null +++ b/stubs/docopt/docopt.pyi @@ -0,0 +1,13 @@ +from typing import Any, Iterable, Optional, Union + +__version__: str + +_Argv = Union[Iterable[str], str] + +def docopt( + doc: str, + argv: Optional[_Argv] = ..., + help: bool = ..., + version: Optional[Any] = ..., + options_first: bool = ..., +) -> dict[str, Any]: ... # Really should be dict[str, Union[str, bool]]