Skip to content

On the way to [pybind11-mypy-demo] #1

@sizmailov

Description

@sizmailov

Pybind demo module

Basics

  • Functions
    • ✔️ w/o args
    • ✔️ anonymous args
    • ✔️ named args
    • ✔️ defaulted args
    • *args / **kwargs
  • Classes
    • ✔️ overloaded init
    • ✔️ instance property ro/rw
    • ✔️ class property ro/rw
    • ✔️ instance attribute
    • ✔️ class attribute

Stubgen features

Render values:

  • defaulted function argument values
  • "builtin-valued" attributes as is
  • custom type valued attributes as comments
  • pybind11-enum-valued attributes/arg default values
  • module-valued class attributes

Render class/static members

  • class function
  • static function
  • ✔️ class property -> ClassVar

Correct order of module elements

  • Sort classes in topo-alpha order (ZBase class would go before ADerived but Cat goes before Dog)

Render docstrings

  • Add CLI option
  • ❓ Add docstring preprocessing hooks
  • Strip overloads annotations

Proper imports

  • Import modules as underscored aliases

Corner cases

  • Skip __hash__ = None for non-hashable types
  • don't render __init__ for non-constructable classes
  • [conditionally] strip numpy.ndarray shape info
  • [conditionally] strip std::array shape info

Robustness to bad docstrings

  • [conditionally] Render C++ types in signatures as strings (arguments or/and return type)
  • [conditionally] Render Invalid python expression as argument default value as strings
  • [conditionally] Produce error/warnings on above
Misc things to test (unordered)
  • exclude umbrella (*args, **kwargs) overload header from overload list
  • static/class functions and ro/rw properties
  • regular ro/rw properties
  • kw-only function arguments
  • positional-only function arguments
  • non-constructable types (with missing __init__)
  • numpy arrays (how to handle shape?)
  • don't produce import statement for nested classes
  • (?) exclude __hash__ = None line for non-hashable types that have __eq__
  • (?) test nested class argument defined in submodule
  • import names that not defined in module as underscored aliases
  • test copy/opaque pybind types (including pybind11/stl.h and pybind11/stl_bind.h)
  • test registered exception render
  • render classes in alpha-topological order (so ZBase class would go before ADerived but Cat goes before Dog)
  • render functions after classes
  • render module attributes that depend on the following classes with string types annotation (e.g. x: 'Foo' = ...)
  • fix pybind versions (e.g. replace iterator with Iterator)
  • skip pybind11-internal attributes
  • render pybind-overloaded "magic" python methods (e.g. __add__)
  • [optional] render docstrings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions