pax_global_header00006660000000000000000000000064150455205510014514gustar00rootroot0000000000000052 comment=ac46c10e229f1fc570600a14a644238b86ae4f99 pybind-pybind11-stubgen-ac46c10/000077500000000000000000000000001504552055100164765ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/.git-blame-ignore-revs000066400000000000000000000001221504552055100225710ustar00rootroot00000000000000ea663c34775284590aef5cf1d087fc1840edb027 abb3085624a1e982f360086b73686b8b32e47087 pybind-pybind11-stubgen-ac46c10/.github/000077500000000000000000000000001504552055100200365ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/.github/workflows/000077500000000000000000000000001504552055100220735ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/.github/workflows/ci.yml000066400000000000000000000156271504552055100232240ustar00rootroot00000000000000name: CI on: workflow_dispatch: pull_request: push: branches: - master tags: - 'v*' jobs: format: name: Format code runs-on: ubuntu-latest steps: - name: Setup Python 3.13 uses: actions/setup-python@v5 with: python-version: "3.13" - name: Checkout uses: actions/checkout@v4 - name: Install requirements run: pip install -r requirements-dev.txt - name: Run isort run: isort --check --profile=black --diff ./pybind11_stubgen if: ${{ failure() || success() }} - name: Run black run: black --diff ./pybind11_stubgen if: ${{ failure() || success() }} - name: Run flake8 run: | flake8 \ --max-line-length=88 \ --extend-ignore=E203 \ --extend-exclude=venv/,.pytest_cache/,.ipynb_checkpoints/,tests/,tmp/,build/ if: ${{ failure() || success() }} tests: name: "Test 🐍 ${{ matrix.python }} β€’ pybind-${{ matrix.pybind11-branch }} β€’ ${{ matrix.numpy-format }}" runs-on: ubuntu-latest strategy: fail-fast: false matrix: pybind11-branch: - "v2.13" python: - "3.13" - "3.12" - "3.11" - "3.10" - "3.9" - "3.8" numpy-format: - "numpy-array-wrap-with-annotated" include: - python: "3.13" pybind11-branch: "v2.9" numpy-format: "numpy-array-wrap-with-annotated" - python: "3.13" pybind11-branch: "v2.11" numpy-format: "numpy-array-wrap-with-annotated" - python: "3.13" pybind11-branch: "v2.12" numpy-format: "numpy-array-wrap-with-annotated" - python: "3.13" pybind11-branch: "v2.13" numpy-format: "numpy-array-use-type-var" # # TODO: uncomment # - python: "3.13" # pybind11-branch: "master" steps: - uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - name: Update CMake uses: jwlawson/actions-setup-cmake@v2 with: # https://github.com/pybind/pybind11/blob/914c06fb252b6cc3727d0eedab6736e88a3fcb01/CMakeLists.txt#L13C34-L13C38 cmake-version: '3.22.x' - name: Setup annotations on Linux if: runner.os == 'Linux' run: python -m pip install pytest-github-actions-annotate-failures - name: Install requirements run: pip install -r "./tests/stubs/python-${{ matrix.python }}/requirements.txt" - name: Install pybind11-stubgen run: pip install . - name: Install demo module shell: bash run: ./tests/install-demo-module.sh --pybind11-branch "${{ matrix.pybind11-branch }}" - name: Check stubs generation shell: bash run: ./tests/check-demo-stubs-generation.sh --stubs-sub-dir "stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}/${{ matrix.numpy-format }}" --${{ matrix.numpy-format }} - name: Archive patch uses: actions/upload-artifact@v4 if: failure() with: name: "python-${{ matrix.python }}-pybind-${{ matrix.pybind11-branch }}-${{ matrix.numpy-format }}.patch" path: "./tests/stubs/python-${{ matrix.python }}/pybind11-${{ matrix.pybind11-branch }}/${{ matrix.numpy-format }}.patch" retention-days: 30 if-no-files-found: ignore - name: Check error generation shell: bash run: ./tests/check-demo-errors-generation.sh test-cli-options: name: "Runs on 🐍 ${{ matrix.python }} β€’ ${{ matrix.test-package }}" runs-on: ubuntu-latest strategy: fail-fast: false matrix: test-package: [ "gemmi" ] python: - "3.13" - "3.12" - "3.11" - "3.10" - "3.9" - "3.8" steps: - uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - name: Setup annotations on Linux if: runner.os == 'Linux' run: python -m pip install pytest-github-actions-annotate-failures - name: Install pybind11-stubgen run: pip install . - name: "Install ${{ matrix.test-package }}" shell: bash run: pip install "${{ matrix.test-package }}" - name: Generate stubs shell: bash run: | pybind11-stubgen "${{ matrix.test-package }}" -o flavour-1 --numpy-array-wrap-with-annotated pybind11-stubgen "${{ matrix.test-package }}" -o flavour-2 --numpy-array-remove-parameters pybind11-stubgen "${{ matrix.test-package }}" -o flavour-3 --print-invalid-expressions-as-is pybind11-stubgen "${{ matrix.test-package }}" -o flavour-4 --numpy-array-use-type-var pybind11-stubgen "${{ matrix.test-package }}" --dry-run publish: name: Publish distribution needs : [format, tests, test-cli-options] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Python 3.13 uses: actions/setup-python@v2 with: python-version: "3.13" - name: Build dist run: pipx run build --sdist --wheel - uses: actions/upload-artifact@v4 with: path: | dist/*.tar.gz dist/*.whl - uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} pybind-pybind11-stubgen-ac46c10/.gitignore000066400000000000000000000067511504552055100204770ustar00rootroot00000000000000# Created by https://www.toptal.com/developers/gitignore/api/c++,cmake,python # Edit at https://www.toptal.com/developers/gitignore?templates=c++,cmake,python ### C++ ### # Prerequisites *.d # Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll # Fortran module files *.mod *.smod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app ### CMake ### CMakeLists.txt.user CMakeCache.txt CMakeFiles CMakeScripts Testing Makefile cmake_install.cmake install_manifest.txt compile_commands.json CTestTestfile.cmake _deps ### CMake Patch ### # External projects *-prefix/ ### Python ### # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ cover/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder .pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more # commonly ignored for libraries. # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control #poetry.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ # pytype static type analyzer .pytype/ # Cython debug symbols cython_debug/ # PyCharm # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ # End of https://www.toptal.com/developers/gitignore/api/c++,cmake,python # VS Code .vscode/ tmp *.patch *.zip pybind-pybind11-stubgen-ac46c10/.pre-commit-config.yaml000066400000000000000000000015721504552055100227640ustar00rootroot00000000000000repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.3.0" hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - id: no-commit-to-branch - repo: local hooks: - id: black name: black entry: black language: python minimum_pre_commit_version: 2.9.2 require_serial: true types_or: [ python, pyi ] - id: isort name: isort entry: isort args: - --profile=black language: system types: [ python ] stages: [ commit ] - id: flake8 name: flake8 exclude: ^(tests)/ language: system entry: flake8 args: # The line length in black - --max-line-length=88 - --extend-ignore=E203 types: [ python ] stages: [ commit ] pybind-pybind11-stubgen-ac46c10/CHANGELOG.md000066400000000000000000000144241504552055100203140ustar00rootroot00000000000000Changelog ========= Version 2.5.5 (Aug 10, 2025) -------------------------- Changes: - πŸ› Fix the type annotation for `__all__` (#261) by @sarlinpe - πŸ› Handle boolean numpy arrays (#260) by @sarlinpe - πŸ› Fix `qualname` prefix in pybind11 3.0.0 (#259) by @gentlegiantJGC Version 2.5.4 (May 14, 2025) -------------------------- Changes: - ✨ Add `argv` to `main()` to simplify use as a library (#252) by @gentlegiantJGC - πŸ› Improve package detection (#253) by @gentlegiantJGC Version 2.5.3 (Feb 24, 2025) -------------------------- Changes: - ✨ Ignore technical dunder Python 3.13 fields (`__static_attributes__` and `__firstlineno__`): (#243) by @nim65s - πŸ”§ CI: Drop Python 3.7, add Python 3.13 (#243) by @nim65s Version 2.5.2 (Feb 24, 2025) -------------------------- Yanked to CI failure, released as 2.5.3 Version 2.5.1 (Mar 26, 2024) -------------------------- Changes: - πŸ› Fixed: Missed numpy unsigned int types (#219) by @Yc7521 Version 2.5 (Mar 3, 2024) -------------------------- Changes: - πŸ› Fixed: Don't render pybind11 `KeysView`, `ValuesView`, `ItemsView` class definitions (#211) - πŸ› Fixed: Escape backslashes in stub output (#208) Version 2.4.2 (Nov 27, 2023) -------------------------- Changes: - πŸ” Revert #196 due to poor review Version 2.4.1 (Nov 25, 2023) -------------------------- Changes: - ✨ Automatically replace invalid enum expressions with corresponding valid expression & import (#196) contributed by @ringohoffman - πŸ› Fixed: do not remove `self` parameter annotation when types do not match (#195) contributed by @ringohoffman Version 2.4 (Nov 21, 2023) -------------------------- Changes: - ✨ Added `--numpy-array-use-type-var` flag which reformats the pybind11-generated `numpy.ndarray[numpy.float32[m, 1]]` annotation as `numpy.ndarray[tuple[M, Literal[1]], numpy.dtype[numpy.float32]]` contributed by @ringohoffman (#188) Version 2.3.7 (Nov 18, 2023) -------------------------- Changes: - πŸ› fix: Handle top-level list-like annotations as types (#183) Version 2.3.6 (Oct 24, 2023) -------------------------- Changes: - πŸ› fix: Missing `py::dtype` translation (#179) Version 2.3.5 (Oct 23, 2023) -------------------------- Changes: - πŸ› fix: Wrong import for lowercase `buffer` (#175), issue (#173) Version 2.3.4 (Oct 23, 2023) -------------------------- Changes: - πŸ› fix: Misleading warning that referred to ignored errors (#171) Version 2.3.3 (Oct 22, 2023) -------------------------- Changes: - πŸ› fix: The `typing.Annotated` does not exist in python < 3.9, use `typing_extensions` (#168) Version 2.3.2 (Oct 21, 2023) -------------------------- Changes: - πŸ› fix: Missing function name in error message (#165) Version 2.3.1 (Oct 21, 2023) -------------------------- Changes: - πŸ› fix: Crash on `None`-valued docstring of property getter (#161) Version 2.3 (Sep 27, 2023) -------------------------- Changes: - πŸ› fix: Inconsistent `--enum-class-locations` behaviour (#158) Version 2.2.2 (Sep 26, 2023) -------------------------- Changes: - πŸ› fix: Missing `-?` in eum representation regex Version 2.2.1 (Sep 23, 2023) -------------------------- Changes: - πŸ“ Update `--print-invalid-expressions-as-is` description Version 2.2 (Sep 20, 2023) -------------------------- Changes: - πŸ› Fix: Python literals as default arg rendered as `...` (#147) - ✨ Add `--print-safe-value-reprs=REGEX` CLI option to override the print-safe flag of Value (for custom default value representations provided via `pybind11::arg_v()`) (#147) - ✨ Add `--enum-class-locations=REGEX:LOC` CLI option to rewrite enum values as valid Python expressions with correct imports. (#147) ⚠️ This release detects more invalid expressions in bindings code. Previously Enum-like representations (e.g. ``) were always treated as non-printable values and were rendered as `...`. The invalid expressions should be acknowledged by `--enum-class-locations` or `--ignore-invalid-expressions`. Version 2.1 (Sep 6, 2023) -------------------------- Changes: - ✨ Add `--stub-extension` CLI option (#142) Version 2.0.2 (Sep 4, 2023) -------------------------- Changes: - πŸ› Fix: missing `isinstance` check (#138) Version 2.0.1 (Sep 2, 2023) -------------------------- Changes: - πŸ› Fix: missing subdirectories for top-level submodules (#136) Version 2.0 (Sep 1, 2023) -------------------------- Changes: - πŸ› Explicitly set encoding of stubs to utf-8 (#133) - πŸ› Fix value representation for collections with print-unsafe elements (#132) Version 2.0.dev1 (Sep 1, 2023) -------------------------- Changes: - πŸ› Fix missing remap of `numpy.ndarray.flags` (#128) - ✨ Process `scipy.sparse.*` types the same as `numpy.ndarray` with `--numpy-array-wrap-with-annotated` (#128) - ✨ Support dynamic array size with `--numpy-array-wrap-with-annotated` (#128) - ❗️ Renamed CLI argument `--numpy-array-wrap-with-annotated-fixed-size` to `--numpy-array-wrap-with-annotated` (#128) Version 1.2 (Aug 31, 2023) -------------------------- Changes: - πŸ› Fix compatibility with Python 3.7..3.9 (#124) - πŸ› Fix incorrect list of base classes (#123) - ✨ Replace `typing` collections with builtin types (e.g. `typing.List` -> `list`) according to [PEP 585](https://peps.python.org/pep-0585/) (#122) - ✨ Add missing translations of pybind types: `function` -> `Callable`, `object`/`handle` -> `typing.Any` (#121) - ✨ Support function-valued default arguments (#119) - πŸ› Fix missing properties docstrings (#118) Version 1.1 (Aug 30, 2023) -------------------------- Changes: - Added `--dry-run` CLI option to skip writing stubs stage (#114 ) Version 1.0-dev (Aug 29, 2023) ------------------------------ ⚠️ Project was rewritten from scratch for `1.x`. This allowed me to address some long-standing issues, but I might accidentally brake behaviour you relied on. Changes: - Updated CLI interface, some options were removed, please see `pybind11-stubgen --help` for details - Replaced regex-based signature parsing with more robust procedure which enables to produce partially degraded signatures - Added type parsing/replacing, including deeply annotated types - Support implicit imports required for static analysis - Add introspection of pure python functions - Support python 3.10+ only (temporarily) - Improved structure of test binary pybind module pybind-pybind11-stubgen-ac46c10/LICENSE000066400000000000000000000042311504552055100175030ustar00rootroot00000000000000Copyright (c) 2019 Sergei Izmailov , All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. You are under no obligation whatsoever to provide any bug fixes, patches, or upgrades to the features, functionality or performance of the source code ("Enhancements") to anyone; however, if you choose to make your Enhancements available either publicly, or directly to the author of this software, without imposing a separate written license agreement for such Enhancements, then you hereby grant the following license: a non-exclusive, royalty-free perpetual license to install, use, modify, prepare derivative works, incorporate into other computer software, distribute, and sublicense such enhancements or derivative works thereof, in binary and source code form. pybind-pybind11-stubgen-ac46c10/README.md000066400000000000000000000025351504552055100177620ustar00rootroot00000000000000[![pypi](https://img.shields.io/pypi/v/pybind11-stubgen.svg?logo=PyPI&logoColor=white)](https://pypi.org/project/pybind11-stubgen/) About ---- Static analysis tools and IDE usually struggle to understand python binary extensions. `pybind11-stubgen` generates [stubs](https://peps.python.org/pep-0561/) for python extensions to make them less opaque. While the CLI tool includes tweaks to target modules compiled specifically with [pybind11](https://github.com/pybind/pybind11) but it should work well with modules built with other libraries. ```bash # Install pip install pybind11-stubgen # Generate stubs for numpy pybind11-stubgen numpy ``` Usage ----- ``` pybind11-stubgen [-h] [-o OUTPUT_DIR] [--root-suffix ROOT_SUFFIX] [--ignore-invalid-expressions REGEX] [--ignore-invalid-identifiers REGEX] [--ignore-unresolved-names REGEX] [--ignore-all-errors] [--enum-class-locations REGEX:LOC] [--numpy-array-wrap-with-annotated| --numpy-array-use-type-var| --numpy-array-remove-parameters] [--print-invalid-expressions-as-is] [--print-safe-value-reprs REGEX] [--exit-code] [--stub-extension EXT] MODULE_NAME ``` pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/000077500000000000000000000000001504552055100216545ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/__init__.py000066400000000000000000000256261504552055100240000ustar00rootroot00000000000000from __future__ import annotations import importlib import logging import re from argparse import ArgumentParser, Namespace from collections.abc import Sequence from pathlib import Path from pybind11_stubgen.parser.interface import IParser from pybind11_stubgen.parser.mixins.error_handlers import ( IgnoreAllErrors, IgnoreInvalidExpressionErrors, IgnoreInvalidIdentifierErrors, IgnoreUnresolvedNameErrors, LogErrors, LoggerData, SuggestCxxSignatureFix, TerminateOnFatalErrors, ) from pybind11_stubgen.parser.mixins.filter import ( FilterClassMembers, FilterInvalidIdentifiers, FilterPybind11ViewClasses, FilterPybindInternals, FilterTypingModuleAttributes, ) from pybind11_stubgen.parser.mixins.fix import ( FixBuiltinTypes, FixCurrentModulePrefixInTypeNames, FixMissing__all__Attribute, FixMissing__future__AnnotationsImport, FixMissingEnumMembersAnnotation, FixMissingFixedSizeImport, FixMissingImports, FixMissingNoneHashFieldAnnotation, FixNumpyArrayDimAnnotation, FixNumpyArrayDimTypeVar, FixNumpyArrayFlags, FixNumpyArrayRemoveParameters, FixNumpyDtype, FixPEP585CollectionNames, FixPybind11EnumStrDoc, FixRedundantBuiltinsAnnotation, FixRedundantMethodsFromBuiltinObject, FixScipyTypeArguments, FixTypingTypeNames, FixValueReprRandomAddress, OverridePrintSafeValues, RemoveSelfAnnotation, ReplaceReadWritePropertyWithField, RewritePybind11EnumValueRepr, ) from pybind11_stubgen.parser.mixins.parse import ( BaseParser, ExtractSignaturesFromPybind11Docstrings, ParserDispatchMixin, ) from pybind11_stubgen.printer import Printer from pybind11_stubgen.structs import QualifiedName from pybind11_stubgen.writer import Writer class CLIArgs(Namespace): output_dir: str root_suffix: str ignore_invalid_expressions: re.Pattern | None ignore_invalid_identifiers: re.Pattern | None ignore_unresolved_names: re.Pattern | None ignore_all_errors: bool enum_class_locations: list[tuple[re.Pattern, str]] numpy_array_wrap_with_annotated: bool numpy_array_use_type_var: bool numpy_array_remove_parameters: bool print_invalid_expressions_as_is: bool print_safe_value_reprs: re.Pattern | None exit_code: bool dry_run: bool stub_extension: str module_name: str def arg_parser() -> ArgumentParser: def regex(pattern_str: str) -> re.Pattern: try: return re.compile(pattern_str) except re.error as e: raise ValueError(f"Invalid REGEX pattern: {e}") def regex_colon_path(regex_path: str) -> tuple[re.Pattern, str]: pattern_str, path = regex_path.rsplit(":", maxsplit=1) if any(not part.isidentifier() for part in path.split(".")): raise ValueError(f"Invalid PATH: {path}") return regex(pattern_str), path parser = ArgumentParser( prog="pybind11-stubgen", description="Generates stubs for specified modules" ) parser.add_argument( "-o", "--output-dir", help="The root directory for output stubs", default="./stubs", ) parser.add_argument( "--root-suffix", type=str, default=None, dest="root_suffix", help="Top-level module directory suffix", ) parser.add_argument( "--ignore-invalid-expressions", metavar="REGEX", default=None, type=regex, help="Ignore invalid expressions matching REGEX", ) parser.add_argument( "--ignore-invalid-identifiers", metavar="REGEX", default=None, type=regex, help="Ignore invalid identifiers matching REGEX", ) parser.add_argument( "--ignore-unresolved-names", metavar="REGEX", default=None, type=regex, help="Ignore unresolved names matching REGEX", ) parser.add_argument( "--ignore-all-errors", default=False, action="store_true", help="Ignore all errors during module parsing", ) parser.add_argument( "--enum-class-locations", dest="enum_class_locations", metavar="REGEX:LOC", action="append", default=[], type=regex_colon_path, help="Locations of enum classes in " ": format. " "Example: `MyEnum:foo.bar.Baz`", ) numpy_array_fix = parser.add_mutually_exclusive_group() numpy_array_fix.add_argument( "--numpy-array-wrap-with-annotated", default=False, action="store_true", help="Replace numpy/scipy arrays of " "'ARRAY_T[TYPE, [*DIMS], *FLAGS]' format with " "'Annotated[ARRAY_T, TYPE, FixedSize|DynamicSize(*DIMS), *FLAGS]'", ) numpy_array_fix.add_argument( "--numpy-array-use-type-var", default=False, action="store_true", help="Replace 'numpy.ndarray[numpy.float32[m, 1]]' with " "'numpy.ndarray[tuple[M, typing.Literal[1]], numpy.dtype[numpy.float32]]'", ) numpy_array_fix.add_argument( "--numpy-array-remove-parameters", default=False, action="store_true", help="Replace 'numpy.ndarray[...]' with 'numpy.ndarray'", ) parser.add_argument( "--print-invalid-expressions-as-is", default=False, action="store_true", help="Suppress the replacement with '...' of invalid expressions" "found in annotations", ) parser.add_argument( "--print-safe-value-reprs", metavar="REGEX", default=None, type=regex, help="Override the print-safe check for values matching REGEX", ) parser.add_argument( "--exit-code", action="store_true", dest="exit_code", help="On error exits with 1 and skips stub generation", ) parser.add_argument( "--dry-run", action="store_true", dest="dry_run", help="Don't write stubs. Parses module and report errors", ) parser.add_argument( "--stub-extension", type=str, default="pyi", metavar="EXT", choices=["pyi", "py"], help="The file extension of the generated stubs. " "Must be 'pyi' (default) or 'py'", ) parser.add_argument( "module_name", metavar="MODULE_NAME", type=str, help="module name", ) return parser def stub_parser_from_args(args: CLIArgs) -> IParser: error_handlers_top: list[type] = [ LoggerData, *([IgnoreAllErrors] if args.ignore_all_errors else []), *([IgnoreInvalidIdentifierErrors] if args.ignore_invalid_identifiers else []), *([IgnoreInvalidExpressionErrors] if args.ignore_invalid_expressions else []), *([IgnoreUnresolvedNameErrors] if args.ignore_unresolved_names else []), ] error_handlers_bottom: list[type] = [ LogErrors, SuggestCxxSignatureFix, *([TerminateOnFatalErrors] if args.exit_code else []), ] numpy_fixes: list[type] = [ *([FixNumpyArrayDimAnnotation] if args.numpy_array_wrap_with_annotated else []), *([FixNumpyArrayDimTypeVar] if args.numpy_array_use_type_var else []), *( [FixNumpyArrayRemoveParameters] if args.numpy_array_remove_parameters else [] ), ] class Parser( *error_handlers_top, # type: ignore[misc] FixMissing__future__AnnotationsImport, FixMissing__all__Attribute, FixMissingNoneHashFieldAnnotation, FixMissingImports, FilterTypingModuleAttributes, FixPEP585CollectionNames, FixTypingTypeNames, FixScipyTypeArguments, FixMissingFixedSizeImport, FixMissingEnumMembersAnnotation, OverridePrintSafeValues, *numpy_fixes, # type: ignore[misc] FixNumpyDtype, FixNumpyArrayFlags, FixCurrentModulePrefixInTypeNames, FixBuiltinTypes, RewritePybind11EnumValueRepr, FilterClassMembers, ReplaceReadWritePropertyWithField, FilterInvalidIdentifiers, FixValueReprRandomAddress, FixRedundantBuiltinsAnnotation, FilterPybindInternals, FilterPybind11ViewClasses, FixRedundantMethodsFromBuiltinObject, RemoveSelfAnnotation, FixPybind11EnumStrDoc, ExtractSignaturesFromPybind11Docstrings, ParserDispatchMixin, BaseParser, *error_handlers_bottom, # type: ignore[misc] ): pass parser = Parser() if args.enum_class_locations: parser.set_pybind11_enum_locations(dict(args.enum_class_locations)) if args.ignore_invalid_identifiers is not None: parser.set_ignored_invalid_identifiers(args.ignore_invalid_identifiers) if args.ignore_invalid_expressions is not None: parser.set_ignored_invalid_expressions(args.ignore_invalid_expressions) if args.ignore_unresolved_names is not None: parser.set_ignored_unresolved_names(args.ignore_unresolved_names) if args.print_safe_value_reprs is not None: parser.set_print_safe_value_pattern(args.print_safe_value_reprs) return parser def main(argv: Sequence[str] | None = None) -> None: logging.basicConfig( level=logging.INFO, format="%(name)s - [%(levelname)7s] %(message)s", ) args = arg_parser().parse_args(argv, namespace=CLIArgs()) parser = stub_parser_from_args(args) printer = Printer(invalid_expr_as_ellipses=not args.print_invalid_expressions_as_is) out_dir, sub_dir = to_output_and_subdir( output_dir=args.output_dir, module_name=args.module_name, root_suffix=args.root_suffix, ) run( parser, printer, args.module_name, out_dir, sub_dir=sub_dir, dry_run=args.dry_run, writer=Writer(stub_ext=args.stub_extension), ) def to_output_and_subdir( output_dir: str, module_name: str, root_suffix: str | None ) -> tuple[Path, Path | None]: out_dir = Path(output_dir) module_path = module_name.split(".") if root_suffix is None: return out_dir.joinpath(*module_path[:-1]), None else: module_path = [f"{module_path[0]}{root_suffix}", *module_path[1:]] if len(module_path) == 1: sub_dir = Path(module_path[-1]) else: sub_dir = None return out_dir.joinpath(*module_path[:-1]), sub_dir def run( parser: IParser, printer: Printer, module_name: str, out_dir: Path, sub_dir: Path | None, dry_run: bool, writer: Writer, ): module = parser.handle_module( QualifiedName.from_str(module_name), importlib.import_module(module_name) ) parser.finalize() if module is None: raise RuntimeError(f"Can't parse {module_name}") if dry_run: return out_dir.mkdir(exist_ok=True, parents=True) writer.write_module(module, printer, to=out_dir, sub_dir=sub_dir) if __name__ == "__main__": main() pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/__main__.py000066400000000000000000000001021504552055100237370ustar00rootroot00000000000000from .__init__ import main if __name__ == "__main__": main() pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/000077500000000000000000000000001504552055100231505ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/__init__.py000066400000000000000000000000001504552055100252470ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/errors.py000066400000000000000000000015461504552055100250440ustar00rootroot00000000000000from __future__ import annotations from pybind11_stubgen.structs import Identifier, QualifiedName class ParserError(Exception): pass class InvalidIdentifierError(ParserError): def __init__(self, name: Identifier, found_at: QualifiedName): super().__init__() self.name = name self.at = found_at def __str__(self): return f"Invalid identifier '{self.name}' at '{self.at}'" class InvalidExpressionError(ParserError): def __init__(self, expression: str): super().__init__() self.expression: str = expression def __str__(self): return f"Invalid expression '{self.expression}'" class NameResolutionError(ParserError): def __init__(self, name: QualifiedName): super().__init__() self.name = name def __str__(self): return f"Can't find/import '{self.name}'" pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/interface.py000066400000000000000000000055301504552055100254650ustar00rootroot00000000000000from __future__ import annotations import abc import types from typing import Any from pybind11_stubgen.parser.errors import ParserError from pybind11_stubgen.structs import ( Alias, Argument, Attribute, Class, Docstring, Field, Function, Import, InvalidExpression, Method, Module, Property, QualifiedName, ResolvedType, Value, ) class IParser(abc.ABC): @abc.abstractmethod def handle_alias(self, path: QualifiedName, origin: Any) -> Alias | None: ... @abc.abstractmethod def handle_attribute(self, path: QualifiedName, attr: Any) -> Attribute | None: ... @abc.abstractmethod def handle_bases( self, path: QualifiedName, bases: tuple[type, ...] ) -> list[QualifiedName]: ... @abc.abstractmethod def handle_class(self, path: QualifiedName, class_: type) -> Class | None: ... @abc.abstractmethod def handle_class_member( self, path: QualifiedName, class_: type, obj: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: ... @abc.abstractmethod def handle_docstring(self, path: QualifiedName, doc: Any) -> Docstring | None: ... @abc.abstractmethod def handle_field(self, path: QualifiedName, field: Any) -> Field | None: ... @abc.abstractmethod def handle_function(self, path: QualifiedName, func: Any) -> list[Function]: ... @abc.abstractmethod def handle_import(self, path: QualifiedName, origin: Any) -> Import | None: ... @abc.abstractmethod def handle_method(self, path: QualifiedName, method: Any) -> list[Method]: ... @abc.abstractmethod def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: ... @abc.abstractmethod def handle_module_member( self, path: QualifiedName, module: types.ModuleType, obj: Any ) -> ( Docstring | Import | Alias | Class | list[Function] | Attribute | Module | None ): ... @abc.abstractmethod def handle_property(self, path: QualifiedName, prop: Any) -> Property | None: ... @abc.abstractmethod def handle_type(self, type_: type) -> QualifiedName: ... @abc.abstractmethod def handle_value(self, value: Any) -> Value: ... @abc.abstractmethod def parse_args_str(self, args_str: str) -> list[Argument]: ... @abc.abstractmethod def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: ... @abc.abstractmethod def parse_value_str(self, value: str) -> Value | InvalidExpression: ... @abc.abstractmethod def report_error(self, error: ParserError) -> None: ... @abc.abstractmethod def finalize(self): ... pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/mixins/000077500000000000000000000000001504552055100244575ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/mixins/__init__.py000066400000000000000000000000001504552055100265560ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/mixins/error_handlers.py000066400000000000000000000126501504552055100300460ustar00rootroot00000000000000from __future__ import annotations import re import sys import types from logging import getLogger from pybind11_stubgen.parser.errors import ( InvalidExpressionError, InvalidIdentifierError, NameResolutionError, ParserError, ) from pybind11_stubgen.parser.interface import IParser from pybind11_stubgen.structs import Class, Function, Method, Module, QualifiedName class LocalErrors: def __init__(self, path: QualifiedName, errors: set[str], stack: list[LocalErrors]): self.path: QualifiedName = path self.errors: set[str] = errors self._stack: list[LocalErrors] = stack def __enter__(self) -> LocalErrors: self._stack.append(self) return self def __exit__(self, exc_type, exc_val, exc_tb): top = self._stack.pop() assert top == self class LoggerData(IParser): def __init__(self): super().__init__() self.stack: list[LocalErrors] = [] def __new_layer(self, path: QualifiedName) -> LocalErrors: return LocalErrors(path, errors=set(), stack=self.stack) def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: with self.__new_layer(path): return super().handle_module(path, module) def handle_class(self, path: QualifiedName, class_: type) -> Class | None: with self.__new_layer(path): return super().handle_class(path, class_) def handle_function(self, path: QualifiedName, class_: type) -> list[Function]: with self.__new_layer(path): return super().handle_function(path, class_) def handle_method(self, path: QualifiedName, class_: type) -> list[Method]: with self.__new_layer(path): return super().handle_method(path, class_) @property def current_path(self) -> QualifiedName: assert len(self.stack) != 0 return self.stack[-1].path @property def reported_errors(self) -> set[str]: assert len(self.stack) != 0 return self.stack[-1].errors logger = getLogger("pybind11_stubgen") class LogErrors(IParser): def report_error(self: LoggerData, error: ParserError) -> None: error_str = f"In {self.current_path} : {error}" if error_str not in self.reported_errors: logger.error(error_str) self.reported_errors.add(error_str) super().report_error(error) class IgnoreUnresolvedNameErrors(IParser): def __init__(self): super().__init__() self.__regex: re.Pattern | None = None def set_ignored_unresolved_names(self, regex: re.Pattern): self.__regex = regex def report_error(self, error: ParserError): if self.__regex is not None: if isinstance(error, NameResolutionError): if self.__regex.match(str(error.name)): return super().report_error(error) class IgnoreInvalidExpressionErrors(IParser): def __init__(self): super().__init__() self.__regex: re.Pattern | None = None def set_ignored_invalid_expressions(self, regex: re.Pattern): self.__regex = regex def report_error(self, error: ParserError): if self.__regex is not None: if isinstance(error, InvalidExpressionError): if self.__regex.match(error.expression): return super().report_error(error) class IgnoreInvalidIdentifierErrors(IParser): def __init__(self): super().__init__() self.__regex: re.Pattern | None = None def set_ignored_invalid_identifiers(self, regex: re.Pattern): self.__regex = regex def report_error(self, error: ParserError): if self.__regex is not None: if isinstance(error, InvalidIdentifierError): if self.__regex.match(str(error.name)): return super().report_error(error) class IgnoreAllErrors(IParser): def report_error(self, error: ParserError): return None class SuggestCxxSignatureFix(IParser): def __init__(self): super().__init__() self.suggest_cxx_fix = False def report_error(self, error: ParserError): if isinstance(error, InvalidExpressionError): expression = error.expression if "::" in expression or expression.endswith(">"): self.suggest_cxx_fix = True super().report_error(error) def finalize(self): if self.suggest_cxx_fix: logger.warning( "Raw C++ types/values were found in signatures extracted " "from docstrings.\n" "Please check the corresponding sections of pybind11 documentation " "to avoid common mistakes in binding code:\n" " - https://pybind11.readthedocs.io/en/latest/advanced/misc.html" "#avoiding-cpp-types-in-docstrings\n" " - https://pybind11.readthedocs.io/en/latest/advanced/functions.html" "#default-arguments-revisited" ) super().finalize() class TerminateOnFatalErrors(IParser): def __init__(self): super().__init__() self.__found_fatal_errors = False def report_error(self, error: ParserError): self.__found_fatal_errors = True super().report_error(error) def finalize(self): super().finalize() if self.__found_fatal_errors: logger.info("Terminating due to previous errors") sys.exit(1) pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/mixins/filter.py000066400000000000000000000113151504552055100263170ustar00rootroot00000000000000from __future__ import annotations import types import typing from typing import Any from pybind11_stubgen.parser.errors import InvalidIdentifierError from pybind11_stubgen.parser.interface import IParser from pybind11_stubgen.structs import ( Alias, Attribute, Class, Docstring, Field, Function, Identifier, Import, Method, Module, Property, QualifiedName, ) class FilterTypingModuleAttributes(IParser): __sentinel = object() def handle_attribute(self, path: QualifiedName, attr: Any) -> Attribute | None: if getattr(typing, str(path[-1]), self.__sentinel) is attr: return None return super().handle_attribute(path, attr) class FilterClassMembers(IParser): __attribute_blacklist: set[Identifier] = { *map( Identifier, ( "__annotations__", "__builtins__", "__cached__", "__file__", "__firstlineno__", "__loader__", "__name__", "__package__", "__path__", "__spec__", "__static_attributes__", ), ) } __class_member_blacklist: set[Identifier] = { *map( Identifier, ( "__annotations__", "__class__", "__dict__", "__module__", "__qualname__", "__weakref__", ), ) } __method_blacklist: set[Identifier] = {*map(Identifier, ("__dir__", "__sizeof__"))} def handle_class_member( self, path: QualifiedName, class_: type, member: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: name = path[-1] if name in self.__class_member_blacklist: return None if not hasattr(class_, "__dict__") or name not in class_.__dict__: # Skip members inherited from base classes return None return super().handle_class_member(path, class_, member) def handle_method(self, path: QualifiedName, value: Any) -> list[Method]: if path[-1] in self.__method_blacklist: return [] return super().handle_method(path, value) def handle_attribute(self, path: QualifiedName, attr: Any) -> Attribute | None: if path[-1] in self.__attribute_blacklist: return None return super().handle_attribute(path, attr) class FilterPybindInternals(IParser): __attribute_blacklist: set[Identifier] = {*map(Identifier, ("__entries",))} __class_blacklist: set[Identifier] = {*map(Identifier, ("pybind11_type",))} def handle_attribute(self, path: QualifiedName, value: Any) -> Attribute | None: if path[-1] in self.__attribute_blacklist: return None return super().handle_attribute(path, value) def handle_class_member( self, path: QualifiedName, class_: type, member: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: name = path[-1] if name in self.__class_blacklist: return None if name.startswith("__pybind11_module"): return None if name.startswith("_pybind11_conduit_v1_"): return None return super().handle_class_member(path, class_, member) class FilterInvalidIdentifiers(IParser): def handle_module_member( self, path: QualifiedName, module: types.ModuleType, obj: Any ) -> ( Docstring | Import | Alias | Class | list[Function] | Attribute | Module | None ): if not path[-1].isidentifier(): self.report_error(InvalidIdentifierError(path[-1], path.parent)) return None return super().handle_module_member(path, module, obj) def handle_class_member( self, path: QualifiedName, class_: type, obj: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: if not path[-1].isidentifier(): self.report_error(InvalidIdentifierError(path[-1], path.parent)) return None return super().handle_class_member(path, class_, obj) class FilterPybind11ViewClasses(IParser): def handle_module_member( self, path: QualifiedName, module: types.ModuleType, obj: Any ) -> ( Docstring | Import | Alias | Class | list[Function] | Attribute | Module | None ): result = super().handle_module_member(path, module, obj) if isinstance(result, Class) and str(result.name) in [ "ItemsView", "KeysView", "ValuesView", ]: # TODO: check obj is a subclass of pybind11_object return None return result pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/mixins/fix.py000066400000000000000000001105231504552055100256210ustar00rootroot00000000000000from __future__ import annotations import builtins import importlib import inspect import re import sys import types from logging import getLogger from typing import Any, Sequence from pybind11_stubgen.parser.errors import ( InvalidExpressionError, NameResolutionError, ParserError, ) from pybind11_stubgen.parser.interface import IParser from pybind11_stubgen.structs import ( Alias, Argument, Attribute, Class, Docstring, Field, Function, Identifier, Import, InvalidExpression, Method, Module, Property, QualifiedName, ResolvedType, TypeVar_, Value, ) from pybind11_stubgen.typing_ext import DynamicSize, FixedSize logger = getLogger("pybind11_stubgen") class RemoveSelfAnnotation(IParser): __any_t_name = QualifiedName.from_str("Any") __typing_any_t_name = QualifiedName.from_str("typing.Any") def handle_method(self, path: QualifiedName, method: Any) -> list[Method]: methods = super().handle_method(path, method) for method in methods: self._remove_self_arg_annotation(path, method.function) return methods def handle_property(self, path: QualifiedName, prop: Any) -> Property | None: prop = super().handle_property(path, prop) if prop is not None: if prop.getter is not None: self._remove_self_arg_annotation(path, prop.getter) if prop.setter is not None: self._remove_self_arg_annotation(path, prop.setter) return prop def _remove_self_arg_annotation(self, path: QualifiedName, func: Function) -> None: if len(func.args) == 0: return fully_qualified_class_name = QualifiedName(path[:-1]) # remove the method name first_arg = func.args[0] if ( first_arg.name == "self" and isinstance(first_arg.annotation, ResolvedType) and not first_arg.annotation.parameters and ( first_arg.annotation.name in { self.__any_t_name, self.__typing_any_t_name, fully_qualified_class_name, fully_qualified_class_name[-len(first_arg.annotation.name) :], } ) ): first_arg.annotation = None class FixMissingImports(IParser): def __init__(self): super().__init__() self.__extra_imports: set[Import] = set() self.__current_module: types.ModuleType | None = None self.__current_class: type | None = None def handle_alias(self, path: QualifiedName, origin: Any) -> Alias | None: result = super().handle_alias(path, origin) if result is None: return None self._add_import(result.origin) return result def handle_attribute(self, path: QualifiedName, attr: Any) -> Attribute | None: result = super().handle_attribute(path, attr) if result is None: return None if isinstance(result.annotation, ResolvedType): self._add_import(result.annotation.name) return result def handle_class(self, path: QualifiedName, class_: type) -> Class | None: old_class = self.__current_class self.__current_class = class_ result = super().handle_class(path, class_) self.__current_class = old_class return result def handle_import(self, path: QualifiedName, origin: Any) -> Import | None: result = super().handle_import(path, origin) if result is None: return None self.__extra_imports.add(result) return result def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: old_imports = self.__extra_imports old_module = self.__current_module self.__extra_imports = set() self.__current_module = module result = super().handle_module(path, module) if result is not None: result.imports |= self.__extra_imports self.__extra_imports = old_imports self.__current_module = old_module return result def handle_type(self, type_: type) -> QualifiedName: result = super().handle_type(type_) if not inspect.ismodule(type_): self._add_import(result) return result def handle_value(self, value: Any) -> Value: result = super().handle_value(value) if inspect.isroutine(value) and result.is_print_safe: self._add_import(QualifiedName.from_str(result.repr)) return result def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if isinstance(result, ResolvedType): self._add_import(result.name) return result def _add_import(self, name: QualifiedName) -> None: if len(name) == 0: return if len(name) == 1 and len(name[0]) == 0: return if hasattr(builtins, name[0]): return if self.__current_class is not None and hasattr(self.__current_class, name[0]): return if self.__current_module is not None and hasattr( self.__current_module, name[0] ): return module_name = self._get_parent_module(name) if module_name is None: self.report_error(NameResolutionError(name)) return self.__extra_imports.add(Import(name=None, origin=module_name)) def _get_parent_module(self, name: QualifiedName) -> QualifiedName | None: parent = name.parent while len(parent) != 0: if self._is_module(parent): if not self._is_accessible(name, from_module=parent): return None return parent parent = parent.parent return None def _is_module(self, name: QualifiedName): try: return importlib.import_module(str(name)) is not None except ModuleNotFoundError: return False def _is_accessible(self, name: QualifiedName, from_module: QualifiedName) -> bool: try: parent = importlib.import_module(str(from_module)) except ModuleNotFoundError: return False relative_path = name[len(from_module) :] for part in relative_path: if not hasattr(parent, part): return False parent = getattr(parent, part) return True class FixMissing__future__AnnotationsImport(IParser): def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: result = super().handle_module(path, module) if result is None: return None result.imports.add(self._future(Identifier("annotations"))) return result def _future(self, feature: Identifier) -> Import: return Import( name=feature, origin=QualifiedName((Identifier("__future__"), feature)) ) class FixMissing__all__Attribute(IParser): def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: result = super().handle_module(path, module) if result is None: return None # don't override __all__ for attr in result.attributes: if attr.name == Identifier("__all__"): return result all_names: list[str] = sorted( set( filter( lambda name: not name.startswith("_"), map( str, ( *(class_.name for class_ in result.classes), *(attr.name for attr in result.attributes), *(func.name for func in result.functions), *(alias.name for alias in result.aliases), *( import_.name for import_ in result.imports if import_.name is not None ), *(sub_module.name for sub_module in result.sub_modules), ), ), ) ) ) result.attributes.append( Attribute( name=Identifier("__all__"), value=self.handle_value(all_names), annotation=ResolvedType(name=QualifiedName.from_str("list[str]")), ) ) return result class FixBuiltinTypes(IParser): _any_type = QualifiedName.from_str("typing.Any") def handle_type(self, type_: type) -> QualifiedName: if type_.__qualname__ == "PyCapsule" and type_.__module__ == "builtins": return self._any_type result = super().handle_type(type_) if result[0] == "builtins": if result[1] == "NoneType": return QualifiedName((Identifier("None"),)) if result[1] in ("function", "builtin_function_or_method"): callable_t = self.parse_annotation_str("typing.Callable") assert isinstance(callable_t, ResolvedType) return callable_t.name return QualifiedName(result[1:]) return result def report_error(self, error: ParserError): if isinstance(error, NameResolutionError): if error.name[0] in ["PyCapsule"]: return super().report_error(error) class FixRedundantBuiltinsAnnotation(IParser): def handle_attribute(self, path: QualifiedName, attr: Any) -> Attribute | None: result = super().handle_attribute(path, attr) if result is None: return None if attr is None or inspect.ismodule(attr): result.annotation = None return result class FixMissingNoneHashFieldAnnotation(IParser): def handle_field(self, path: QualifiedName, field: Any) -> Field | None: result = super().handle_field(path, field) if result is None: return None if field is None and path[-1] == "__hash__": result.attribute.annotation = self.parse_annotation_str( "typing.ClassVar[None]" ) return result class FixPEP585CollectionNames(IParser): __typing_collection_names: set[Identifier] = set( Identifier(name) for name in ( "Dict", "List", "Set", "Tuple", "FrozenSet", "Type", ) ) def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if ( not isinstance(result, ResolvedType) or len(result.name) != 2 or result.name[0] != "typing" ): return result word = result.name[1] if word in self.__typing_collection_names: result.name = QualifiedName.from_str(f"{word.lower()}") return result class FixTypingTypeNames(IParser): __typing_names: set[Identifier] = set( Identifier(name) for name in ( "Annotated", "Any", "Buffer", "Callable", "Dict", "ItemsView", "Iterable", "Iterator", "KeysView", "List", "Literal", "Optional", "Sequence", "Set", "Tuple", "Union", "ValuesView", # Old pybind11 annotations were not capitalized "buffer", "iterable", "iterator", "sequence", ) ) __typing_extensions_names: set[Identifier] = set( Identifier(name) for name in ( "buffer", "Buffer", ) ) def __init__(self): super().__init__() if sys.version_info < (3, 9): self.__typing_extensions_names.add(Identifier("Annotated")) if sys.version_info < (3, 8): self.__typing_extensions_names.add(Identifier("Literal")) def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) return self._parse_annotation_str(result) def _parse_annotation_str( self, result: ResolvedType | InvalidExpression | Value ) -> ResolvedType | InvalidExpression | Value: if not isinstance(result, ResolvedType): return result result.parameters = ( [self._parse_annotation_str(p) for p in result.parameters] if result.parameters is not None else None ) if len(result.name) != 1: return result word = result.name[0] if word in self.__typing_names: package = "typing" if word in self.__typing_extensions_names: package = "typing_extensions" result.name = QualifiedName.from_str( f"{package}.{word[0].upper()}{word[1:]}" ) if word == "function" and result.parameters is None: result.name = QualifiedName.from_str("typing.Callable") if word in ("object", "handle") and result.parameters is None: result.name = QualifiedName.from_str("typing.Any") return result class FixCurrentModulePrefixInTypeNames(IParser): def __init__(self): super().__init__() self.__current_module: QualifiedName = QualifiedName() def handle_alias(self, path: QualifiedName, origin: Any) -> Alias | None: result = super().handle_alias(path, origin) if result is None: return None result.origin = self._strip_current_module(result.origin) return result def handle_attribute(self, path: QualifiedName, attr: Any) -> Attribute | None: result = super().handle_attribute(path, attr) if result is None: return None if isinstance(result.annotation, ResolvedType): result.annotation.name = self._strip_current_module(result.annotation.name) return result def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: tmp = self.__current_module self.__current_module = path result = super().handle_module(path, module) self.__current_module = tmp return result def handle_type(self, type_: type) -> QualifiedName: result = super().handle_type(type_) return self._strip_current_module(result) def handle_value(self, value: Any) -> Value: result = super().handle_value(value) if inspect.isroutine(value): result.repr = str( self._strip_current_module(QualifiedName.from_str(result.repr)) ) return result def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if isinstance(result, ResolvedType): result.name = self._strip_current_module(result.name) return result def _strip_current_module(self, name: QualifiedName) -> QualifiedName: if name[: len(self.__current_module)] == self.__current_module: return QualifiedName(name[len(self.__current_module) :]) return name class FixValueReprRandomAddress(IParser): """ repr examples: # PyCapsule """ _pattern = re.compile( r"<(?P[\w.]+) object " r"(?P\w+\s)*at " r"(?P
0x[a-fA-F0-9]+)>" ) def handle_value(self, value: Any) -> Value: result = super().handle_value(value) result.repr = self._pattern.sub(r"<\g object>", result.repr) return result class FixNumpyArrayDimAnnotation(IParser): __array_names: set[QualifiedName] = { QualifiedName.from_str("numpy.ndarray"), *( QualifiedName.from_str(f"scipy.sparse.{storage}_{arr}") for storage in ["bsr", "coo", "csr", "csc", "dia", "dok", "lil"] for arr in ["array", "matrix"] ), } # NB: Not using full name due to ambiguity `typing.Annotated` vs # `typing_extension.Annotated` in different python versions # Rely on later fix by `FixTypingTypeNames` __annotated_name = QualifiedName.from_str("Annotated") numpy_primitive_types: set[QualifiedName] = set( map( QualifiedName.from_str, ( "bool", *map( lambda name: f"numpy.{name}", ( "uint8", "int8", "uint16", "int16", "uint32", "int32", "uint64", "int64", "float16", "float32", "float64", "complex32", "complex64", "longcomplex", ), ), ), ) ) __DIM_VARS = ["n", "m"] def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: # Affects types of the following pattern: # ARRAY_T[PRIMITIVE_TYPE[*DIMS], *FLAGS] # Replace with: # Annotated[ARRAY_T, PRIMITIVE_TYPE, FixedSize/DynamicSize[*DIMS], *FLAGS] result = super().parse_annotation_str(annotation_str) if ( not isinstance(result, ResolvedType) or result.name not in self.__array_names or result.parameters is None or len(result.parameters) == 0 ): return result scalar_with_dims = result.parameters[0] # e.g. numpy.float64[32, 32] flags = result.parameters[1:] if ( not isinstance(scalar_with_dims, ResolvedType) or scalar_with_dims.name not in self.numpy_primitive_types ): return result result = ResolvedType( name=self.__annotated_name, parameters=[ self.parse_annotation_str(str(result.name)), ResolvedType(scalar_with_dims.name), ], ) assert result.parameters is not None if ( scalar_with_dims.parameters is not None and len(scalar_with_dims.parameters) >= 0 ): dims = self.__to_dims(scalar_with_dims.parameters) if dims is not None and len(dims) > 0: result.parameters += [ self.handle_value(self.__wrap_with_size_helper(dims)) ] result.parameters += flags return result def __wrap_with_size_helper(self, dims: list[int | str]) -> FixedSize | DynamicSize: if all(isinstance(d, int) for d in dims): return_t = FixedSize else: return_t = DynamicSize # TRICK: Use `self.handle_type` to make `FixedSize`/`DynamicSize` # properly added to the list of imports self.handle_type(return_t) return return_t(*dims) # type: ignore[arg-type] def __to_dims( self, dimensions: Sequence[ResolvedType | Value | InvalidExpression] ) -> list[int | str] | None: result = [] for dim_param in dimensions: if isinstance(dim_param, Value): try: dim = int(dim_param.repr) except ValueError: return None elif isinstance(dim_param, ResolvedType): dim = str(dim_param) if dim not in self.__DIM_VARS: return None else: return None result.append(dim) return result def report_error(self, error: ParserError) -> None: if ( isinstance(error, NameResolutionError) and len(error.name) == 1 and len(error.name[0]) == 1 and error.name[0] in self.__DIM_VARS ): # Ignores all unknown 'm' and 'n' regardless of the context return super().report_error(error) class FixNumpyArrayDimTypeVar(IParser): __array_names: set[QualifiedName] = {QualifiedName.from_str("numpy.ndarray")} numpy_primitive_types = FixNumpyArrayDimAnnotation.numpy_primitive_types __DIM_VARS: set[str] = set() def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: result = super().handle_module(path, module) if result is None: return None if self.__DIM_VARS: # the TypeVar_'s generated code will reference `typing` result.imports.add( Import(name=None, origin=QualifiedName.from_str("typing")) ) for name in self.__DIM_VARS: result.type_vars.append( TypeVar_( name=Identifier(name), bound=self.parse_annotation_str("int"), ), ) self.__DIM_VARS.clear() return result def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: # Affects types of the following pattern: # numpy.ndarray[PRIMITIVE_TYPE[*DIMS], *FLAGS] # Replace with: # numpy.ndarray[tuple[M, Literal[1]], numpy.dtype[numpy.float32]] result = super().parse_annotation_str(annotation_str) if not isinstance(result, ResolvedType): return result # handle unqualified, single-letter annotation as a TypeVar if len(result.name) == 1 and len(result.name[0]) == 1: result.name = QualifiedName.from_str(result.name[0].upper()) self.__DIM_VARS.add(result.name[0]) if result.name not in self.__array_names: return result # ndarray is generic and should have 2 type arguments if result.parameters is None or len(result.parameters) == 0: result.parameters = [ self.parse_annotation_str("Any"), ResolvedType( name=QualifiedName.from_str("numpy.dtype"), parameters=[self.parse_annotation_str("Any")], ), ] return result scalar_with_dims = result.parameters[0] # e.g. numpy.float64[32, 32] if ( not isinstance(scalar_with_dims, ResolvedType) or scalar_with_dims.name not in self.numpy_primitive_types ): return result name = scalar_with_dims.name # Pybind annotates a bool Python type, which cannot be used with # numpy.dtype because it does not inherit from numpy.generic. # Only numpy.bool_ works reliably with both NumPy 1.x and 2.x. if str(name) == "bool": name = QualifiedName.from_str("numpy.bool_") dtype = ResolvedType( name=QualifiedName.from_str("numpy.dtype"), parameters=[ResolvedType(name=name)], ) shape = self.parse_annotation_str("Any") if ( scalar_with_dims.parameters is not None and len(scalar_with_dims.parameters) > 0 ): dims = self.__to_dims(scalar_with_dims.parameters) if dims is not None: shape = self.parse_annotation_str("Tuple") assert isinstance(shape, ResolvedType) shape.parameters = [] for dim in dims: if isinstance(dim, int): # self.parse_annotation_str will qualify Literal with either # typing or typing_extensions and add the import to the module literal_dim = self.parse_annotation_str("Literal") assert isinstance(literal_dim, ResolvedType) literal_dim.parameters = [Value(repr=str(dim))] shape.parameters.append(literal_dim) else: shape.parameters.append( ResolvedType(name=QualifiedName.from_str(dim)) ) result.parameters = [shape, dtype] return result def __to_dims( self, dimensions: Sequence[ResolvedType | Value | InvalidExpression] ) -> list[int | str] | None: result: list[int | str] = [] for dim_param in dimensions: if isinstance(dim_param, Value): try: dim = int(dim_param.repr) except ValueError: return None elif isinstance(dim_param, ResolvedType): dim = str(dim_param) else: return None result.append(dim) return result def report_error(self, error: ParserError) -> None: if ( isinstance(error, NameResolutionError) and len(error.name) == 1 and error.name[0] in self.__DIM_VARS ): # allow type variables, which are manually resolved in `handle_module` return super().report_error(error) class FixNumpyArrayRemoveParameters(IParser): __ndarray_name = QualifiedName.from_str("numpy.ndarray") def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if isinstance(result, ResolvedType) and result.name == self.__ndarray_name: result.parameters = None return result class FixScipyTypeArguments(IParser): def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if not isinstance(result, ResolvedType): return result # scipy.sparse arrays/matrices are not currently generic and do not accept type # arguments if result.name[:2] == ("scipy", "sparse"): result.parameters = None return result class FixNumpyDtype(IParser): __numpy_dtype = QualifiedName.from_str("numpy.dtype") def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if not isinstance(result, ResolvedType) or result.parameters: return result # numpy.dtype is generic and should have a type argument if result.name[:1] == ("dtype",) or result.name[:2] == ("numpy", "dtype"): result.name = self.__numpy_dtype result.parameters = [self.parse_annotation_str("Any")] return result class FixNumpyArrayFlags(IParser): __ndarray_name = QualifiedName.from_str("numpy.ndarray") __flags: set[QualifiedName] = { QualifiedName.from_str("flags.writeable"), QualifiedName.from_str("flags.c_contiguous"), QualifiedName.from_str("flags.f_contiguous"), } def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: result = super().parse_annotation_str(annotation_str) if isinstance(result, ResolvedType) and result.name == self.__ndarray_name: if result.parameters is not None: for param in result.parameters: if isinstance(param, ResolvedType) and param.name in self.__flags: param.name = QualifiedName.from_str( f"numpy.ndarray.{param.name}" ) return result def report_error(self, error: ParserError) -> None: if isinstance(error, NameResolutionError) and error.name in self.__flags: return super().report_error(error) class FixRedundantMethodsFromBuiltinObject(IParser): def handle_method(self, path: QualifiedName, method: Any) -> list[Method]: result = super().handle_method(path, method) return [ m for m in result if not ( m.function.name == "__init__" and m.function.doc == object.__init__.__doc__ ) ] class ReplaceReadWritePropertyWithField(IParser): def handle_class_member( self, path: QualifiedName, class_: type, obj: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: result = super().handle_class_member(path, class_, obj) if isinstance(result, Property): if ( result.doc is None and result.getter is not None and result.setter is not None and len(result.getter.args) == 1 and len(result.setter.args) == 2 and result.getter.doc is None and result.setter.doc is None and result.getter.returns == result.setter.args[1].annotation ): return Field( attribute=Attribute( name=result.name, annotation=result.getter.returns, value=None ), modifier=None, ) return result class FixMissingFixedSizeImport(IParser): def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: # Accommodate to # https://github.com/pybind/pybind11/pull/4679 result = super().parse_annotation_str(annotation_str) if ( isinstance(result, Value) and result.repr.startswith("FixedSize(") and result.repr.endswith(")") ): try: dimensions = map( int, result.repr[len("FixedSize(") : -len(")")].split(","), ) except ValueError: pass else: # call `handle_type` to trigger implicit import self.handle_type(FixedSize) return self.handle_value(FixedSize(*dimensions)) return result class FixMissingEnumMembersAnnotation(IParser): __class_var_dict = ResolvedType( name=QualifiedName.from_str("typing.ClassVar"), parameters=[ResolvedType(name=QualifiedName.from_str("dict"))], ) def handle_field(self, path: QualifiedName, field: Any) -> Field | None: result = super().handle_field(path, field) if result is None: return None if ( path[-1] == "__members__" and isinstance(field, dict) and result.attribute.annotation == self.__class_var_dict ): assert isinstance(result.attribute.annotation, ResolvedType) dict_type = self._guess_dict_type(field) if dict_type is not None: result.attribute.annotation.parameters = [dict_type] return result def _guess_dict_type(self, d: dict) -> ResolvedType | None: if len(d) == 0: return None key_types = set() value_types = set() for key, value in d.items(): key_types.add(self.handle_type(type(key))) value_types.add(self.handle_type(type(value))) if len(key_types) == 1: key_type = [ResolvedType(name=t) for t in key_types][0] else: union_t = self.parse_annotation_str("typing.Union") assert isinstance(union_t, ResolvedType) key_type = ResolvedType( name=union_t.name, parameters=[ResolvedType(name=t) for t in key_types] ) if len(value_types) == 1: value_type = [ResolvedType(name=t) for t in value_types][0] else: union_t = self.parse_annotation_str("typing.Union") assert isinstance(union_t, ResolvedType) value_type = ResolvedType( name=union_t.name, parameters=[ResolvedType(name=t) for t in value_types], ) dict_t = self.parse_annotation_str("typing.Dict") assert isinstance(dict_t, ResolvedType) return ResolvedType( name=dict_t.name, parameters=[key_type, value_type], ) class FixPybind11EnumStrDoc(IParser): def handle_class_member( self, path: QualifiedName, class_: type, obj: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: result = super().handle_class_member(path, class_, obj) if not isinstance(result, list) or not hasattr( # list[Method] class_, "__members__" ): # class is enum return result for method in result: assert isinstance(method, Method) if ( method.function.name != "__str__" or method.function.doc != "name(self: handle) -> str\n" ): continue method.function.args = [ Argument( name=Identifier("self"), # annotation=ResolvedType(self.handle_type(class_)), ) ] method.function.returns = ResolvedType(name=QualifiedName.from_str("str")) # Note: Wrong function name in __str.__.__doc__ triggered # generic (*args, **kwargs) signature which in turn # recognized as a static method signature method.modifier = None method.function.doc = None return result class OverridePrintSafeValues(IParser): _print_safe_values: re.Pattern | None def __init__(self): super().__init__() self._print_safe_values = None def set_print_safe_value_pattern(self, pattern: re.Pattern): self._print_safe_values = pattern def parse_value_str(self, value: str) -> Value | InvalidExpression: result = super().parse_value_str(value) if ( self._print_safe_values is not None and isinstance(result, Value) and not result.is_print_safe and self._print_safe_values.match(result.repr) is not None ): result.is_print_safe = True return result class RewritePybind11EnumValueRepr(IParser): _pybind11_enum_pattern = re.compile(r"<(?P\w+(\.\w+)+): (?P-?\d+)>") # _pybind11_enum_pattern = re.compile(r"<(?P\w+(\.\w+)+): (?P\d+)>") _unknown_enum_classes: set[str] = set() def __init__(self): super().__init__() self._pybind11_enum_locations: dict[re.Pattern, str] = {} def set_pybind11_enum_locations(self, locations: dict[re.Pattern, str]): self._pybind11_enum_locations = locations def parse_value_str(self, value: str) -> Value | InvalidExpression: value = value.strip() match = self._pybind11_enum_pattern.match(value) if match is not None: enum_qual_name = match.group("enum") enum_class_str, entry = enum_qual_name.rsplit(".", maxsplit=1) for pattern, prefix in self._pybind11_enum_locations.items(): if pattern.match(enum_class_str) is None: continue enum_class = self.parse_annotation_str(f"{prefix}.{enum_class_str}") if isinstance(enum_class, ResolvedType): return Value(repr=f"{enum_class.name}.{entry}", is_print_safe=True) return super().parse_value_str(value) def report_error(self, error: ParserError) -> None: if isinstance(error, InvalidExpressionError): match = self._pybind11_enum_pattern.match(error.expression) if match is not None: enum_qual_name = match.group("enum") enum_class_str, entry = enum_qual_name.rsplit(".", maxsplit=1) self._unknown_enum_classes.add(enum_class_str) super().report_error(error) def finalize(self): if self._unknown_enum_classes: logger.warning( "Enum-like str representations were found with no " "matching mapping to the enum class location.\n" "Use `--enum-class-locations` to specify " "full path to the following enum(s):\n" + "\n".join(f" - {c}" for c in self._unknown_enum_classes) ) super().finalize() pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/parser/mixins/parse.py000066400000000000000000000736251504552055100261600ustar00rootroot00000000000000from __future__ import annotations import ast import inspect import re import types from typing import Any from pybind11_stubgen.parser.errors import ( InvalidExpressionError, InvalidIdentifierError, NameResolutionError, ParserError, ) from pybind11_stubgen.parser.interface import IParser from pybind11_stubgen.structs import ( Alias, Argument, Attribute, Class, Decorator, Docstring, Field, Function, Identifier, Import, InvalidExpression, Method, Modifier, Module, Property, QualifiedName, ResolvedType, TypeVar_, Value, ) _generic_args = [ Argument(name=Identifier("args"), variadic=True), Argument(name=Identifier("kwargs"), kw_variadic=True), ] class ParserDispatchMixin(IParser): def handle_class(self, path: QualifiedName, class_: type) -> Class | None: base_classes = class_.__bases__ result = Class(name=path[-1], bases=self.handle_bases(path, base_classes)) for name, member in inspect.getmembers(class_): obj = self.handle_class_member( QualifiedName([*path, Identifier(name)]), class_, member ) if isinstance(obj, Docstring): result.doc = obj elif isinstance(obj, Alias): result.aliases.append(obj) elif isinstance(obj, Field): result.fields.append(obj) elif isinstance(obj, Class): result.classes.append(obj) elif isinstance(obj, list): # list[Method] result.methods.extend(obj) elif isinstance(obj, Property): result.properties.append(obj) elif obj is None: pass else: raise AssertionError() return result def handle_class_member( self, path: QualifiedName, class_: type, member: Any ) -> Docstring | Alias | Class | list[Method] | Field | Property | None: if inspect.isroutine(member): return self.handle_method(path, member) if self._is_alias(path, member): return self.handle_alias(path, member) if inspect.isclass(member): return self.handle_class(path, member) if self._is_descriptor(member): return self.handle_property(path, member) if path[-1] == "__doc__": return self.handle_docstring(path, member) return self.handle_field(path, member) def handle_module( self, path: QualifiedName, module: types.ModuleType ) -> Module | None: result = Module(name=path[-1]) for name, member in inspect.getmembers(module): obj = self.handle_module_member( QualifiedName([*path, Identifier(name)]), module, member ) if isinstance(obj, Docstring): result.doc = obj elif isinstance(obj, Import): result.imports.add(obj) elif isinstance(obj, Alias): result.aliases.append(obj) elif isinstance(obj, Class): result.classes.append(obj) elif isinstance(obj, list): # list[Function] result.functions.extend(obj) elif isinstance(obj, Module): result.sub_modules.append(obj) elif isinstance(obj, Attribute): result.attributes.append(obj) elif isinstance(obj, TypeVar_): result.type_vars.append(obj) elif obj is None: if name == "__path__": result.is_package = True else: raise AssertionError() return result def handle_module_member( self, path: QualifiedName, module: types.ModuleType, member: Any ) -> ( Docstring | Import | Alias | Class | list[Function] | Attribute | Module | None ): member_module = self._get_value_parent_module_name(member) if ( member_module is not None and member_module != module.__name__ or path[-1] == "annotations" ): return self.handle_import(path, member) if self._is_alias(path, member): return self.handle_alias(path, member) if inspect.isroutine(member): return self.handle_function(path, member) if inspect.isclass(member): return self.handle_class(path, member) if inspect.ismodule(member): return self.handle_module(path, member) if path[-1] == "__doc__": return self.handle_docstring(path, member) return self.handle_attribute(path, member) def _get_value_parent_module_name(self, obj: Any) -> str | None: if inspect.ismodule(obj): return obj.__name__.rsplit(".", 1)[0] if inspect.isclass(obj) or inspect.isroutine(obj): return getattr(obj, "__module__", None) return None def _is_alias(self, path: QualifiedName, member: Any): if (inspect.isroutine(member) or inspect.isclass(member)) and path[ -1 ] != member.__name__: return True if inspect.ismodule(member) and member.__name__ != str(path): return True return False def _is_descriptor(self, member: Any) -> bool: # https://docs.python.org/3/glossary.html#term-descriptor # Ignore `__delete__`-only descriptors return hasattr(member, "__get__") or hasattr(member, "__set__") class BaseParser(IParser): def handle_alias(self, path: QualifiedName, origin: Any) -> Alias | None: full_name = self._get_full_name(path, origin) if full_name is None: return None return Alias( name=path[-1], origin=full_name, ) def handle_attribute(self, path: QualifiedName, value: Any) -> Attribute | None: return Attribute( name=path[-1], value=self.handle_value(value), annotation=ResolvedType(name=self.handle_type(type(value))), ) def handle_bases( self, path: QualifiedName, bases: tuple[type, ...] ) -> list[QualifiedName]: return [self.handle_type(type_) for type_ in bases if type_ is not object] def handle_docstring(self, path: QualifiedName, value: Any) -> Docstring | None: if isinstance(value, str): return Docstring(value) return None def handle_field(self, path: QualifiedName, value: Any) -> Field | None: attr = self.handle_attribute(path, value) if attr is None: return None result = Field( attribute=Attribute( name=attr.name, value=attr.value, ), modifier="static", ) if attr.annotation is not None: class_var = self.parse_annotation_str("typing.ClassVar") assert isinstance(class_var, ResolvedType) result.attribute.annotation = ResolvedType( name=class_var.name, parameters=[attr.annotation], ) return result def handle_function(self, path: QualifiedName, func: Any) -> list[Function]: doc: Docstring | None = ( Docstring(func.__doc__) if getattr(func, "__doc__", None) is not None else None ) func_name = Identifier(path[-1]) try: ( args, var_args, var_kw, defaults, kw_only_args, kw_only_defaults, annotations, ) = inspect.getfullargspec(func) func_args: dict[str, Argument] = { arg_name: Argument(name=Identifier(arg_name)) for arg_name in args } func_args["return"] = Argument( name=Identifier(), ) if var_args is not None: func_args[var_args] = Argument(name=Identifier(var_args), variadic=True) for arg_name in kw_only_args: func_args[arg_name] = Argument(name=Identifier(arg_name), kw_only=True) if var_kw is not None: func_args[var_kw] = Argument(name=Identifier(var_kw), kw_variadic=True) if defaults is not None: for i, default in enumerate(defaults): arg_name = args[len(args) - len(defaults) + i] func_args[arg_name].default = self.handle_value(default) if kw_only_defaults is not None: for arg_name, default in kw_only_defaults.items(): func_args[arg_name].default = self.handle_value(default) for arg_name, annotation in annotations.items(): if isinstance(annotation, str): func_args[arg_name].annotation = self.parse_annotation_str( annotation ) elif not isinstance(annotation, type): func_args[arg_name].annotation = self.handle_value(annotation) elif self._is_generic_alias(annotation): func_args[arg_name].annotation = self.parse_annotation_str( str(annotation) ) else: func_args[arg_name].annotation = ResolvedType( name=self.handle_type(annotation), ) if "return" in func_args: returns = func_args["return"].annotation else: returns = None return [ Function( name=func_name, args=[ arg for arg_name, arg in func_args.items() if arg_name != "return" ], returns=returns, doc=doc, ) ] except TypeError: # generic signature `f(*args, *kwargs)` return [ Function( name=func_name, args=_generic_args, doc=doc, ) ] def _is_generic_alias(self, annotation: type) -> bool: generic_alias_t: type | None = getattr(types, "GenericAlias", None) if generic_alias_t is None: return False return isinstance(annotation, generic_alias_t) def handle_import(self, path: QualifiedName, origin: Any) -> Import | None: full_name = self._get_full_name(path, origin) if full_name is None: return None return Import( path[-1], full_name, ) def handle_method(self, path: QualifiedName, method: Any) -> list[Method]: return [ Method(function=func, modifier=self._get_method_modifier(func.args)) for func in self.handle_function(path, method) ] def handle_value(self, value: Any) -> Value: value_type = type(value) # Use exact type match, not `isinstance()` that allows inherited types pass if value is None or value_type in (bool, int, str): return Value(repr=repr(value), is_print_safe=True) if value_type in (float, complex): try: # checks for NaN, +inf, -inf repr_str = repr(value) eval(repr_str) return Value(repr=repr_str, is_print_safe=True) except (SyntaxError, NameError): pass if value_type in (list, tuple, set): assert isinstance(value, (list, tuple, set)) if len(value) == 0: return Value(repr=f"{value_type.__name__}()", is_print_safe=True) elements: list[Value] = [self.handle_value(el) for el in value] is_print_safe = all(el.is_print_safe for el in elements) left, right = { list: "[]", tuple: "()", set: "{}", }[value_type] return Value( repr="".join([left, ", ".join(el.repr for el in elements), right]), is_print_safe=is_print_safe, ) if value_type is dict: assert isinstance(value, dict) parts = [] is_print_safe = True for k, v in value.items(): k_value = self.handle_value(k) v_value = self.handle_value(v) parts.append(f"{k_value.repr}: {v_value.repr}") is_print_safe = ( is_print_safe and k_value.is_print_safe and v_value.is_print_safe ) return Value( repr="".join(["{", ", ".join(parts), "}"]), is_print_safe=is_print_safe ) if inspect.isroutine(value): module_name = getattr(value, "__module__", None) qual_name = getattr(value, "__qualname__", None) if ( module_name is not None and "<" not in module_name and qual_name is not None and "<" not in qual_name ): if module_name == "builtins": repr_str = qual_name else: repr_str = f"{module_name}.{qual_name}" return Value(repr=repr_str, is_print_safe=True) if inspect.isclass(value): return Value(repr=str(self.handle_type(value)), is_print_safe=True) if inspect.ismodule(value): return Value(repr=value.__name__, is_print_safe=True) return Value(repr=repr(value), is_print_safe=False) def handle_type(self, type_: type) -> QualifiedName: return QualifiedName( ( Identifier(part) for part in ( *type_.__module__.split("."), *type_.__qualname__.split("."), ) ) ) def parse_value_str(self, value: str) -> Value | InvalidExpression: return self._parse_expression_str(value) def report_error(self, error: ParserError): if isinstance(error, NameResolutionError): if error.name[0] == "module": return super().report_error(error) def _get_method_modifier(self, args: list[Argument]) -> Modifier: if len(args) == 0: return "static" name = args[0].name if name == Identifier("self"): return None elif name == Identifier("cls"): return "class" else: return "static" def _get_full_name(self, path: QualifiedName, origin: Any) -> QualifiedName | None: if inspect.ismodule(origin): origin_full_name = origin.__name__ else: module_name = getattr(origin, "__module__", None) if module_name == "__future__": return None if module_name is None: self.report_error(NameResolutionError(path)) return None qual_name = getattr(origin, "__qualname__", None) if qual_name is None: self.report_error(NameResolutionError(path)) return None # Note: __qualname__ prefix is an artefact of pybind11 # `PyCapsule.` in pybind11 2 # pybind11_detail_function_record_* in 3 match = re.match( r"(PyCapsule|pybind11_detail_function_record_[_a-zA-Z0-9]+)\.", qual_name, ) if match: qual_name = qual_name[match.end() :] origin_full_name = f"{module_name}.{qual_name}" origin_name = QualifiedName.from_str(origin_full_name) for part in origin_name: if not part.isidentifier(): self.report_error(InvalidIdentifierError(part, path)) return None return origin_name def _parse_expression_str(self, expr_str: str) -> Value | InvalidExpression: strip_expr = expr_str.strip() try: ast.parse(strip_expr) print_safe = False try: ast.literal_eval(strip_expr) print_safe = True except (ValueError, TypeError, SyntaxError, MemoryError, RecursionError): pass return Value(strip_expr, is_print_safe=print_safe) except SyntaxError: self.report_error(InvalidExpressionError(strip_expr)) return InvalidExpression(strip_expr) class ExtractSignaturesFromPybind11Docstrings(IParser): _arg_star_name_regex = re.compile( r"^\s*(?P\*{1,2})?" r"\s*(?P\w+)\s*$" ) def handle_function(self, path: QualifiedName, func: Any) -> list[Function]: result = super().handle_function(path, func) if len(result) == 1 and result[0].args == _generic_args: doc: str | None = func.__doc__ func_name = Identifier(path[-1]) if doc is not None: parsed_funcs = self.parse_function_docstring( func_name, doc.splitlines() ) if len(parsed_funcs) > 0: return parsed_funcs return result def handle_property(self, path: QualifiedName, prop: Any) -> Property | None: result = Property(name=path[-1], modifier=None) # Note: pybind *usually* does not include function name # in getter/setter signatures, e.g.: # (arg0: demo._bindings.enum.ConsoleForegroundColor) -> int # fake_path = QualifiedName((*path, Identifier(""))) if hasattr(prop, "fget") and prop.fget is not None: for func_path in [fake_path, path]: result.getter = self._fixup_parsed_getters_or_setters( self.handle_function(func_path, prop.fget) ) if result.getter is not None and result.getter.args != _generic_args: break if hasattr(prop, "fset") and prop.fset is not None: for func_path in [fake_path, path]: result.setter = self._fixup_parsed_getters_or_setters( self.handle_function(func_path, prop.fset) ) if result.setter is not None and result.setter.args != _generic_args: break if result.getter is None and result.setter is None: return None prop_doc = getattr(prop, "__doc__", None) if prop_doc is not None: result.doc = self._strip_empty_lines(prop_doc.splitlines()) if ( result.doc is not None and result.getter is not None and ( result.doc == result.getter.doc or result.doc == self._strip_empty_lines( (getattr(prop.fget, "__doc__", "") or "").splitlines() ) ) ): result.doc = None return result def parse_args_str(self, args_str: str) -> list[Argument]: split_args = self._split_args_str(args_str) if split_args is None: return _generic_args result: list[Argument] = [] kw_only = False for arg_str, annotation_str, default_str in split_args: if arg_str.strip() == "/": for arg in result: arg.pos_only = True continue if arg_str.strip() == "*": kw_only = True continue match = self._arg_star_name_regex.match(arg_str) if match is None: return _generic_args name = Identifier(match.group("name")) variadic = False kw_variadic = False stars = match.group("stars") if stars == "*": variadic = True elif stars == "**": kw_variadic = True if annotation_str is not None: annotation = self.parse_annotation_str(annotation_str) else: annotation = None if default_str is not None: default = self.parse_value_str(default_str) else: default = None result.append( Argument( name=name, default=default, annotation=annotation, variadic=variadic, kw_variadic=kw_variadic, kw_only=kw_only, ) ) return result def parse_annotation_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: variants = self._split_type_union_str(annotation_str) if variants is None or len(variants) == 0: self.report_error(InvalidExpressionError(annotation_str)) return InvalidExpression(annotation_str) if len(variants) == 1: return self.parse_type_str(variants[0]) union_t = self.parse_annotation_str("typing.Union") assert isinstance(union_t, ResolvedType) return ResolvedType( name=union_t.name, parameters=[self.parse_type_str(variant) for variant in variants], ) def parse_type_str( self, annotation_str: str ) -> ResolvedType | InvalidExpression | Value: qname_regex = re.compile( r"^\s*(?P([_A-Za-z]\w*)?(\s*\.\s*[_A-Za-z]\w*)*)" ) annotation_str = annotation_str.strip() match = qname_regex.match(annotation_str) if match is None: return self.parse_value_str(annotation_str) qual_name = QualifiedName( Identifier(part) for part in match.group("qual_name").replace(" ", "").split(".") ) parameters_str = annotation_str[match.end("qual_name") :].strip() if len(parameters_str) == 0: parameters = None else: if parameters_str[0] != "[" or parameters_str[-1] != "]": return self.parse_value_str(annotation_str) split_parameters = self._split_parameters_str(parameters_str[1:-1]) if split_parameters is None: return self.parse_value_str(annotation_str) parameters = [ self.parse_annotation_str(param_str) for param_str in split_parameters ] return ResolvedType(name=qual_name, parameters=parameters) def parse_function_docstring( self, func_name: Identifier, doc_lines: list[str] ) -> list[Function]: if len(doc_lines) == 0: return [] top_signature_regex = re.compile( rf"^{func_name}\((?P.*)\)\s*(->\s*(?P.+))?$" ) match = top_signature_regex.match(doc_lines[0]) if match is None: return [] if len(doc_lines) < 2 or doc_lines[1] != "Overloaded function.": returns_str = match.group("returns") if returns_str is not None: returns = self.parse_annotation_str(returns_str) else: returns = None return [ Function( name=func_name, args=self.parse_args_str(match.group("args")), doc=self._strip_empty_lines(doc_lines[1:]), returns=returns, ) ] overload_signature_regex = re.compile( rf"^(\s*(?P\d+).\s*)" rf"{func_name}\((?P.*)\)\s*->\s*(?P.+)$" ) doc_start = 0 _dummy = Function(Identifier("")) overloads = [_dummy] for i in range(2, len(doc_lines)): match = overload_signature_regex.match(doc_lines[i]) if match: if match.group("overload_number") != f"{len(overloads)}": continue overloads[-1].doc = self._strip_empty_lines(doc_lines[doc_start:i]) doc_start = i + 1 overloads.append( Function( name=func_name, args=self.parse_args_str(match.group("args")), returns=self.parse_annotation_str(match.group("returns")), doc=None, decorators=[ # use `parse_annotation_str()` to trigger typing import Decorator(str(self.parse_annotation_str("typing.overload"))) ], ) ) overloads[-1].doc = self._strip_empty_lines(doc_lines[doc_start:]) return overloads[1:] def _fixup_parsed_getters_or_setters( self, funcs: list[Function] ) -> Function | None: if len(funcs) == 0: return None if len(funcs) > 1: raise RuntimeError( "Multiple overloads in property's getters/setters are not supported" ) func = funcs[0] if ( len(func.args) > 0 and not func.args[0].variadic and not func.args[0].kw_variadic and func.args[0].default is None ): func.args[0].name = Identifier("self") func.args[0].annotation = None else: pass # TODO: produce warning return func def _split_args_str( self, args_str: str ) -> list[tuple[str, str | None, str | None]] | None: result = [] closing = {"(": ")", "{": "}", "[": "]"} stack = [] i = 0 arg_begin = 0 semicolon_pos: int | None = None eq_sign_pos: int | None = None def add_arg(): nonlocal semicolon_pos nonlocal eq_sign_pos annotation = None default = None arg_end = i if eq_sign_pos is not None: arg_end = eq_sign_pos default = args_str[eq_sign_pos + 1 : i] if semicolon_pos is not None: annotation = args_str[semicolon_pos + 1 : arg_end] arg_end = semicolon_pos name = args_str[arg_begin:arg_end] result.append((name, annotation, default)) semicolon_pos = None eq_sign_pos = None while i < len(args_str): c = args_str[i] if c in "\"'": # TODO: handle triple-quoted strings too str_end = self._find_str_end(args_str, i) if str_end is None: return None i = str_end elif c in closing: stack.append(closing[c]) elif len(stack) == 0: if c == ",": add_arg() arg_begin = i + 1 elif c == ":" and semicolon_pos is None: semicolon_pos = i elif c == "=" and args_str[i : i + 2] != "==": eq_sign_pos = i elif stack[-1] == c: stack.pop() i += 1 if len(stack) != 0: return None if len(args_str[arg_begin:i].strip()) != 0: add_arg() return result def _split_type_union_str(self, type_str: str) -> list[str] | None: return self._split_str(type_str, delim="|") def _split_parameters_str(self, param_str: str) -> list[str] | None: return self._split_str(param_str, delim=",") def _split_str(self, param_str: str, delim: str): result = [] closing = {"(": ")", "{": "}", "[": "]"} stack = [] i = 0 arg_begin = 0 def add_arg(): arg_end = i param = param_str[arg_begin:arg_end] result.append(param) while i < len(param_str): c = param_str[i] if c in "\"'": # TODO: handle triple-quoted strings too str_end = self._find_str_end(param_str, i) if str_end is None: return None i = str_end elif c in closing: stack.append(closing[c]) elif len(stack) == 0: if c == delim: add_arg() arg_begin = i + 1 elif stack[-1] == c: stack.pop() i += 1 if len(stack) != 0: return None if param_str[arg_begin:i].strip() != 0: add_arg() return result def _find_str_end(self, s, start) -> int | None: for i in range(start + 1, len(s)): c = s[i] if c == "\\": # skip escaped chars continue if c == s[start]: return i return None def _strip_empty_lines(self, doc_lines: list[str]) -> Docstring | None: assert isinstance(doc_lines, list) start = 0 for start in range(0, len(doc_lines)): if len(doc_lines[start].strip()) > 0: break end = len(doc_lines) - 1 for end in range(len(doc_lines) - 1, 0, -1): if len(doc_lines[end].strip()) > 0: break result = "\n".join(doc_lines[start : end + 1]) if len(result) == 0: return None return Docstring(result) def report_error(self, error: ParserError) -> None: if isinstance(error, NameResolutionError): if error.name[0] == "pybind11_builtins": return if isinstance(error, InvalidIdentifierError): name = error.name if ( name.startswith("ItemsView[") and name.endswith("]") or name.startswith("KeysView[") and name.endswith("]") or name.startswith("ValuesView[") and name.endswith("]") ): return super().report_error(error) def handle_bases( self, path: QualifiedName, bases: tuple[type, ...] ) -> list[QualifiedName]: result = [] for base in super().handle_bases(path, bases): if base[0] == "pybind11_builtins": break result.append(base) return result pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/printer.py000066400000000000000000000236651504552055100237250ustar00rootroot00000000000000from __future__ import annotations import dataclasses import sys from pybind11_stubgen.structs import ( Alias, Annotation, Argument, Attribute, Class, Docstring, Field, Function, Identifier, Import, InvalidExpression, Method, Modifier, Module, Property, ResolvedType, TypeVar_, Value, ) def indent_lines(lines: list[str], by=4) -> list[str]: return [" " * by + line for line in lines] class Printer: def __init__(self, invalid_expr_as_ellipses: bool): self.invalid_expr_as_ellipses = invalid_expr_as_ellipses def print_alias(self, alias: Alias) -> list[str]: return [f"{alias.name} = {alias.origin}"] def print_attribute(self, attr: Attribute) -> list[str]: parts = [ f"{attr.name}", ] if attr.annotation is not None: parts.append(f": {self.print_annotation(attr.annotation)}") if attr.value is not None and attr.value.is_print_safe: parts.append(f" = {self.print_value(attr.value)}") else: if attr.annotation is None: parts.append(" = ...") if attr.value is not None: parts.append(f" # value = {self.print_value(attr.value)}") return ["".join(parts)] def print_argument(self, arg: Argument) -> str: parts = [] if arg.variadic: parts += ["*"] if arg.kw_variadic: parts += ["**"] parts.append(f"{arg.name}") if arg.annotation is not None: parts.append(f": {self.print_annotation(arg.annotation)}") if isinstance(arg.default, Value): if arg.default.is_print_safe: parts.append(f" = {self.print_value(arg.default)}") else: parts.append(" = ...") elif isinstance(arg.default, InvalidExpression): parts.append(f" = {self.print_invalid_exp(arg.default)}") return "".join(parts) def print_class(self, class_: Class) -> list[str]: if class_.bases: base_list = "(" + ", ".join(str(base) for base in class_.bases) + ")" else: base_list = "" return [ f"class {class_.name}{base_list}:", *indent_lines(self.print_class_body(class_)), ] def print_type_var(self, type_var: TypeVar_) -> list[str]: return [str(type_var)] def print_class_body(self, class_: Class) -> list[str]: result = [] if class_.doc is not None: result.extend(self.print_docstring(class_.doc)) for sub_class in sorted(class_.classes, key=lambda c: c.name): result.extend(self.print_class(sub_class)) modifier_order: dict[Modifier, int] = { "static": 0, "class": 1, None: 2, } for field in sorted( class_.fields, key=lambda f: (modifier_order[f.modifier], f.attribute.name) ): result.extend(self.print_field(field)) for alias in sorted(class_.aliases, key=lambda a: a.name): result.extend(self.print_alias(alias)) for method in sorted( class_.methods, key=lambda m: (modifier_order[m.modifier], m.function.name) ): result.extend(self.print_method(method)) for prop in sorted(class_.properties, key=lambda p: p.name): result.extend(self.print_property(prop)) if not result: result = ["pass"] return result def print_docstring(self, doc: Docstring) -> list[str]: return [ '"""', *( line.replace("\\", r"\\").replace('"""', r"\"\"\"") for line in doc.splitlines() ), '"""', ] def print_field(self, field: Field) -> list[str]: return self.print_attribute(field.attribute) # FIXME: modifier def print_function(self, func: Function) -> list[str]: pos_only = False kw_only = False args = [] for arg in func.args: if arg.variadic: pos_only = True kw_only = True if not pos_only and not arg.pos_only: pos_only = True if sys.version_info >= (3, 8): args.append("/") if not kw_only and arg.kw_only: kw_only = True args.append("*") args.append(self.print_argument(arg)) if len(args) > 0 and args[0] == "/": args = args[1:] signature = [ f"def {func.name}(", ", ".join(args), ")", ] if func.returns is not None: signature.append(f" -> {self.print_annotation(func.returns)}") signature.append(":") result: list[str] = [ *(f"@{decorator}" for decorator in func.decorators), "".join(signature), ] if func.doc is not None: body = self.print_docstring(func.doc) else: body = ["..."] result.extend(indent_lines(body)) return result def print_submodule_import(self, name: Identifier) -> list[str]: return [f"from . import {name}"] def print_import(self, import_: Import) -> list[str]: parent = str(import_.origin.parent) if import_.name is None: return [f"import {import_.origin}"] if len(parent) == 0: return [f"import {import_.origin} as {import_.name}"] result = f"from {parent} import {import_.origin[-1]}" if import_.name != import_.origin[-1]: result += f" as {import_.name}" return [result] def print_method(self, method: Method) -> list[str]: result = [] if method.modifier == "static": result += ["@staticmethod"] elif method.modifier == "class": result += ["@classmethod"] elif method.modifier is None: pass else: raise RuntimeError() result.extend(self.print_function(method.function)) return result def print_module(self, module: Module) -> list[str]: result = [] if module.doc is not None: result.extend(self.print_docstring(module.doc)) for import_ in sorted(module.imports, key=lambda x: x.origin): result.extend(self.print_import(import_)) for sub_module in module.sub_modules: result.extend(self.print_submodule_import(sub_module.name)) # Place __all__ above everything for attr in sorted(module.attributes, key=lambda a: a.name): if attr.name == "__all__": result.extend(self.print_attribute(attr)) break for type_var in sorted(module.type_vars, key=lambda t: t.name): result.extend(self.print_type_var(type_var)) for class_ in sorted(module.classes, key=lambda c: c.name): result.extend(self.print_class(class_)) for func in sorted(module.functions, key=lambda f: f.name): result.extend(self.print_function(func)) for attr in sorted(module.attributes, key=lambda a: a.name): if attr.name != "__all__": result.extend(self.print_attribute(attr)) for alias in module.aliases: result.extend(self.print_alias(alias)) return result def print_property(self, prop: Property) -> list[str]: if not prop.getter: # FIXME: support setter-only props return [] # FIXME: add modifier result = [] result.extend( [ "@property", *self.print_function( dataclasses.replace( prop.getter, name=prop.name, # replace getter docstring if prop.doc exists doc=prop.doc if prop.doc is not None else prop.getter.doc, ) ), ] ) if prop.setter: result.extend( [ f"@{prop.name}.setter", *self.print_function( dataclasses.replace( prop.setter, name=prop.name, # remove setter docstring if prop.doc exists doc=None if prop.doc is not None else prop.setter.doc, ) ), ] ) return result def print_value(self, value: Value) -> str: split = value.repr.split("\n", 1) if len(split) == 1: return split[0] else: return split[0] + "..." def print_type(self, type_: ResolvedType) -> str: if ( str(type_.name) == "typing.Optional" and type_.parameters is not None and len(type_.parameters) == 1 ): return f"{self.print_annotation(type_.parameters[0])} | None" if str(type_.name) == "typing.Union" and type_.parameters is not None: return " | ".join(self.print_annotation(p) for p in type_.parameters) if type_.parameters: param_str = ( "[" + ", ".join(self.print_annotation(p) for p in type_.parameters) + "]" ) else: param_str = "" return f"{type_.name}{param_str}" def print_annotation(self, annotation: Annotation) -> str: if isinstance(annotation, ResolvedType): return self.print_type(annotation) elif isinstance(annotation, Value): return self.print_value(annotation) elif isinstance(annotation, InvalidExpression): return self.print_invalid_exp(annotation) else: raise AssertionError() def print_invalid_exp(self, invalid_expr: InvalidExpression) -> str: if self.invalid_expr_as_ellipses: return "..." return invalid_expr.text pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/py.typed000066400000000000000000000000001504552055100233410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/structs.py000066400000000000000000000120101504552055100237270ustar00rootroot00000000000000from __future__ import annotations import sys from dataclasses import dataclass from dataclasses import field as field_ from typing import Tuple, Union if sys.version_info >= (3, 8): from typing import Literal Modifier = Literal["static", "class", None] else: from typing import Optional Modifier = Optional[str] class Identifier(str): pass class Decorator(str): pass class Docstring(str): pass @dataclass class InvalidExpression: text: str def __str__(self): return f"Invalid python expression `{self.text}`" class QualifiedName(Tuple[Identifier, ...]): """Fully Qualified Name""" @classmethod def from_str(cls, name: str) -> QualifiedName: return QualifiedName(Identifier(part) for part in name.split(".")) def __str__(self): return ".".join(self) @property def parent(self) -> QualifiedName: return QualifiedName(self[:-1]) @dataclass class Value: repr: str is_print_safe: bool = False # `self.repr` is valid python and safe to print as is def __str__(self): return self.repr @dataclass class ResolvedType: name: QualifiedName parameters: list[ResolvedType | Value | InvalidExpression] | None = field_( default=None ) def __str__(self): if self.parameters: param_str = "[" + ", ".join(str(p) for p in self.parameters) + "]" else: param_str = "" return f"{self.name}{param_str}" @dataclass class Alias: name: Identifier origin: QualifiedName Annotation = Union[ResolvedType, Value, InvalidExpression] @dataclass class TypeVar_: name: Identifier constraints: list[Annotation] = field_(default_factory=list) bound: Annotation | None = field_(default=None) covariant: bool = field_(default=False) contravariant: bool = field_(default=False) def __str__(self) -> str: return ( f'{self.name} = typing.TypeVar("{self.name}"' + (", " if self.constraints else "") + (", ".join(str(c) for c in self.constraints)) + (f", bound={str(self.bound)}" if self.bound is not None else "") + (f", covariant={self.covariant}" if self.covariant else "") + (f", contravariant={self.contravariant}" if self.contravariant else "") + ")" ) @dataclass class Attribute: name: Identifier value: Value | None annotation: Annotation | None = field_(default=None) @dataclass class Argument: name: Identifier | None pos_only: bool = field_(default=False) kw_only: bool = field_(default=False) variadic: bool = field_(default=False) # *args kw_variadic: bool = field_(default=False) # **kwargs default: Value | InvalidExpression | None = field_(default=None) annotation: Annotation | None = field_(default=None) def __str__(self): result = [] if self.variadic: result += ["*"] if self.kw_variadic: result += ["**"] result += [f"{self.name}"] if self.annotation: result += [f": {self.annotation}"] if self.default: result += [f" = {self.default}"] return "".join(result) @dataclass class Function: name: Identifier args: list[Argument] = field_(default_factory=list) returns: Annotation | None = field_(default=None) doc: Docstring | None = field_(default=None) decorators: list[Decorator] = field_(default_factory=list) def __str__(self): return ( f"{self.name}({', '.join(str(arg) for arg in self.args)}) -> {self.returns}" ) @dataclass class Property: name: Identifier modifier: Modifier doc: Docstring | None = field_(default=None) getter: Function | None = field_(default=None) setter: Function | None = field_(default=None) @dataclass class Method: function: Function modifier: Modifier @dataclass class Field: attribute: Attribute modifier: Modifier @dataclass class Class: name: Identifier doc: Docstring | None = field_(default=None) bases: list[QualifiedName] = field_(default_factory=list) classes: list[Class] = field_(default_factory=list) fields: list[Field] = field_(default_factory=list) methods: list[Method] = field_(default_factory=list) properties: list[Property] = field_(default_factory=list) aliases: list[Alias] = field_(default_factory=list) @dataclass(eq=True, frozen=True) class Import: name: Identifier | None origin: QualifiedName @dataclass class Module: name: Identifier doc: Docstring | None = field_(default=None) classes: list[Class] = field_(default_factory=list) functions: list[Function] = field_(default_factory=list) sub_modules: list[Module] = field_(default_factory=list) attributes: list[Attribute] = field_(default_factory=list) imports: set[Import] = field_(default_factory=set) aliases: list[Alias] = field_(default_factory=list) type_vars: list[TypeVar_] = field_(default_factory=list) is_package: bool = field_(default=False) pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/typing_ext.py000066400000000000000000000011421504552055100244160ustar00rootroot00000000000000from __future__ import annotations class FixedSize: def __init__(self, *dim: int): self.dim: tuple[int, ...] = dim def __repr__(self): return ( f"{self.__module__}." f"{self.__class__.__qualname__}" f"({', '.join(str(d) for d in self.dim)})" ) class DynamicSize: def __init__(self, *dim: int | str): self.dim: tuple[int | str, ...] = dim def __repr__(self): return ( f"{self.__module__}." f"{self.__class__.__qualname__}" f"({', '.join(repr(d) for d in self.dim)})" ) pybind-pybind11-stubgen-ac46c10/pybind11_stubgen/writer.py000066400000000000000000000021151504552055100235410ustar00rootroot00000000000000from __future__ import annotations from pathlib import Path from pybind11_stubgen.printer import Printer from pybind11_stubgen.structs import Module class Writer: def __init__(self, stub_ext: str = "pyi"): # assert stub_extension in ["pyi", "py"] self.stub_ext: str = stub_ext def write_module( self, module: Module, printer: Printer, to: Path, sub_dir: Path | None = None ): assert to.exists() assert to.is_dir() if module.sub_modules or module.is_package or sub_dir is not None: if sub_dir is None: sub_dir = Path(module.name) module_dir = to / sub_dir module_dir.mkdir(exist_ok=True) module_file = module_dir / f"__init__.{self.stub_ext}" else: module_file = to / f"{module.name}.{self.stub_ext}" with open(module_file, "w", encoding="utf-8") as f: f.writelines(line + "\n" for line in printer.print_module(module)) for sub_module in module.sub_modules: self.write_module(sub_module, printer, to=module_dir) pybind-pybind11-stubgen-ac46c10/requirements-dev.txt000066400000000000000000000001321504552055100225320ustar00rootroot00000000000000black==22.8.0 flake8~=6.1.0 isort==5.10.1 numpy~=1.20 scipy~=1.0 typing_extensions==4.7.1 pybind-pybind11-stubgen-ac46c10/setup.py000066400000000000000000000012121504552055100202040ustar00rootroot00000000000000from setuptools import find_packages, setup setup( name="pybind11-stubgen", maintainer="Sergei Izmailov", maintainer_email="sergei.a.izmailov@gmail.com", description="PEP 561 type stubs generator for pybind11 modules", url="https://github.com/sizmailov/pybind11-stubgen", version="2.5.5", long_description=open("README.md").read(), long_description_content_type="text/markdown", license="BSD", entry_points={ "console_scripts": "pybind11-stubgen = pybind11_stubgen.__init__:main" }, packages=find_packages(), package_data={"pybind11_stubgen": ["py.typed"]}, python_requires="~=3.7", ) pybind-pybind11-stubgen-ac46c10/tests/000077500000000000000000000000001504552055100176405ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/.gitignore000066400000000000000000000000161504552055100216250ustar00rootroot00000000000000py-demo-stubs pybind-pybind11-stubgen-ac46c10/tests/README.md000066400000000000000000000004541504552055100211220ustar00rootroot00000000000000# Test project structure The setup mocks the following project structure: 1. A C++ library (C++/CMake): [`demo-lib`](demo-lib) 2. Bindings of C++ library as shared object (C++/CMake): [`py-demo/bindings`](py-demo/bindings) 3. Bindings of C++ library as python module (Python): [`py-demo`](py-demo) pybind-pybind11-stubgen-ac46c10/tests/check-demo-errors-generation.sh000077500000000000000000000015151504552055100256430ustar00rootroot00000000000000#!/bin/bash set -e TESTS_ROOT="$(readlink -m "$(dirname "$0")")" DEMO_ERRORS_FILE="${TESTS_ROOT}/demo.errors.stderr.txt" STUBS_DIR="/tmp/out" # Stubs should never be actually written remove_demo_errors() { rm -rf "${DEMO_ERRORS_FILE}"; } check_error_messages() { ( set -o pipefail ; git diff --exit-code HEAD -- "${DEMO_ERRORS_FILE}"; ) } run_stubgen() { ( set +e ; pybind11-stubgen \ demo \ --output-dir=${STUBS_DIR} \ --exit-code \ 2> "${DEMO_ERRORS_FILE}" \ || exit 0 ) || ( echo "'pybind11-stubgen demo --exit-code' did not exit with code 1" exit 1 ) } remove_randomness_in_errors (){ sed -i 's/0x[0-9a-f]*/0x1234abcd5678/gi' "${DEMO_ERRORS_FILE}" } main () { remove_demo_errors run_stubgen remove_randomness_in_errors check_error_messages } main "$@" pybind-pybind11-stubgen-ac46c10/tests/check-demo-stubs-generation.sh000077500000000000000000000037211504552055100254700ustar00rootroot00000000000000#!/bin/bash set -e function parse_args() { CLEAR='\033[0m' RED='\033[0;31m' function usage() { if [ -n "$1" ]; then echo -e "${RED}πŸ‘‰ $1${CLEAR}\n"; fi echo "Usage: $0 --stubs-sub-dir STUBS_SUB_DIR [--numpy-array-wrap-with-annotated] [--numpy-array-use-type-var]" echo " --stubs-sub-dir stubs output dir relative to this script directory" echo " --numpy-array-wrap-with-annotated use --numpy-array-wrap-with-annotated to generate numpy array stubs" echo " --numpy-array-use-type-var use --numpy-array-use-type-var to generate numpy array stubs" exit 1 } # parse params while [[ "$#" > 0 ]]; do case $1 in --stubs-sub-dir) STUBS_SUB_DIR="$2";shift;shift;; --numpy-array-use-type-var) NUMPY_FORMAT="$1";shift;; --numpy-array-wrap-with-annotated) NUMPY_FORMAT="$1";shift;; *) usage "Unknown parameter passed: $1"; shift; shift;; esac; done # verify params if [ -z "$STUBS_SUB_DIR" ]; then usage "STUBS_SUB_DIR is not set"; fi; if [ -z "$NUMPY_FORMAT" ]; then usage "NUMPY_FORMAT is not set"; fi; TESTS_ROOT="$(readlink -m "$(dirname "$0")")" STUBS_DIR=$(readlink -m "${TESTS_ROOT}/${STUBS_SUB_DIR}") } remove_stubs() { rm -rf "${STUBS_DIR}/*" ; } run_stubgen() { pybind11-stubgen \ demo \ --output-dir=${STUBS_DIR} \ ${NUMPY_FORMAT} \ --ignore-invalid-expressions="\(anonymous namespace\)::(Enum|Unbound)| $ ) target_include_directories(demo PRIVATE $ ) target_link_libraries(demo PUBLIC Eigen3::Eigen) set_property(TARGET demo PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(Demo::demo ALIAS demo) include(GNUInstallDirs) install(TARGETS demo EXPORT DemoTargets PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/demo" ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) set(DEMO_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for DemoConfig.cmake") install(EXPORT DemoTargets NAMESPACE Demo:: DESTINATION ${DEMO_CMAKECONFIG_INSTALL_DIR}) include(CMakePackageConfigHelpers) write_basic_package_version_file( DemoConfigVersion.cmake VERSION ${PACKAGE_VERSION} COMPATIBILITY SameMajorVersion ) install( FILES ./DemoConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/DemoConfigVersion.cmake DESTINATION ${DEMO_CMAKECONFIG_INSTALL_DIR} ) pybind-pybind11-stubgen-ac46c10/tests/demo-lib/DemoConfig.cmake000066400000000000000000000001731504552055100243450ustar00rootroot00000000000000include(CMakeFindDependencyMacro) find_dependency(Eigen3 REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/DemoTargets.cmake") pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/000077500000000000000000000000001504552055100227535ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/000077500000000000000000000000001504552055100236775ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/Foo.h000066400000000000000000000003431504552055100245730ustar00rootroot00000000000000#pragma once #include namespace demo{ class CppException : public std::runtime_error { using std::runtime_error::runtime_error; }; struct Foo { void f(); struct Child { void g(); }; }; } pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/Inheritance.h000066400000000000000000000002241504552055100262770ustar00rootroot00000000000000#pragma once #include namespace demo{ struct Base { struct Inner{}; std::string name; }; struct Derived : Base { int count; }; } pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/NestedClasses.h000066400000000000000000000002541504552055100266110ustar00rootroot00000000000000#pragma once namespace demo{ struct Outer { struct Inner{ enum class NestedEnum { ONE=1, TWO }; NestedEnum value; }; Inner inner; }; } pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/sublibA/000077500000000000000000000000001504552055100252605ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/sublibA/ConsoleColors.h000066400000000000000000000004041504552055100302130ustar00rootroot00000000000000namespace demo{ namespace sublibA{ enum class ConsoleForegroundColor { Green = 32, Yellow = 33, Blue = 34, Magenta = 35, None_ = -1 }; enum ConsoleBackgroundColor { Green = 42, Yellow = 43, Blue = 44, Magenta = 45 }; } } pybind-pybind11-stubgen-ac46c10/tests/demo-lib/include/demo/sublibA/add.h000066400000000000000000000001021504552055100261520ustar00rootroot00000000000000namespace demo{ namespace sublibA{ int add(int a, int b); } } pybind-pybind11-stubgen-ac46c10/tests/demo-lib/src/000077500000000000000000000000001504552055100221175ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/demo-lib/src/Foo.cpp000066400000000000000000000003331504552055100233450ustar00rootroot00000000000000#include "demo/Foo.h" #include void demo::Foo::f() { std::cout << "invoked demo::Foo::f()" << std::endl; } void demo::Foo::Child::g() { std::cout << "invoked demo::Foo::Child::g()" << std::endl; } pybind-pybind11-stubgen-ac46c10/tests/demo-lib/src/sublibA/000077500000000000000000000000001504552055100235005ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/demo-lib/src/sublibA/add.cpp000066400000000000000000000001321504552055100247300ustar00rootroot00000000000000#include "demo/sublibA/add.h" int demo::sublibA::add(int a, int b) { return a + b; } pybind-pybind11-stubgen-ac46c10/tests/demo.errors.stderr.txt000066400000000000000000000043521504552055100241460ustar00rootroot00000000000000pybind11_stubgen - [ ERROR] In demo._bindings.aliases.foreign_enum_default : Invalid expression '' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_c : Can't find/import 'm' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_c : Can't find/import 'n' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_r : Can't find/import 'm' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.dense_matrix_r : Can't find/import 'n' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.four_col_matrix_r : Can't find/import 'm' pybind11_stubgen - [ ERROR] In demo._bindings.eigen.four_row_matrix_r : Can't find/import 'n' pybind11_stubgen - [ ERROR] In demo._bindings.enum.accept_defaulted_enum : Invalid expression '' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_enum : Invalid expression '(anonymous namespace)::Enum' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_enum_defaulted : Invalid expression '' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_type : Invalid expression '(anonymous namespace)::Unbound' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.accept_unbound_type_defaulted : Invalid expression '' pybind11_stubgen - [ ERROR] In demo._bindings.flawed_bindings.get_unbound_type : Invalid expression '(anonymous namespace)::Unbound' pybind11_stubgen - [WARNING] Enum-like str representations were found with no matching mapping to the enum class location. Use `--enum-class-locations` to specify full path to the following enum(s): - ConsoleForegroundColor pybind11_stubgen - [WARNING] Raw C++ types/values were found in signatures extracted from docstrings. Please check the corresponding sections of pybind11 documentation to avoid common mistakes in binding code: - https://pybind11.readthedocs.io/en/latest/advanced/misc.html#avoiding-cpp-types-in-docstrings - https://pybind11.readthedocs.io/en/latest/advanced/functions.html#default-arguments-revisited pybind11_stubgen - [ INFO] Terminating due to previous errors pybind-pybind11-stubgen-ac46c10/tests/install-demo-module.sh000077500000000000000000000037371504552055100240640ustar00rootroot00000000000000#!/bin/bash set -e PYTHON_EXECUTABLE=$(python -c 'import sys; print(sys.executable)') function parse_args() { CLEAR='\033[0m' RED='\033[0;31m' function usage() { if [ -n "$1" ]; then echo -e "${RED}πŸ‘‰ $1${CLEAR}\n"; fi echo "Usage: $0 --pybind11-branch PYBIND11_BRANCH" echo " --pybind11-branch name of pybind11 branch" exit 1 } # parse params while [[ "$#" > 0 ]]; do case $1 in --pybind11-branch) PYBIND11_BRANCH="$2"; shift;shift;; *) usage "Unknown parameter passed: $1"; shift; shift;; esac; done # verify params if [ -z "$PYBIND11_BRANCH" ]; then usage "PYBIND11_BRANCH is not set"; fi; TESTS_ROOT="$(readlink -m "$(dirname "$0")")" PROJECT_ROOT="${TESTS_ROOT}/.." TEMP_DIR="${PROJECT_ROOT}/tmp/pybind11-${PYBIND11_BRANCH}" INSTALL_PREFIX="${TEMP_DIR}/install" BUILD_ROOT="${TEMP_DIR}/build" EXTERNAL_DIR="${TEMP_DIR}/external" } clone_pybind11() { mkdir -p "${EXTERNAL_DIR}" if [ ! -d "${EXTERNAL_DIR}/pybind11" ]; then git clone \ --depth 1 \ --branch "${PYBIND11_BRANCH}" \ --single-branch \ https://github.com/pybind/pybind11.git \ "${EXTERNAL_DIR}/pybind11" fi } install_pybind11() { export CMAKE_PREFIX_PATH="$(cmeel cmake)" cmake \ -S "${EXTERNAL_DIR}/pybind11" \ -B "${BUILD_ROOT}/pybind11"\ -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} cmake --install "${BUILD_ROOT}/pybind11" \ --prefix "${INSTALL_PREFIX}" } install_demo() { cmake -S "${TESTS_ROOT}/demo-lib" -B "${BUILD_ROOT}/demo" cmake --build "${BUILD_ROOT}/demo" cmake --install "${BUILD_ROOT}/demo" \ --prefix "${INSTALL_PREFIX}" } install_pydemo() { ( export CMAKE_PREFIX_PATH="$(readlink -m "${INSTALL_PREFIX}"):$(cmeel cmake)"; export CMAKE_ARGS="-DCMAKE_CXX_STANDARD=17"; pip install --force-reinstall "${TESTS_ROOT}/py-demo" ) } main () { parse_args "$@" clone_pybind11 install_pybind11 install_demo install_pydemo } main "$@" pybind-pybind11-stubgen-ac46c10/tests/py-demo/000077500000000000000000000000001504552055100212125ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/py-demo/README.rst000066400000000000000000000016051504552055100227030ustar00rootroot00000000000000 An example of C++ project with pybind11 bindings The primary purpose of this project is to test `pybind11-stubgen `_ functionality. It can be used as a C++ python module template. Project layout -------------- .. code-block:: sh ./include/demo/ # includes (.h) of C++ project ./src/ # sources (.cpp) of C++ project ./cpp_library_bindings/ # pybind11 bindings of C++ project ./external/ # root for 3rd party libraries sources (pybind11, gtests, etc.) Build module shared library --------------------------- Needed only for testing/debug .. code-block:: sh mkdir build (cd build ; cmake .. ) Install python -------------- The build step will be invoked automatically during install process .. code-block:: sh python setup.py install # regular python install is working pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/000077500000000000000000000000001504552055100230075ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/CMakeLists.txt000066400000000000000000000006071504552055100255520ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.12) project(PyDemo LANGUAGES CXX VERSION 1.0) find_package(Demo CONFIG REQUIRED) find_package(pybind11 CONFIG REQUIRED) file(GLOB_RECURSE BINDINGS_SOURCES ./src/**.cpp ./src/**.h ) pybind11_add_module(_bindings ${BINDINGS_SOURCES}) target_include_directories(_bindings PRIVATE ./src) target_link_libraries(_bindings PRIVATE Demo::demo) pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/000077500000000000000000000000001504552055100235765ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/main.cpp000066400000000000000000000014361504552055100252320ustar00rootroot00000000000000#include "modules.h" PYBIND11_MODULE(_bindings, m) { bind_classes_module(m.def_submodule("classes")); bind_eigen_module(m.def_submodule("eigen")); bind_enum_module(m.def_submodule("enum")); bind_aliases_module(m.def_submodule("aliases")); bind_flawed_bindings_module(m.def_submodule("flawed_bindings")); bind_functions_module(m.def_submodule("functions")); bind_issues_module(m.def_submodule("issues")); bind_methods_module(m.def_submodule("methods")); bind_numpy_module(m.def_submodule("numpy")); bind_properties_module(m.def_submodule("properties")); bind_stl_module(m.def_submodule("stl")); bind_stl_bind_module(m.def_submodule("stl_bind")); bind_typing_module(m.def_submodule("typing")); bind_values_module(m.def_submodule("values")); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules.h000066400000000000000000000014561504552055100254250ustar00rootroot00000000000000#pragma once #include #include "opaque_types.h" #define PYBIND11_VERSION_AT_LEAST(x,y) (PYBIND11_VERSION_MAJOR>x || ( PYBIND11_VERSION_MAJOR>=x && PYBIND11_VERSION_MINOR>=y )) namespace py = pybind11; void bind_aliases_module(py::module&& m); void bind_classes_module(py::module&& m); void bind_eigen_module(py::module&& m); void bind_enum_module(py::module&& m); void bind_flawed_bindings_module(py::module&& m); void bind_functions_module(py::module&& m); void bind_issues_module(py::module&& m); void bind_methods_module(py::module&& m); void bind_numpy_module(py::module&& m); void bind_properties_module(py::module&& m); void bind_stl_module(py::module&& m); void bind_stl_bind_module(py::module&& m); void bind_typing_module(py::module&& m); void bind_values_module(py::module&& m); pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/000077500000000000000000000000001504552055100252465ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/aliases.cpp000066400000000000000000000044151504552055100273770ustar00rootroot00000000000000#include "modules.h" #include #include namespace { class Dummy { }; struct Color { }; struct Bar1 { }; struct Bar2 { }; struct Bar3 { }; struct Bar4 { }; } // namespace void bind_aliases_module(py::module &&m) { { // python module as value auto &&pyDummy = py::class_(m, "Dummy"); pyDummy.def_property_readonly_static( "linalg", [](py::object &) { return py::module::import("numpy.linalg"); }); m.add_object("random", py::module::import("numpy.random")); } { auto &&pyColor = py::class_(m, "Color"); m.def("func", [](int x) { return x + 1; }); m.attr("local_type_alias") = pyColor; m.attr("local_func_alias") = m.attr("func"); } { auto &&sub = m.def_submodule("foreign_attr"); sub.attr("value") = demo::Foo(); } { auto &&sub = m.def_submodule("foreign_arg"); sub.def("set_foo", [](demo::Foo &) { return 13; }); } { auto &&sub = m.def_submodule("foreign_return"); sub.def("get_foo", []() { return demo::Foo(); }); } { auto &&sub = m.def_submodule("foreign_class_member"); auto &&pyBar = py::class_(sub, "Bar1"); pyBar.attr("foo") = demo::Foo(); } { auto &&sub = m.def_submodule("foreign_method_arg"); auto &&pyBar = py::class_(sub, "Bar2"); pyBar.def("set_foo", [](const Bar2 &, const demo::Foo &) { return 13; }); } { auto &&sub = m.def_submodule("foreign_method_return"); auto &&pyBar = py::class_(sub, "Bar3"); pyBar.def("get_foo", []() { return demo::Foo(); }); } { auto &&sub = m.def_submodule("missing_self_arg"); auto &&pyBar = py::class_(sub, "Bar4"); pyBar.def("set_foo", [](const demo::Foo &) { return 13; }); } { m.attr("foreign_type_alias") = m.attr("foreign_method_arg").attr("Bar2"); m.attr("foreign_class_alias") = m.attr("foreign_return").attr("get_foo"); } m.def( "foreign_enum_default", [](const py::object & /* color */) {}, py::arg("color") = demo::sublibA::ConsoleForegroundColor::Blue ); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/classes.cpp000066400000000000000000000023641504552055100274140ustar00rootroot00000000000000#include "modules.h" #include #include #include void bind_classes_module(py::module&&m) { { auto pyOuter = py::class_(m, "Outer"); auto pyInner = py::class_(pyOuter, "Inner"); py::enum_(pyInner, "NestedEnum") .value("ONE", demo::Outer::Inner::NestedEnum::ONE) .value("TWO", demo::Outer::Inner::NestedEnum::TWO); pyInner.def_readwrite("value", &demo::Outer::Inner::value); pyOuter.def_readwrite("inner", &demo::Outer::inner); } { py::class_ pyBase(m, "Base"); pyBase.def_readwrite("name", &demo::Base::name); py::class_(pyBase, "Inner"); py::class_(m, "Derived") .def_readwrite("count", &demo::Derived::count); } { auto pyFoo = py::class_(m, "Foo"); pyFoo.def(py::init<>()).def("f", &demo::Foo::f); py::class_(pyFoo, "FooChild") .def(py::init<>()) .def("g", &demo::Foo::Child::g); } { py::register_exception(m, "CppException"); } } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/eigen.cpp000066400000000000000000000030071504552055100270410ustar00rootroot00000000000000#include "modules.h" #include #include void bind_eigen_module(py::module &&m) { using DenseMatrixR = Eigen::Matrix; using DenseMatrixC = Eigen::Matrix; using FixedMatrixR = Eigen::Matrix; using FixedMatrixC = Eigen::Matrix; using FourRowMatrixR = Eigen::Matrix; using FourColMatrixR = Eigen::Matrix; using SparseMatrixR = Eigen::SparseMatrix; using SparseMatrixC = Eigen::SparseMatrix; m.def("get_matrix_int", [] { return Eigen::Matrix3i{}; }); m.def("get_vector_float64", [] { return Eigen::Vector3d{}; }); m.def("accept_matrix_int", [](Eigen::Matrix3i &) {}); m.def("accept_vector_float64", [](Eigen::Vector3d &) {}); m.def("dense_matrix_r", [](DenseMatrixR &m) { return m; }); m.def("dense_matrix_c", [](DenseMatrixC &m) { return m; }); m.def("four_row_matrix_r", [](FourRowMatrixR &m) { return m; }); m.def("four_col_matrix_r", [](FourColMatrixR &m) { return m; }); m.def("sparse_matrix_r", [](SparseMatrixR &m) { return m; }); m.def("sparse_matrix_c", [](SparseMatrixC &m) { return m; }); m.def("fixed_mutator_r", [](const Eigen::Ref &) {}); m.def("fixed_mutator_c", [](const Eigen::Ref &) {}); m.def("fixed_mutator_a", [](const py::EigenDRef &) {}); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/enum.cpp000066400000000000000000000013611504552055100267170ustar00rootroot00000000000000#include "modules.h" #include void bind_enum_module(py::module&&m) { py::enum_(m, "ConsoleForegroundColor") .value("Green", demo::sublibA::ConsoleForegroundColor::Green) .value("Yellow", demo::sublibA::ConsoleForegroundColor::Yellow) .value("Blue", demo::sublibA::ConsoleForegroundColor::Blue) .value("Magenta", demo::sublibA::ConsoleForegroundColor::Magenta) .value("None_", demo::sublibA::ConsoleForegroundColor::None_) .export_values(); m.def( "accept_defaulted_enum", [](const demo::sublibA::ConsoleForegroundColor &color) {}, py::arg("color") = demo::sublibA::ConsoleForegroundColor::None_); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/flawed_bindings.cpp000066400000000000000000000013571504552055100310770ustar00rootroot00000000000000#include "modules.h" namespace { struct Unbound {}; enum Enum { ONE = 1, TWO = 2 }; } // namespace void bind_flawed_bindings_module(py::module&& m) { // This submodule will have C++ signatures in python docstrings to emulate // common mistakes in using pybind11 m.def("get_unbound_type", [] { return Unbound{}; }); m.def("accept_unbound_type", [](std::pair) { return 0; }); m.def("accept_unbound_enum", [](Enum) { return 0; }); py::class_(m, "Unbound"); py::class_(m, "Enum"); m.def( "accept_unbound_type_defaulted", [](Unbound) { return 0; }, py::arg("x") = Unbound{}); m.def( "accept_unbound_enum_defaulted", [](Enum) { return 0; }, py::arg("x") = Enum::ONE); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/functions.cpp000066400000000000000000000057141504552055100277710ustar00rootroot00000000000000#include "modules.h" #if PYBIND11_VERSION_AT_LEAST(2, 12) #include #endif #include #include #include namespace { void generic(const py::args &args, const py::kwargs &kwargs) {} class Foo { int x; public: explicit Foo(int x) : x(x) {} }; }; // namespace void bind_functions_module(py::module &&m) { m.def("add", demo::sublibA::add); { m.def( "mul", [](int x, int y) { return x * y; }, "Multiply x and y (int)", py::arg("x"), py::arg("y")); m.def( "mul", [](double p, double q) { return p * q; }, "Multiply p and q (double)", py::arg("p"), py::arg("q")); } m.def("func_w_anon_args", [](int x, int y, int z) {}); #if PYBIND11_VERSION_AT_LEAST(2, 6) m.def( "func_w_named_pos_args", [](int x, int y, int z) {}, py::arg("x"), py::arg("y"), py::arg("z"), py::pos_only()); m.def( "pos_kw_only_mix", [](int i, int j, int k) { return py::make_tuple(i, j, k); }, py::arg("i"), py::pos_only(), py::arg("j"), py::kw_only(), py::arg("k")); m.def("generic", &generic); m.def( "pos_kw_only_variadic_mix", [](int i, int j, py::args &, int k, py::kwargs &) { return py::make_tuple(i, j, k); }, py::arg("i"), py::pos_only(), py::arg("j"), py::kw_only(), py::arg("k")); #endif m.def("accept_callable", [](py::function &callable) { return callable(); }); m.def("accept_py_object", [](py::object &object) { return py::str(object); }); m.def("accept_py_handle", [](py::handle &handle) { return py::str(handle); }); #if PYBIND11_VERSION_AT_LEAST(2, 12) m.def("accept_annotated_callable", [](py::typing::Callable &callable) { return callable(13, 42); }); #endif #if PYBIND11_VERSION_AT_LEAST(2, 10) m.def("accept_frozenset", [](const py::frozenset &) {}); #endif m.def("accept_set", [](const py::set &) {}); m.def("default_int_arg", [](int n) {}, py::arg("n") = 5); m.def("default_optional_arg", [](std::optional n) {}, py::arg("n") = py::none()); { auto default_value = py::list(); default_value.append(py::int_(1)); default_value.append(py::int_(2)); default_value.append(py::int_(6)); default_value.append(py::int_(18)); m.def("default_list_arg", [](py::list &l) {}, py::arg("l") = default_value); } py::class_ pyFoo(m, "Foo"); pyFoo.def(py::init()); m.def("default_custom_arg", [](Foo &foo) {}, py::arg_v("foo", Foo(5), "Foo(5)")); m.def("pass_callback", [](std::function &callback) { return Foo(13); }); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/issues.cpp000066400000000000000000000025711504552055100272720ustar00rootroot00000000000000#include "modules.h" void bind_issues_module(py::module &&m) { { // https://github.com/sizmailov/pybind11-stubgen/issues/51 m.def( "issue_51_catastrophic_regex", [](int *, int *) {}, R"docstring( Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable))docstring"); } { // https://github.com/sizmailov/pybind11-stubgen/issues/73 m.def( "issue_73_utf8_doc_chars", [] {}, py::doc("Construct a Ramsete unicycle controller.\n" "\n" "Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make\n" "\n" "convergence more aggressive like a proportional term.\n" "Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger\n" "values provide more damping in response.")); } { m.def("backslashes_should_be_escaped", [] {}, R"docstring( \brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \theta]^T` )docstring"); } { // https://github.com/sizmailov/pybind11-stubgen/issues/86 auto cleanup_callback = []() { /* ... */ }; m.attr("_cleanup") = py::capsule(cleanup_callback); } } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/methods.cpp000066400000000000000000000006101504552055100274120ustar00rootroot00000000000000#include "modules.h" namespace { struct Dummy { int regular_method(int x) { return x + 1; } static int static_method(int x) { return x + 1; } }; } // namespace void bind_methods_module(py::module&& m) { auto &&pyDummy = py::class_(m, "Dummy"); pyDummy.def_static("static_method", &Dummy::static_method); pyDummy.def("regular_method", &Dummy::regular_method); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/numpy.cpp000066400000000000000000000006771504552055100271340ustar00rootroot00000000000000#include #include "modules.h" void bind_numpy_module(py::module&&m) { { m.def("get_ndarray_int", [] { return py::array_t{}; }); m.def("get_ndarray_float64", [] { return py::array_t{}; }); m.def("accept_ndarray_int", [](py::array_t &) {}); m.def("accept_ndarray_float64", [](py::array_t &) {}); } m.def("return_dtype", []() { return py::dtype("(m, "WithoutDoc", "No user docstring provided"); pyDummy.def_readwrite("def_readwrite", &WithoutDoc::value); pyDummy.def_property( "def_property", [](WithoutDoc &self) { return self.value; }, [](WithoutDoc self, int value) { self.value = value; }); pyDummy.def_property_readonly("def_property_readonly", [](WithoutDoc &self) { return self.value; }); pyDummy.def_readonly("def_readonly", &WithoutDoc::value); pyDummy.def_property_static( "def_property_static", [](py::object & /* self */) { return WithoutDoc::static_value; }, [](py::object & /* self */, int value) { WithoutDoc::static_value = value; }); pyDummy.def_property_readonly_static( "def_property_readonly_static", [](py::object & /* self */) { return WithoutDoc::static_value; }); } { auto &&pyDummy = py::class_( m, "WithPropDoc", "User docstring provided only to `def_` calls"); auto &&doc = py::doc("prop doc token"); pyDummy.def_readwrite("def_readwrite", &WithPropDoc::value, doc); pyDummy.def_property( "def_property", [](WithPropDoc &self) { return self.value; }, [](WithPropDoc self, int value) { self.value = value; }, doc); pyDummy.def_property_readonly( "def_property_readonly", [](WithPropDoc &self) { return self.value; }, doc); pyDummy.def_readonly("def_readonly", &WithPropDoc::value, doc); pyDummy.def_property_static( "def_property_static", [](py::object & /* self */) { return WithPropDoc::static_value; }, [](py::object & /* self */, int value) { WithPropDoc::static_value = value; }, doc); pyDummy.def_property_readonly_static( "def_property_readonly_static", [](py::object & /* self */) { return WithPropDoc::static_value; }, doc); } { auto &&pyDummy = py::class_( m, "WithGetterSetterDoc", "User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but " "NOT to `def_*(..., doc)` calls"); auto &&getter_doc = py::doc("getter doc token"); auto &&setter_doc = py::doc("setter doc token"); pyDummy.def_property( "def_property", py::cpp_function([](WithGetterSetterDoc &self) { return self.value; }, getter_doc), py::cpp_function([](WithGetterSetterDoc self, int value) { self.value = value; }, setter_doc)); pyDummy.def_property_readonly( "def_property_readonly", py::cpp_function([](WithGetterSetterDoc &self) { return self.value; }, getter_doc)); pyDummy.def_property_static( "def_property_static", py::cpp_function( [](py::object & /* self */) { return WithGetterSetterDoc::static_value; }, getter_doc), py::cpp_function([](py::object & /* self */, int value) { WithGetterSetterDoc::static_value = value; }, setter_doc)); pyDummy.def_property_readonly_static("def_property_readonly_static", py::cpp_function([](py::object & /* self */) { return WithGetterSetterDoc::static_value; }), getter_doc); } { auto &&pyDummy = py::class_( m, "WithPropAndGetterSetterDoc", "User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and " "to `def_*(, doc)` calls"); auto &&prop_doc = py::doc("prop doc token"); auto &&getter_doc = py::doc("getter doc token"); auto &&setter_doc = py::doc("setter doc token"); pyDummy.def_property( "def_property", py::cpp_function([](WithPropAndGetterSetterDoc &self) { return self.value; }, getter_doc), py::cpp_function( [](WithPropAndGetterSetterDoc self, int value) { self.value = value; }, setter_doc), prop_doc); pyDummy.def_property_readonly( "def_property_readonly", py::cpp_function([](WithPropAndGetterSetterDoc &self) { return self.value; }, getter_doc), prop_doc); pyDummy.def_property_static( "def_property_static", py::cpp_function( [](py::object & /* self */) { return WithPropAndGetterSetterDoc::static_value; }, getter_doc), py::cpp_function([](py::object & /* self */, int value) { WithPropAndGetterSetterDoc::static_value = value; }, setter_doc), prop_doc); pyDummy.def_property_readonly_static( "def_property_readonly_static", py::cpp_function( [](py::object & /* self */) { return WithPropAndGetterSetterDoc::static_value; }, getter_doc), prop_doc); } } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/stl.cpp000066400000000000000000000010461504552055100265550ustar00rootroot00000000000000#include #include #include "modules.h" #include #include #include void bind_stl_module(py::module &&m) { m.def("std_map", [] { return std::map>{}; }); m.def("std_vector", [] { return std::vector>{}; }); m.def("std_array", [](const std::array &a) { return a; }); m.def("std_variant", [](const std::variant> &) {}); m.def("std_optional", [](const std::optional &) {}); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/stl_bind.cpp000066400000000000000000000010251504552055100275460ustar00rootroot00000000000000#include #include #include "modules.h" #include #include void bind_stl_bind_module(py::module&&m) { py::bind_vector>>(m, "VectorPairStringDouble"); py::bind_map>>(m, "MapStringComplex"); m.def("get_complex_map", [] { return std::map>{}; }); m.def("get_vector_of_pairs", [] { return std::vector>{}; }); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/typing.cpp000066400000000000000000000003101504552055100272560ustar00rootroot00000000000000#include "modules.h" void bind_typing_module(py::module &&m) { m.def("get_sequence", [](py::sequence &seq) { return seq; }); m.def("get_buffer", [](py::buffer &buffer) { return buffer; }); } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/modules/values.cpp000066400000000000000000000022511504552055100272510ustar00rootroot00000000000000#include #include "modules.h" #include namespace { class Dummy {}; class Foo {}; } // namespace void bind_values_module(py::module &&m) { { // python module as value auto &&pyDummy = py::class_(m, "Dummy"); pyDummy.def_property_readonly_static( "linalg", [](py::object &) { return py::module::import("numpy.linalg"); }); m.attr("random") = py::module::import("numpy.random"); } { py::list li; li.append(py::none{}); li.append(2); li.append(py::dict{}); m.attr("list_with_none") = li; } { auto pyFoo = py::class_(m, "Foo"); m.attr("foovar") = Foo(); py::list foolist; foolist.append(Foo()); foolist.append(Foo()); m.attr("foolist") = foolist; m.attr("none") = py::none(); } { m.attr("t_10ms") = std::chrono::milliseconds(10); m.attr("t_20ns") = std::chrono::nanoseconds(20); m.attr("t_30s") = std::chrono::seconds(30); m.def("add_day", [](std::chrono::system_clock::time_point &t) { return t + std::chrono::hours(24); }); } } pybind-pybind11-stubgen-ac46c10/tests/py-demo/bindings/src/opaque_types.h000066400000000000000000000004531504552055100264670ustar00rootroot00000000000000#pragma once #include #include #include using MapStringComplex = std::map>; using VectorPairStringDouble = std::vector>; PYBIND11_MAKE_OPAQUE(MapStringComplex); PYBIND11_MAKE_OPAQUE(VectorPairStringDouble); pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/000077500000000000000000000000001504552055100221365ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/__init__.py000066400000000000000000000002661504552055100242530ustar00rootroot00000000000000# Mock common layout library mixed of C/C++ core and pure python # C++-based modules are prefixed with underscore from . import pure_python from .core import * # version = "0.0.0" pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/core.py000066400000000000000000000000311504552055100234320ustar00rootroot00000000000000from ._bindings import * pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/000077500000000000000000000000001504552055100245125ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/__init__.py000066400000000000000000000000511504552055100266170ustar00rootroot00000000000000from . import classes, functions, values pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/classes.py000066400000000000000000000001451504552055100265210ustar00rootroot00000000000000class A: """A""" class B(A): """B""" class C(B): """C""" class X(object): pass pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/functions.py000066400000000000000000000013001504552055100270660ustar00rootroot00000000000000from __future__ import annotations import sys import typing if sys.version_info[:2] >= (3, 8): from .functions_3_8_plus import args_mix if sys.version_info[:2] >= (3, 9): from .functions_3_9_plus import generic_alias_annotation class _Dummy: @staticmethod def foo(): return 42 def search(a: int, b: list[int]) -> int: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=lambda val: 0): ... def static_method_as_default_arg(callback=_Dummy.foo): ... def accept_frozenset(arg: typing.FrozenSet[int | float]) -> int | None: pass pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/functions_3_8_plus.py000066400000000000000000000002611504552055100306070ustar00rootroot00000000000000import typing def args_mix( a: int, b: float = 0.5, /, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/functions_3_9_plus.py000066400000000000000000000001501504552055100306050ustar00rootroot00000000000000def generic_alias_annotation( a: list[tuple[int]], b: dict[int, str], ) -> list[float]: ... pybind-pybind11-stubgen-ac46c10/tests/py-demo/demo/pure_python/values.py000066400000000000000000000001421504552055100263600ustar00rootroot00000000000000from typing import Callable, Dict callables_dict: Dict[str, Callable] = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/py-demo/pyproject.toml000066400000000000000000000002111504552055100241200ustar00rootroot00000000000000[build-system] requires = [ "setuptools>=42", "wheel", "ninja", "cmake>=3.12", ] build-backend = "setuptools.build_meta" pybind-pybind11-stubgen-ac46c10/tests/py-demo/setup.py000066400000000000000000000132741504552055100227330ustar00rootroot00000000000000import os import re import subprocess import sys from pathlib import Path from setuptools import Extension, find_packages, setup from setuptools.command.build_ext import build_ext # Convert distutils Windows platform specifiers to CMake -A arguments PLAT_TO_CMAKE = { "win32": "Win32", "win-amd64": "x64", "win-arm32": "ARM", "win-arm64": "ARM64", } # A CMakeExtension needs a sourcedir instead of a file list. # The name must be the _single_ output extension from the CMake build. # If you need multiple extensions, see scikit-build. class CMakeExtension(Extension): def __init__(self, name: str, sourcedir: str = "") -> None: super().__init__(name, sources=[]) self.sourcedir = os.fspath(Path(sourcedir).resolve()) class CMakeBuild(build_ext): def build_extension(self, ext: CMakeExtension) -> None: # Must be in this form due to bug in .resolve() only fixed in Python 3.10+ ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name) extdir = ext_fullpath.parent.resolve() # Using this requires trailing slash for auto-detection & inclusion of # auxiliary "native" libs debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug cfg = "Debug" if debug else "Release" # CMake lets you override the generator - we need to check this. # Can be set with Conda-Build, for example. cmake_generator = os.environ.get("CMAKE_GENERATOR", "") # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code # from Python. cmake_args = [ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", f"-DPYTHON_EXECUTABLE={sys.executable}", f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm ] build_args = [] # Adding CMake arguments set as environment variable # (needed e.g. to build for ARM OSx on conda-forge) if "CMAKE_ARGS" in os.environ: cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] if "CMAKE_PREFIX_PATH" in os.environ: cmake_args += [f"-DCMAKE_PREFIX_PATH={os.environ['CMAKE_PREFIX_PATH']}"] # In this example, we pass in the version to C++. You might not need to. cmake_args += [f"-DEXAMPLE_VERSION_INFO={self.distribution.get_version()}"] if self.compiler.compiler_type != "msvc": # Using Ninja-build since it a) is available as a wheel and b) # multithreads automatically. MSVC would require all variables be # exported for Ninja to pick it up, which is a little tricky to do. # Users can override the generator with CMAKE_GENERATOR in CMake # 3.15+. if not cmake_generator or cmake_generator == "Ninja": try: import ninja ninja_executable_path = Path(ninja.BIN_DIR) / "ninja" cmake_args += [ "-GNinja", f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}", ] except ImportError: pass else: # Single config generators are handled "normally" single_config = any(x in cmake_generator for x in {"NMake", "Ninja"}) # CMake allows an arch-in-generator style for backward compatibility contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"}) # Specify the arch if using MSVC generator, but only if it doesn't # contain a backward-compatibility arch spec already in the # generator name. if not single_config and not contains_arch: cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]] # Multi-config generators have a different way to specify configs if not single_config: cmake_args += [ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}" ] build_args += ["--config", cfg] if sys.platform.startswith("darwin"): # Cross-compile support for macOS - respect ARCHFLAGS if set archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", "")) if archs: cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level # across all generators. if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: # self.parallel is a Python 3 only way to set parallel jobs by hand # using -j in the build_ext call, not supported by pip or PyPA-build. if hasattr(self, "parallel") and self.parallel: # CMake 3.12+ only. build_args += [f"-j{self.parallel}"] build_temp = Path(self.build_temp) / ext.name if not build_temp.exists(): build_temp.mkdir(parents=True) subprocess.run( ["cmake", ext.sourcedir, *cmake_args], cwd=build_temp, check=True ) subprocess.run( ["cmake", "--build", ".", *build_args], cwd=build_temp, check=True ) setup( name="py-demo", version="0.0.0", author="Sergei Izmailov", author_email="sergei.a.izmailov@gmail.com", description="Demo package to test stub generation", long_description=open("README.rst").read(), ext_modules=[CMakeExtension("demo._bindings", "bindings")], packages=find_packages(), cmdclass=dict(build_ext=CMakeBuild), url="https://github.com/sizmailov/pybind11-project-example", zip_safe=False, install_requires=["numpy"], ) pybind-pybind11-stubgen-ac46c10/tests/stubs/000077500000000000000000000000001504552055100210005ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.10000077700000000000000000000000001504552055100244422python-3.11ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.11000077700000000000000000000000001504552055100244442python-3.12ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/000077500000000000000000000000001504552055100227025ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/000077500000000000000000000000001504552055100250765ustar00rootroot00000000000000numpy-array-wrap-with-annotated/000077500000000000000000000000001504552055100331765ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11demo/000077500000000000000000000000001504552055100341225ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated__init__.pyi000066400000000000000000000011261504552055100364040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100360565ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000007301504552055100403400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100374775ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100417670ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100425060ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100427060ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100443740ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100440440ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100446150ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100432520ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100435360ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100402350ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner eigen.pyi000066400000000000000000000057671504552055100377070ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy import pybind11_stubgen.typing_ext import scipy.sparse __all__: list[str] = [ "accept_matrix_int", "accept_vector_float64", "dense_matrix_c", "dense_matrix_r", "fixed_mutator_a", "fixed_mutator_c", "fixed_mutator_r", "four_col_matrix_r", "four_row_matrix_r", "get_matrix_int", "get_vector_float64", "sparse_matrix_c", "sparse_matrix_r", ] def accept_matrix_int( arg0: typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ] ) -> None: ... def accept_vector_float64( arg0: typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ] ) -> None: ... def dense_matrix_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def dense_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def fixed_mutator_a( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, ] ) -> None: ... def fixed_mutator_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.f_contiguous, ] ) -> None: ... def fixed_mutator_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.c_contiguous, ] ) -> None: ... def four_col_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ]: ... def four_row_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ]: ... def get_matrix_int() -> typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ]: ... def get_vector_float64() -> typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ]: ... def sparse_matrix_c( arg0: typing.Annotated[scipy.sparse.csc_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... def sparse_matrix_r( arg0: typing.Annotated[scipy.sparse.csr_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... enum.pyi000066400000000000000000000042501504552055100375460ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100417160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000031311504552055100406070ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_callable", "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_frozenset(arg0: frozenset) -> None: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100401140ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100402410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... numpy.pyi000066400000000000000000000011441504552055100377510ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy __all__: list[str] = [ "accept_ndarray_float64", "accept_ndarray_int", "get_ndarray_float64", "get_ndarray_int", "return_dtype", ] def accept_ndarray_float64( arg0: typing.Annotated[numpy.ndarray, numpy.float64] ) -> None: ... def accept_ndarray_int(arg0: typing.Annotated[numpy.ndarray, numpy.int32]) -> None: ... def get_ndarray_float64() -> typing.Annotated[numpy.ndarray, numpy.float64]: ... def get_ndarray_int() -> typing.Annotated[numpy.ndarray, numpy.int32]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... properties.pyi000066400000000000000000000045431504552055100410030ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl.pyi000066400000000000000000000011051504552055100374000ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import pybind11_stubgen.typing_ext __all__: list[str] = [ "std_array", "std_map", "std_optional", "std_variant", "std_vector", ] def std_array( arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] ) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... def std_map() -> dict[int, complex]: ... def std_optional(arg0: int | None) -> None: ... def std_variant(arg0: int | float | tuple[int, int]) -> None: ... def std_vector() -> list[tuple[int, float]]: ... stl_bind.pyi000066400000000000000000000075531504552055100404110ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView[str, complex]: ... def keys(self) -> typing.KeysView[str]: ... def values(self) -> typing.ValuesView[complex]: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100401110ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100401020ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100356030ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100364765ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000003611504552055100407600ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values __all__: list[str] = [ "classes", "functions", "functions_3_8_plus", "functions_3_9_plus", "values", ] classes.pyi000066400000000000000000000003071504552055100406560ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000015561504552055100412400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation __all__: list[str] = [ "accept_frozenset", "args_mix", "builtin_function_as_default_arg", "function_as_default_arg", "generic_alias_annotation", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... functions_3_8_plus.pyi000066400000000000000000000004001504552055100427370ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import typing as typing __all__: list[str] = ["args_mix", "typing"] def args_mix( a: int, b: float = 0.5, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... functions_3_9_plus.pyi000066400000000000000000000002601504552055100427440ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["generic_alias_annotation"] def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... values.pyi000066400000000000000000000001741504552055100405220ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.11/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/000077500000000000000000000000001504552055100250775ustar00rootroot00000000000000numpy-array-wrap-with-annotated/000077500000000000000000000000001504552055100331775ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12demo/000077500000000000000000000000001504552055100341235ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated__init__.pyi000066400000000000000000000011261504552055100364050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100360575ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000007301504552055100403410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100375005ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100417700ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100425070ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100427070ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100443750ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100440450ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100446160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100432530ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100435370ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100402360ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner eigen.pyi000066400000000000000000000057671504552055100377100ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy import pybind11_stubgen.typing_ext import scipy.sparse __all__: list[str] = [ "accept_matrix_int", "accept_vector_float64", "dense_matrix_c", "dense_matrix_r", "fixed_mutator_a", "fixed_mutator_c", "fixed_mutator_r", "four_col_matrix_r", "four_row_matrix_r", "get_matrix_int", "get_vector_float64", "sparse_matrix_c", "sparse_matrix_r", ] def accept_matrix_int( arg0: typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ] ) -> None: ... def accept_vector_float64( arg0: typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ] ) -> None: ... def dense_matrix_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def dense_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def fixed_mutator_a( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, ] ) -> None: ... def fixed_mutator_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.f_contiguous, ] ) -> None: ... def fixed_mutator_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.c_contiguous, ] ) -> None: ... def four_col_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ]: ... def four_row_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ]: ... def get_matrix_int() -> typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ]: ... def get_vector_float64() -> typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ]: ... def sparse_matrix_c( arg0: typing.Annotated[scipy.sparse.csc_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... def sparse_matrix_r( arg0: typing.Annotated[scipy.sparse.csr_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... enum.pyi000066400000000000000000000042501504552055100375470ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100417170ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000033231504552055100406130ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_annotated_callable", "accept_callable", "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_frozenset(arg0: frozenset) -> None: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100401150ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100402420ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... numpy.pyi000066400000000000000000000011441504552055100377520ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy __all__: list[str] = [ "accept_ndarray_float64", "accept_ndarray_int", "get_ndarray_float64", "get_ndarray_int", "return_dtype", ] def accept_ndarray_float64( arg0: typing.Annotated[numpy.ndarray, numpy.float64] ) -> None: ... def accept_ndarray_int(arg0: typing.Annotated[numpy.ndarray, numpy.int32]) -> None: ... def get_ndarray_float64() -> typing.Annotated[numpy.ndarray, numpy.float64]: ... def get_ndarray_int() -> typing.Annotated[numpy.ndarray, numpy.int32]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... properties.pyi000066400000000000000000000045431504552055100410040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl.pyi000066400000000000000000000011051504552055100374010ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import pybind11_stubgen.typing_ext __all__: list[str] = [ "std_array", "std_map", "std_optional", "std_variant", "std_vector", ] def std_array( arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] ) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... def std_map() -> dict[int, complex]: ... def std_optional(arg0: int | None) -> None: ... def std_variant(arg0: int | float | tuple[int, int]) -> None: ... def std_vector() -> list[tuple[int, float]]: ... stl_bind.pyi000066400000000000000000000075471504552055100404150ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator[str]: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView: ... def keys(self) -> typing.KeysView: ... def values(self) -> typing.ValuesView: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100401120ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100401030ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100356040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100364775ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000003611504552055100407610ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values __all__: list[str] = [ "classes", "functions", "functions_3_8_plus", "functions_3_9_plus", "values", ] classes.pyi000066400000000000000000000003071504552055100406570ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000015561504552055100412410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation __all__: list[str] = [ "accept_frozenset", "args_mix", "builtin_function_as_default_arg", "function_as_default_arg", "generic_alias_annotation", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... functions_3_8_plus.pyi000066400000000000000000000004001504552055100427400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import typing as typing __all__: list[str] = ["args_mix", "typing"] def args_mix( a: int, b: float = 0.5, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... functions_3_9_plus.pyi000066400000000000000000000002601504552055100427450ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["generic_alias_annotation"] def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... values.pyi000066400000000000000000000001741504552055100405230ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.12/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/000077500000000000000000000000001504552055100251005ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/000077500000000000000000000000001504552055100317235ustar00rootroot00000000000000demo/000077500000000000000000000000001504552055100325705ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var__init__.pyi000066400000000000000000000011261504552055100350520ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100345245ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo__init__.pyi000066400000000000000000000007301504552055100370060ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100361455ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100404350ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100411540ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100413540ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100430420ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100425120ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100432630ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100417200ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100422040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100367030ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner eigen.pyi000066400000000000000000000044131504552055100363400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing import numpy import scipy.sparse __all__: list[str] = [ "accept_matrix_int", "accept_vector_float64", "dense_matrix_c", "dense_matrix_r", "fixed_mutator_a", "fixed_mutator_c", "fixed_mutator_r", "four_col_matrix_r", "four_row_matrix_r", "get_matrix_int", "get_vector_float64", "sparse_matrix_c", "sparse_matrix_r", ] M = typing.TypeVar("M", bound=int) N = typing.TypeVar("N", bound=int) def accept_matrix_int( arg0: numpy.ndarray[ tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.int32] ] ) -> None: ... def accept_vector_float64( arg0: numpy.ndarray[ tuple[typing.Literal[3], typing.Literal[1]], numpy.dtype[numpy.float64] ] ) -> None: ... def dense_matrix_c( arg0: numpy.ndarray[tuple[M, N], numpy.dtype[numpy.float32]] ) -> numpy.ndarray[tuple[M, N], numpy.dtype[numpy.float32]]: ... def dense_matrix_r( arg0: numpy.ndarray[tuple[M, N], numpy.dtype[numpy.float32]] ) -> numpy.ndarray[tuple[M, N], numpy.dtype[numpy.float32]]: ... def fixed_mutator_a( arg0: numpy.ndarray[ tuple[typing.Literal[5], typing.Literal[6]], numpy.dtype[numpy.float32] ] ) -> None: ... def fixed_mutator_c( arg0: numpy.ndarray[ tuple[typing.Literal[5], typing.Literal[6]], numpy.dtype[numpy.float32] ] ) -> None: ... def fixed_mutator_r( arg0: numpy.ndarray[ tuple[typing.Literal[5], typing.Literal[6]], numpy.dtype[numpy.float32] ] ) -> None: ... def four_col_matrix_r( arg0: numpy.ndarray[tuple[M, typing.Literal[4]], numpy.dtype[numpy.float32]] ) -> numpy.ndarray[tuple[M, typing.Literal[4]], numpy.dtype[numpy.float32]]: ... def four_row_matrix_r( arg0: numpy.ndarray[tuple[typing.Literal[4], N], numpy.dtype[numpy.float32]] ) -> numpy.ndarray[tuple[typing.Literal[4], N], numpy.dtype[numpy.float32]]: ... def get_matrix_int() -> numpy.ndarray[ tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.int32] ]: ... def get_vector_float64() -> numpy.ndarray[ tuple[typing.Literal[3], typing.Literal[1]], numpy.dtype[numpy.float64] ]: ... def sparse_matrix_c(arg0: scipy.sparse.csc_matrix) -> scipy.sparse.csc_matrix: ... def sparse_matrix_r(arg0: scipy.sparse.csr_matrix) -> scipy.sparse.csr_matrix: ... enum.pyi000066400000000000000000000042501504552055100362140ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100403640ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000033231504552055100372600ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_annotated_callable", "accept_callable", "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_frozenset(arg0: frozenset) -> None: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100365620ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100367070ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... numpy.pyi000066400000000000000000000012061504552055100364160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing import numpy __all__: list[str] = [ "accept_ndarray_float64", "accept_ndarray_int", "get_ndarray_float64", "get_ndarray_int", "return_dtype", ] def accept_ndarray_float64( arg0: numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]] ) -> None: ... def accept_ndarray_int( arg0: numpy.ndarray[typing.Any, numpy.dtype[numpy.int32]] ) -> None: ... def get_ndarray_float64() -> numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]: ... def get_ndarray_int() -> numpy.ndarray[typing.Any, numpy.dtype[numpy.int32]]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... properties.pyi000066400000000000000000000045431504552055100374510ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl.pyi000066400000000000000000000011051504552055100360460ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing import pybind11_stubgen.typing_ext __all__: list[str] = [ "std_array", "std_map", "std_optional", "std_variant", "std_vector", ] def std_array( arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] ) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... def std_map() -> dict[int, complex]: ... def std_optional(arg0: int | None) -> None: ... def std_variant(arg0: int | float | tuple[int, int]) -> None: ... def std_vector() -> list[tuple[int, float]]: ... stl_bind.pyi000066400000000000000000000075471504552055100370620ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator[str]: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView: ... def keys(self) -> typing.KeysView: ... def values(self) -> typing.ValuesView: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100365570ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100365500ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100342510ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100351445ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo__init__.pyi000066400000000000000000000003611504552055100374260ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values __all__: list[str] = [ "classes", "functions", "functions_3_8_plus", "functions_3_9_plus", "values", ] classes.pyi000066400000000000000000000003071504552055100373240ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000015561504552055100377060ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation __all__: list[str] = [ "accept_frozenset", "args_mix", "builtin_function_as_default_arg", "function_as_default_arg", "generic_alias_annotation", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... functions_3_8_plus.pyi000066400000000000000000000004001504552055100414050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/pure_pythonfrom __future__ import annotations import typing as typing __all__: list[str] = ["args_mix", "typing"] def args_mix( a: int, b: float = 0.5, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... functions_3_9_plus.pyi000066400000000000000000000002601504552055100414120ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["generic_alias_annotation"] def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... values.pyi000066400000000000000000000001741504552055100371700ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-use-type-var/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} numpy-array-wrap-with-annotated/000077500000000000000000000000001504552055100332005ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13demo/000077500000000000000000000000001504552055100341245ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated__init__.pyi000066400000000000000000000011261504552055100364060ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100360605ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000007301504552055100403420ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100375015ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100417710ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100425100ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100427100ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100443760ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100440460ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100446170ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100432540ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100435400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100402370ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner eigen.pyi000066400000000000000000000057671504552055100377110ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy import pybind11_stubgen.typing_ext import scipy.sparse __all__: list[str] = [ "accept_matrix_int", "accept_vector_float64", "dense_matrix_c", "dense_matrix_r", "fixed_mutator_a", "fixed_mutator_c", "fixed_mutator_r", "four_col_matrix_r", "four_row_matrix_r", "get_matrix_int", "get_vector_float64", "sparse_matrix_c", "sparse_matrix_r", ] def accept_matrix_int( arg0: typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ] ) -> None: ... def accept_vector_float64( arg0: typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ] ) -> None: ... def dense_matrix_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def dense_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def fixed_mutator_a( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, ] ) -> None: ... def fixed_mutator_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.f_contiguous, ] ) -> None: ... def fixed_mutator_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.c_contiguous, ] ) -> None: ... def four_col_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ]: ... def four_row_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ]: ... def get_matrix_int() -> typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ]: ... def get_vector_float64() -> typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ]: ... def sparse_matrix_c( arg0: typing.Annotated[scipy.sparse.csc_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... def sparse_matrix_r( arg0: typing.Annotated[scipy.sparse.csr_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... enum.pyi000066400000000000000000000042501504552055100375500ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100417200ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000033231504552055100406140ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_annotated_callable", "accept_callable", "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_frozenset(arg0: frozenset) -> None: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100401160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100402430ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... numpy.pyi000066400000000000000000000011441504552055100377530ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy __all__: list[str] = [ "accept_ndarray_float64", "accept_ndarray_int", "get_ndarray_float64", "get_ndarray_int", "return_dtype", ] def accept_ndarray_float64( arg0: typing.Annotated[numpy.ndarray, numpy.float64] ) -> None: ... def accept_ndarray_int(arg0: typing.Annotated[numpy.ndarray, numpy.int32]) -> None: ... def get_ndarray_float64() -> typing.Annotated[numpy.ndarray, numpy.float64]: ... def get_ndarray_int() -> typing.Annotated[numpy.ndarray, numpy.int32]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... properties.pyi000066400000000000000000000045431504552055100410050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl.pyi000066400000000000000000000011051504552055100374020ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import pybind11_stubgen.typing_ext __all__: list[str] = [ "std_array", "std_map", "std_optional", "std_variant", "std_vector", ] def std_array( arg0: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] ) -> typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)]: ... def std_map() -> dict[int, complex]: ... def std_optional(arg0: int | None) -> None: ... def std_variant(arg0: int | float | tuple[int, int]) -> None: ... def std_vector() -> list[tuple[int, float]]: ... stl_bind.pyi000066400000000000000000000075471504552055100404160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator[str]: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView: ... def keys(self) -> typing.KeysView: ... def values(self) -> typing.ValuesView: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100401130ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100401040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100356050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100365005ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000003611504552055100407620ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values __all__: list[str] = [ "classes", "functions", "functions_3_8_plus", "functions_3_9_plus", "values", ] classes.pyi000066400000000000000000000003071504552055100406600ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000015561504552055100412420ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation __all__: list[str] = [ "accept_frozenset", "args_mix", "builtin_function_as_default_arg", "function_as_default_arg", "generic_alias_annotation", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... functions_3_8_plus.pyi000066400000000000000000000004001504552055100427410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import typing as typing __all__: list[str] = ["args_mix", "typing"] def args_mix( a: int, b: float = 0.5, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... functions_3_9_plus.pyi000066400000000000000000000002601504552055100427460ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["generic_alias_annotation"] def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... values.pyi000066400000000000000000000001741504552055100405240ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/000077500000000000000000000000001504552055100250255ustar00rootroot00000000000000numpy-array-wrap-with-annotated/000077500000000000000000000000001504552055100331255ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9demo/000077500000000000000000000000001504552055100340515ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated__init__.pyi000066400000000000000000000011261504552055100363330ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100360055ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000007301504552055100402670ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100374265ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100417160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100424350ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100426350ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100443230ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100437730ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100445440ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100432010ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100434650ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100401640ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner eigen.pyi000066400000000000000000000057671504552055100376360ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy import pybind11_stubgen.typing_ext import scipy.sparse __all__: list[str] = [ "accept_matrix_int", "accept_vector_float64", "dense_matrix_c", "dense_matrix_r", "fixed_mutator_a", "fixed_mutator_c", "fixed_mutator_r", "four_col_matrix_r", "four_row_matrix_r", "get_matrix_int", "get_vector_float64", "sparse_matrix_c", "sparse_matrix_r", ] def accept_matrix_int( arg0: typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ] ) -> None: ... def accept_vector_float64( arg0: typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ] ) -> None: ... def dense_matrix_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def dense_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def fixed_mutator_a( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, ] ) -> None: ... def fixed_mutator_c( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.f_contiguous, ] ) -> None: ... def fixed_mutator_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.c_contiguous, ] ) -> None: ... def four_col_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ]: ... def four_row_matrix_r( arg0: typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ] ) -> typing.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ]: ... def get_matrix_int() -> typing.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ]: ... def get_vector_float64() -> typing.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ]: ... def sparse_matrix_c( arg0: typing.Annotated[scipy.sparse.csc_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... def sparse_matrix_r( arg0: typing.Annotated[scipy.sparse.csr_matrix, numpy.float32] ) -> typing.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... enum.pyi000066400000000000000000000042501504552055100374750ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100416450ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000030161504552055100405400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_callable", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100400430ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100401700ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... numpy.pyi000066400000000000000000000011441504552055100377000ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy __all__: list[str] = [ "accept_ndarray_float64", "accept_ndarray_int", "get_ndarray_float64", "get_ndarray_int", "return_dtype", ] def accept_ndarray_float64( arg0: typing.Annotated[numpy.ndarray, numpy.float64] ) -> None: ... def accept_ndarray_int(arg0: typing.Annotated[numpy.ndarray, numpy.int32]) -> None: ... def get_ndarray_float64() -> typing.Annotated[numpy.ndarray, numpy.float64]: ... def get_ndarray_int() -> typing.Annotated[numpy.ndarray, numpy.int32]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... properties.pyi000066400000000000000000000045431504552055100407320ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl.pyi000066400000000000000000000006511504552055100373340ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "std_array", "std_map", "std_optional", "std_variant", "std_vector", ] def std_array(arg0: list[int[3]]) -> list[int[3]]: ... def std_map() -> dict[int, complex]: ... def std_optional(arg0: int | None) -> None: ... def std_variant(arg0: int | float | tuple[int, int]) -> None: ... def std_vector() -> list[tuple[int, float]]: ... stl_bind.pyi000066400000000000000000000076051504552055100403360ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView[MapStringComplex]: ... def keys(self) -> typing.KeysView[MapStringComplex]: ... def values(self) -> typing.ValuesView[MapStringComplex]: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100400400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100400310ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100355320ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100364255ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000003611504552055100407070ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, functions_3_8_plus, functions_3_9_plus, values __all__: list[str] = [ "classes", "functions", "functions_3_8_plus", "functions_3_9_plus", "values", ] classes.pyi000066400000000000000000000003071504552055100406050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000015561504552055100411670ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing from demo.pure_python.functions_3_8_plus import args_mix from demo.pure_python.functions_3_9_plus import generic_alias_annotation __all__: list[str] = [ "accept_frozenset", "args_mix", "builtin_function_as_default_arg", "function_as_default_arg", "generic_alias_annotation", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... functions_3_8_plus.pyi000066400000000000000000000004001504552055100426660ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import typing as typing __all__: list[str] = ["args_mix", "typing"] def args_mix( a: int, b: float = 0.5, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... functions_3_9_plus.pyi000066400000000000000000000002601504552055100426730ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["generic_alias_annotation"] def generic_alias_annotation(a: list[tuple[int]], b: dict[int, str]) -> list[float]: ... values.pyi000066400000000000000000000001741504552055100404510ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/pybind11-v2.9/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.12/requirements.txt000066400000000000000000000001411504552055100261620ustar00rootroot00000000000000black==22.8.0 cmeel-eigen==3.4.0.2 isort==5.10.1 numpy~=1.20 scipy~=1.0 typing_extensions==4.7.1 pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.13000077700000000000000000000000001504552055100244462python-3.12ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/000077500000000000000000000000001504552055100226265ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/000077500000000000000000000000001504552055100250245ustar00rootroot00000000000000numpy-array-wrap-with-annotated/000077500000000000000000000000001504552055100331245ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13demo/000077500000000000000000000000001504552055100340505ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated__init__.pyi000066400000000000000000000011261504552055100363320ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100360045ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000007301504552055100402660ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100374255ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100417150ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100424340ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100426340ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100443220ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100437720ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100445430ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100432000ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100434640ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100401630ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner enum.pyi000066400000000000000000000042501504552055100374740ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100416440ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000033151504552055100405410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_annotated_callable", "accept_callable", "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_frozenset(arg0: frozenset) -> None: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100400420ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100401670ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... properties.pyi000066400000000000000000000045431504552055100407310ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl_bind.pyi000066400000000000000000000075471504552055100403420ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator[str]: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView: ... def keys(self) -> typing.KeysView: ... def values(self) -> typing.ValuesView: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100400370ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100400300ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100355310ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100364245ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000002061504552055100407040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, values __all__: list[str] = ["classes", "functions", "values"] classes.pyi000066400000000000000000000003071504552055100406040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000012731504552055100411620ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing __all__: list[str] = [ "accept_frozenset", "builtin_function_as_default_arg", "function_as_default_arg", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... values.pyi000066400000000000000000000001741504552055100404500ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.7/requirements.txt000066400000000000000000000001411504552055100261060ustar00rootroot00000000000000black==22.8.0 cmeel-eigen==3.4.0.2 isort==5.10.1 numpy~=1.20 scipy~=1.0 typing_extensions==4.7.1 pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/000077500000000000000000000000001504552055100226275ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/000077500000000000000000000000001504552055100250255ustar00rootroot00000000000000numpy-array-wrap-with-annotated/000077500000000000000000000000001504552055100331255ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13demo/000077500000000000000000000000001504552055100340515ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated__init__.pyi000066400000000000000000000011261504552055100363330ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) from . import _bindings, core, pure_python __all__: list[str] = [ "aliases", "classes", "core", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "pure_python", "stl", "stl_bind", "typing", "values", "version", ] version: str = "0.0.0" _bindings/000077500000000000000000000000001504552055100360055ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000007301504552055100402670ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations from . import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] aliases/000077500000000000000000000000001504552055100374265ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings__init__.pyi000066400000000000000000000020771504552055100417160ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import numpy from numpy import random import demo._bindings.enum from demo._bindings.aliases.foreign_method_arg import Bar2 as foreign_type_alias from demo._bindings.aliases.foreign_return import get_foo as foreign_class_alias from . import ( foreign_arg, foreign_attr, foreign_class_member, foreign_method_arg, foreign_method_return, foreign_return, missing_self_arg, ) __all__: list[str] = [ "Color", "Dummy", "foreign_arg", "foreign_attr", "foreign_class_alias", "foreign_class_member", "foreign_enum_default", "foreign_method_arg", "foreign_method_return", "foreign_return", "foreign_type_alias", "func", "local_func_alias", "local_type_alias", "missing_self_arg", "random", ] class Color: pass class Dummy: linalg = numpy.linalg def foreign_enum_default( color: typing.Any = demo._bindings.enum.ConsoleForegroundColor.Blue, ) -> None: ... def func(arg0: int) -> int: ... local_func_alias = func local_type_alias = Color foreign_arg.pyi000066400000000000000000000002371504552055100424350ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["set_foo"] def set_foo(arg0: demo._bindings.classes.Foo) -> int: ... foreign_attr.pyi000066400000000000000000000002631504552055100426350ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["value"] value: demo._bindings.classes.Foo # value = foreign_class_member.pyi000066400000000000000000000003571504552055100443230ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import typing import demo._bindings.classes __all__: list[str] = ["Bar1"] class Bar1: foo: typing.ClassVar[ demo._bindings.classes.Foo ] # value = foreign_method_arg.pyi000066400000000000000000000002621504552055100437730ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar2"] class Bar2: def set_foo(self, arg0: demo._bindings.classes.Foo) -> int: ... foreign_method_return.pyi000066400000000000000000000002651504552055100445440ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar3"] class Bar3: @staticmethod def get_foo() -> demo._bindings.classes.Foo: ... foreign_return.pyi000066400000000000000000000002261504552055100432010ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["get_foo"] def get_foo() -> demo._bindings.classes.Foo: ... missing_self_arg.pyi000066400000000000000000000002541504552055100434650ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindings/aliasesfrom __future__ import annotations import demo._bindings.classes __all__: list[str] = ["Bar4"] class Bar4: def set_foo(self: demo._bindings.classes.Foo) -> int: ... classes.pyi000066400000000000000000000031141504552055100401640ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = ["Base", "CppException", "Derived", "Foo", "Outer"] class Base: class Inner: pass name: str class CppException(Exception): pass class Derived(Base): count: int class Foo: class FooChild: def __init__(self) -> None: ... def g(self) -> None: ... def __init__(self) -> None: ... def f(self) -> None: ... class Outer: class Inner: class NestedEnum: """ Members: ONE TWO """ ONE: typing.ClassVar[Outer.Inner.NestedEnum] # value = TWO: typing.ClassVar[Outer.Inner.NestedEnum] # value = __members__: typing.ClassVar[ dict[str, Outer.Inner.NestedEnum] ] # value = {'ONE': , 'TWO': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... value: Outer.Inner.NestedEnum inner: Outer.Inner eigen.pyi000066400000000000000000000063221504552055100376220ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import numpy import pybind11_stubgen.typing_ext import scipy.sparse import typing_extensions __all__: list[str] = [ "accept_matrix_int", "accept_vector_float64", "dense_matrix_c", "dense_matrix_r", "fixed_mutator_a", "fixed_mutator_c", "fixed_mutator_r", "four_col_matrix_r", "four_row_matrix_r", "get_matrix_int", "get_vector_float64", "sparse_matrix_c", "sparse_matrix_r", ] def accept_matrix_int( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ] ) -> None: ... def accept_vector_float64( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ] ) -> None: ... def dense_matrix_c( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def dense_matrix_r( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ] ) -> typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", "n") ]: ... def fixed_mutator_a( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, ] ) -> None: ... def fixed_mutator_c( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.f_contiguous, ] ) -> None: ... def fixed_mutator_r( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.FixedSize(5, 6), numpy.ndarray.flags.writeable, numpy.ndarray.flags.c_contiguous, ] ) -> None: ... def four_col_matrix_r( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ] ) -> typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize("m", 4) ]: ... def four_row_matrix_r( arg0: typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ] ) -> typing_extensions.Annotated[ numpy.ndarray, numpy.float32, pybind11_stubgen.typing_ext.DynamicSize(4, "n") ]: ... def get_matrix_int() -> typing_extensions.Annotated[ numpy.ndarray, numpy.int32, pybind11_stubgen.typing_ext.FixedSize(3, 3) ]: ... def get_vector_float64() -> typing_extensions.Annotated[ numpy.ndarray, numpy.float64, pybind11_stubgen.typing_ext.FixedSize(3, 1) ]: ... def sparse_matrix_c( arg0: typing_extensions.Annotated[scipy.sparse.csc_matrix, numpy.float32] ) -> typing_extensions.Annotated[scipy.sparse.csc_matrix, numpy.float32]: ... def sparse_matrix_r( arg0: typing_extensions.Annotated[scipy.sparse.csr_matrix, numpy.float32] ) -> typing_extensions.Annotated[scipy.sparse.csr_matrix, numpy.float32]: ... enum.pyi000066400000000000000000000042501504552055100374750ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Blue", "ConsoleForegroundColor", "Green", "Magenta", "None_", "Yellow", "accept_defaulted_enum", ] class ConsoleForegroundColor: """ Members: Green Yellow Blue Magenta None_ """ Blue: typing.ClassVar[ ConsoleForegroundColor ] # value = Green: typing.ClassVar[ ConsoleForegroundColor ] # value = Magenta: typing.ClassVar[ ConsoleForegroundColor ] # value = None_: typing.ClassVar[ ConsoleForegroundColor ] # value = Yellow: typing.ClassVar[ ConsoleForegroundColor ] # value = __members__: typing.ClassVar[ dict[str, ConsoleForegroundColor] ] # value = {'Green': , 'Yellow': , 'Blue': , 'Magenta': , 'None_': } def __eq__(self, other: typing.Any) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: typing.Any) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... def __str__(self) -> str: ... @property def name(self) -> str: ... @property def value(self) -> int: ... def accept_defaulted_enum( color: ConsoleForegroundColor = ConsoleForegroundColor.None_, ) -> None: ... Blue: ConsoleForegroundColor # value = Green: ConsoleForegroundColor # value = Magenta: ConsoleForegroundColor # value = None_: ConsoleForegroundColor # value = Yellow: ConsoleForegroundColor # value = flawed_bindings.pyi000066400000000000000000000010521504552055100416450ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = [ "Enum", "Unbound", "accept_unbound_enum", "accept_unbound_enum_defaulted", "accept_unbound_type", "accept_unbound_type_defaulted", "get_unbound_type", ] class Enum: pass class Unbound: pass def accept_unbound_enum(arg0: ...) -> int: ... def accept_unbound_enum_defaulted(x: Enum = ...) -> int: ... def accept_unbound_type(arg0: tuple[..., int]) -> int: ... def accept_unbound_type_defaulted(x: Unbound = ...) -> int: ... def get_unbound_type() -> ...: ... functions.pyi000066400000000000000000000033231504552055100405410ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "Foo", "accept_annotated_callable", "accept_callable", "accept_frozenset", "accept_py_handle", "accept_py_object", "accept_set", "add", "default_custom_arg", "default_int_arg", "default_list_arg", "default_optional_arg", "func_w_anon_args", "func_w_named_pos_args", "generic", "mul", "pass_callback", "pos_kw_only_mix", "pos_kw_only_variadic_mix", ] class Foo: def __init__(self, arg0: int) -> None: ... def accept_annotated_callable(arg0: typing.Callable[[int, int], int]) -> typing.Any: ... def accept_callable(arg0: typing.Callable) -> typing.Any: ... def accept_frozenset(arg0: frozenset) -> None: ... def accept_py_handle(arg0: typing.Any) -> str: ... def accept_py_object(arg0: typing.Any) -> str: ... def accept_set(arg0: set) -> None: ... def add(arg0: int, arg1: int) -> int: ... def default_custom_arg(foo: Foo = Foo(5)) -> None: ... def default_int_arg(n: int = 5) -> None: ... def default_list_arg(l: list = [1, 2, 6, 18]) -> None: ... def default_optional_arg(n: int | None = None) -> None: ... def func_w_anon_args(arg0: int, arg1: int, arg2: int) -> None: ... def func_w_named_pos_args(x: int, y: int, z: int) -> None: ... def generic(*args, **kwargs) -> None: ... @typing.overload def mul(x: int, y: int) -> int: """ Multiply x and y (int) """ @typing.overload def mul(p: float, q: float) -> float: """ Multiply p and q (double) """ def pass_callback(arg0: typing.Callable[[Foo], Foo]) -> Foo: ... def pos_kw_only_mix(i: int, /, j: int, *, k: int) -> tuple: ... def pos_kw_only_variadic_mix(i: int, /, j: int, *args, k: int, **kwargs) -> tuple: ... issues.pyi000066400000000000000000000017021504552055100400430ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "backslashes_should_be_escaped", "issue_51_catastrophic_regex", "issue_73_utf8_doc_chars", ] def backslashes_should_be_escaped() -> None: """ \\brief A brief description of this function. A detailed description of this function. Here's some reStructuredText: :math:`x = [x, y, \\theta]^T` """ def issue_51_catastrophic_regex(arg0: int, arg1: int) -> None: """ Use-case: issue_51(os.get_handle_inheritable, os.set_handle_inheritable) """ def issue_73_utf8_doc_chars() -> None: """ Construct a Ramsete unicycle controller. Tuning parameter (b > 0 radΒ²/mΒ²) for which larger values make convergence more aggressive like a proportional term. Tuning parameter (0 rad⁻¹ < zeta < 1 rad⁻¹) for which larger values provide more damping in response. """ _cleanup: typing.Any # value = methods.pyi000066400000000000000000000003041504552055100401700ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations __all__: list[str] = ["Dummy"] class Dummy: @staticmethod def static_method(arg0: int) -> int: ... def regular_method(self, arg0: int) -> int: ... numpy.pyi000066400000000000000000000012651504552055100377040ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import numpy import typing_extensions __all__: list[str] = [ "accept_ndarray_float64", "accept_ndarray_int", "get_ndarray_float64", "get_ndarray_int", "return_dtype", ] def accept_ndarray_float64( arg0: typing_extensions.Annotated[numpy.ndarray, numpy.float64] ) -> None: ... def accept_ndarray_int( arg0: typing_extensions.Annotated[numpy.ndarray, numpy.int32] ) -> None: ... def get_ndarray_float64() -> typing_extensions.Annotated[ numpy.ndarray, numpy.float64 ]: ... def get_ndarray_int() -> typing_extensions.Annotated[numpy.ndarray, numpy.int32]: ... def return_dtype() -> numpy.dtype[typing.Any]: ... properties.pyi000066400000000000000000000045431504552055100407320ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "WithGetterSetterDoc", "WithPropAndGetterSetterDoc", "WithPropDoc", "WithoutDoc", ] class WithGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters, but NOT to `def_*(..., doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ getter doc token """ @def_property.setter def def_property(self, arg1: int) -> None: """ setter doc token """ @property def def_property_readonly(self) -> int: """ getter doc token """ class WithPropAndGetterSetterDoc: """ User docstring provided via pybind11::cpp_function(..., doc) to getters/setters and to `def_*(, doc)` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ class WithPropDoc: """ User docstring provided only to `def_` calls """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 @property def def_property(self) -> int: """ prop doc token """ @def_property.setter def def_property(self, arg1: int) -> None: ... @property def def_property_readonly(self) -> int: """ prop doc token """ @property def def_readonly(self) -> int: """ prop doc token """ @property def def_readwrite(self) -> int: """ prop doc token """ @def_readwrite.setter def def_readwrite(self, arg0: int) -> None: ... class WithoutDoc: """ No user docstring provided """ def_property_readonly_static: typing.ClassVar[int] = 0 def_property_static: typing.ClassVar[int] = 0 def_property: int def_readwrite: int @property def def_property_readonly(self) -> int: ... @property def def_readonly(self) -> int: ... stl.pyi000066400000000000000000000012101504552055100373240ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import pybind11_stubgen.typing_ext import typing_extensions __all__: list[str] = [ "std_array", "std_map", "std_optional", "std_variant", "std_vector", ] def std_array( arg0: typing_extensions.Annotated[ list[int], pybind11_stubgen.typing_ext.FixedSize(3) ] ) -> typing_extensions.Annotated[ list[int], pybind11_stubgen.typing_ext.FixedSize(3) ]: ... def std_map() -> dict[int, complex]: ... def std_optional(arg0: int | None) -> None: ... def std_variant(arg0: int | float | tuple[int, int]) -> None: ... def std_vector() -> list[tuple[int, float]]: ... stl_bind.pyi000066400000000000000000000075471504552055100403430ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing __all__: list[str] = [ "MapStringComplex", "VectorPairStringDouble", "get_complex_map", "get_vector_of_pairs", ] class MapStringComplex: def __bool__(self) -> bool: """ Check whether the map is nonempty """ @typing.overload def __contains__(self, arg0: str) -> bool: ... @typing.overload def __contains__(self, arg0: typing.Any) -> bool: ... def __delitem__(self, arg0: str) -> None: ... def __getitem__(self, arg0: str) -> complex: ... def __init__(self) -> None: ... def __iter__(self) -> typing.Iterator[str]: ... def __len__(self) -> int: ... def __repr__(self) -> str: """ Return the canonical string representation of this map. """ def __setitem__(self, arg0: str, arg1: complex) -> None: ... def items(self) -> typing.ItemsView: ... def keys(self) -> typing.KeysView: ... def values(self) -> typing.ValuesView: ... class VectorPairStringDouble: __hash__: typing.ClassVar[None] = None def __bool__(self) -> bool: """ Check whether the list is nonempty """ def __contains__(self, x: tuple[str, float]) -> bool: """ Return true the container contains ``x`` """ @typing.overload def __delitem__(self, arg0: int) -> None: """ Delete the list elements at index ``i`` """ @typing.overload def __delitem__(self, arg0: slice) -> None: """ Delete list elements using a slice object """ def __eq__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __getitem__(self, s: slice) -> VectorPairStringDouble: """ Retrieve list elements using a slice object """ @typing.overload def __getitem__(self, arg0: int) -> tuple[str, float]: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: VectorPairStringDouble) -> None: """ Copy constructor """ @typing.overload def __init__(self, arg0: typing.Iterable) -> None: ... def __iter__(self) -> typing.Iterator[tuple[str, float]]: ... def __len__(self) -> int: ... def __ne__(self, arg0: VectorPairStringDouble) -> bool: ... @typing.overload def __setitem__(self, arg0: int, arg1: tuple[str, float]) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: VectorPairStringDouble) -> None: """ Assign list elements using a slice object """ def append(self, x: tuple[str, float]) -> None: """ Add an item to the end of the list """ def clear(self) -> None: """ Clear the contents """ def count(self, x: tuple[str, float]) -> int: """ Return the number of times ``x`` appears in the list """ @typing.overload def extend(self, L: VectorPairStringDouble) -> None: """ Extend the list by appending all the items in the given list """ @typing.overload def extend(self, L: typing.Iterable) -> None: """ Extend the list by appending all the items in the given list """ def insert(self, i: int, x: tuple[str, float]) -> None: """ Insert an item at a given position. """ @typing.overload def pop(self) -> tuple[str, float]: """ Remove and return the last item """ @typing.overload def pop(self, i: int) -> tuple[str, float]: """ Remove and return the item at index ``i`` """ def remove(self, x: tuple[str, float]) -> None: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ def get_complex_map() -> MapStringComplex: ... def get_vector_of_pairs() -> VectorPairStringDouble: ... typing.pyi000066400000000000000000000004221504552055100400400ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import typing import typing_extensions __all__: list[str] = ["get_buffer", "get_sequence"] def get_buffer(arg0: typing_extensions.Buffer) -> typing_extensions.Buffer: ... def get_sequence(arg0: typing.Sequence) -> typing.Sequence: ... values.pyi000066400000000000000000000014521504552055100400310ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/_bindingsfrom __future__ import annotations import datetime import numpy from numpy import random __all__: list[str] = [ "Dummy", "Foo", "add_day", "foolist", "foovar", "list_with_none", "none", "random", "t_10ms", "t_20ns", "t_30s", ] class Dummy: linalg = numpy.linalg class Foo: pass def add_day(arg0: datetime.datetime) -> datetime.datetime: ... foolist: list # value = [, ] foovar: Foo # value = list_with_none: list = [None, 2, {}] none = None t_10ms: datetime.timedelta # value = datetime.timedelta(microseconds=10000) t_20ns: datetime.timedelta # value = datetime.timedelta(0) t_30s: datetime.timedelta # value = datetime.timedelta(seconds=30) core.pyi000066400000000000000000000007451504552055100355320ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demofrom __future__ import annotations from demo._bindings import ( aliases, classes, eigen, enum, flawed_bindings, functions, issues, methods, numpy, properties, stl, stl_bind, typing, values, ) __all__: list[str] = [ "aliases", "classes", "eigen", "enum", "flawed_bindings", "functions", "issues", "methods", "numpy", "properties", "stl", "stl_bind", "typing", "values", ] pure_python/000077500000000000000000000000001504552055100364255ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo__init__.pyi000066400000000000000000000002601504552055100407050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations from . import classes, functions, functions_3_8_plus, values __all__: list[str] = ["classes", "functions", "functions_3_8_plus", "values"] classes.pyi000066400000000000000000000003071504552055100406050ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["A", "B", "C", "X"] class A: """ A """ class B(A): """ B """ class C(B): """ C """ class X: pass functions.pyi000066400000000000000000000014051504552055100411600ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import sys as sys import typing as typing from demo.pure_python.functions_3_8_plus import args_mix __all__: list[str] = [ "accept_frozenset", "args_mix", "builtin_function_as_default_arg", "function_as_default_arg", "lambda_as_default_arg", "search", "static_method_as_default_arg", "sys", "typing", ] class _Dummy: @staticmethod def foo(): ... def accept_frozenset(arg: frozenset[int | float]) -> int | None: ... def builtin_function_as_default_arg(func: type(len) = len): ... def function_as_default_arg(func: type(search) = search): ... def lambda_as_default_arg(callback=...): ... def search(a: int, b: list[int]) -> int: ... def static_method_as_default_arg(callback=_Dummy.foo): ... functions_3_8_plus.pyi000066400000000000000000000004001504552055100426660ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations import typing as typing __all__: list[str] = ["args_mix", "typing"] def args_mix( a: int, b: float = 0.5, c: str = "", *args: int, x: int = 1, y=int, **kwargs: typing.Dict[int, str], ): ... values.pyi000066400000000000000000000001741504552055100404510ustar00rootroot00000000000000pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/pybind11-v2.13/numpy-array-wrap-with-annotated/demo/pure_pythonfrom __future__ import annotations __all__: list[str] = ["callables_dict"] callables_dict: dict = {"len": len, "int": int} pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.8/requirements.txt000066400000000000000000000001411504552055100261070ustar00rootroot00000000000000black==22.8.0 cmeel-eigen==3.4.0.2 isort==5.10.1 numpy~=1.20 scipy~=1.0 typing_extensions==4.7.1 pybind-pybind11-stubgen-ac46c10/tests/stubs/python-3.9000077700000000000000000000000001504552055100243712python-3.10ustar00rootroot00000000000000