mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 01:15:52 +00:00
style: pre-commit fixes
This commit is contained in:
parent
886c9c2c80
commit
31cc64f414
@ -2569,18 +2569,17 @@ template <typename D>
|
||||
// Always a dict
|
||||
// https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older
|
||||
object object_api<D>::annotations() const {
|
||||
// Python 3.8, 3.9
|
||||
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 9
|
||||
if (isinstance<type>(derived())){
|
||||
return getattr(derived(), "__dict__").get("__annotations__", dict());
|
||||
}
|
||||
else{
|
||||
return getattr(derived(), "__annotations__", dict());
|
||||
}
|
||||
// Python 3.10+
|
||||
#else
|
||||
// Python 3.8, 3.9
|
||||
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 9
|
||||
if (isinstance<type>(derived())) {
|
||||
return getattr(derived(), "__dict__").get("__annotations__", dict());
|
||||
} else {
|
||||
return getattr(derived(), "__annotations__", dict());
|
||||
#endif
|
||||
}
|
||||
// Python 3.10+
|
||||
#else
|
||||
return getattr(derived(), "__annotations__", dict());
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
|
@ -1102,12 +1102,12 @@ def test_dict_ranges(tested_dict, expected):
|
||||
assert m.dict_iterator_default_initialization()
|
||||
assert m.transform_dict_plus_one(tested_dict) == expected
|
||||
|
||||
|
||||
# https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older
|
||||
def get_annotations_helper(o):
|
||||
if isinstance(o, type):
|
||||
return o.__dict__.get('__annotations__', {})
|
||||
else:
|
||||
return getattr(o, '__annotations__', {})
|
||||
return o.__dict__.get("__annotations__", {})
|
||||
return getattr(o, "__annotations__", {})
|
||||
|
||||
|
||||
def test_module_attribute_types() -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user