mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
feat(typing): allow annotate methods with pos_only when only have the self argument (#5403)
* feat: allow annotate methods with `pos_only` when only have the `self` argument * chore(typing): make arguments for auto-generated dunder methods positional-only * docs: add more comments to improve readability * style: fix nit suggestions * Add test_self_only_pos_only() in tests/test_methods_and_attributes * test: add docstring tests for generated dunder methods * test: remove failed tests * fix(test): run `gc.collect()` three times for refcount tests --------- Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
This commit is contained in:
@@ -19,6 +19,13 @@ NO_DELETER_MSG = (
|
||||
)
|
||||
|
||||
|
||||
def test_self_only_pos_only():
|
||||
assert (
|
||||
m.ExampleMandA.__str__.__doc__
|
||||
== "__str__(self: pybind11_tests.methods_and_attributes.ExampleMandA, /) -> str\n"
|
||||
)
|
||||
|
||||
|
||||
def test_methods_and_attributes():
|
||||
instance1 = m.ExampleMandA()
|
||||
instance2 = m.ExampleMandA(32)
|
||||
|
||||
Reference in New Issue
Block a user