mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +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:
@@ -93,3 +93,20 @@ def test_roundtrip_simple_cpp_derived():
|
||||
# Issue #3062: pickleable base C++ classes can incur object slicing
|
||||
# if derived typeid is not registered with pybind11
|
||||
assert not m.check_dynamic_cast_SimpleCppDerived(p2)
|
||||
|
||||
|
||||
def test_new_style_pickle_getstate_pos_only():
|
||||
assert (
|
||||
re.match(
|
||||
r"^__getstate__\(self: [\w\.]+, /\)", m.PickleableNew.__getstate__.__doc__
|
||||
)
|
||||
is not None
|
||||
)
|
||||
if hasattr(m, "PickleableWithDictNew"):
|
||||
assert (
|
||||
re.match(
|
||||
r"^__getstate__\(self: [\w\.]+, /\)",
|
||||
m.PickleableWithDictNew.__getstate__.__doc__,
|
||||
)
|
||||
is not None
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user