mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-07 17:32:00 +00:00
style: pre-commit fixes
This commit is contained in:
parent
4c263c1336
commit
4788d8cf32
@ -2567,9 +2567,9 @@ str_attr_accessor object_api<D>::doc() const {
|
|||||||
|
|
||||||
template <typename D>
|
template <typename D>
|
||||||
str_attr_accessor object_api<D>::annotations() const {
|
str_attr_accessor object_api<D>::annotations() const {
|
||||||
str_attr_accessor annotations_dict = attr("__annotations__");
|
str_attr_accessor annotations_dict = attr("__annotations__");
|
||||||
// Create dict automatically
|
// Create dict automatically
|
||||||
if (!isinstance<dict>(annotations_dict)){
|
if (!isinstance<dict>(annotations_dict)) {
|
||||||
annotations_dict = dict();
|
annotations_dict = dict();
|
||||||
}
|
}
|
||||||
return annotations_dict;
|
return annotations_dict;
|
||||||
|
@ -1002,7 +1002,6 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
m.attr_with_type<py::typing::List<int>>("list_int") = py::list();
|
m.attr_with_type<py::typing::List<int>>("list_int") = py::list();
|
||||||
m.attr_with_type<py::typing::Set<py::str>>("set_str") = py::set();
|
m.attr_with_type<py::typing::Set<py::str>>("set_str") = py::set();
|
||||||
|
|
||||||
|
|
||||||
struct Empty {};
|
struct Empty {};
|
||||||
py::class_<Empty>(m, "EmptyAnnotationClass");
|
py::class_<Empty>(m, "EmptyAnnotationClass");
|
||||||
|
|
||||||
@ -1015,5 +1014,4 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
point.attr_with_type<py::typing::Dict<py::str, int>>("dict_str_int") = py::dict();
|
point.attr_with_type<py::typing::Dict<py::str, int>>("dict_str_int") = py::dict();
|
||||||
|
|
||||||
m.attr_with_type<py::typing::Final<int>>("CONST_INT") = 3;
|
m.attr_with_type<py::typing::Final<int>>("CONST_INT") = 3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1106,8 +1106,8 @@ def test_dict_ranges(tested_dict, expected):
|
|||||||
def test_module_attribute_types() -> None:
|
def test_module_attribute_types() -> None:
|
||||||
module_annotations = m.__annotations__
|
module_annotations = m.__annotations__
|
||||||
|
|
||||||
assert module_annotations['list_int'] == 'list[int]'
|
assert module_annotations["list_int"] == "list[int]"
|
||||||
assert module_annotations['set_str'] == 'set[str]'
|
assert module_annotations["set_str"] == "set[str]"
|
||||||
|
|
||||||
|
|
||||||
def test_class_attribute_types() -> None:
|
def test_class_attribute_types() -> None:
|
||||||
@ -1115,9 +1115,10 @@ def test_class_attribute_types() -> None:
|
|||||||
annotations = m.Point.__annotations__
|
annotations = m.Point.__annotations__
|
||||||
|
|
||||||
assert empty_annotations == {}
|
assert empty_annotations == {}
|
||||||
assert annotations['x'] == 'float'
|
assert annotations["x"] == "float"
|
||||||
assert annotations['dict_str_int'] == 'dict[str, int]'
|
assert annotations["dict_str_int"] == "dict[str, int]"
|
||||||
|
|
||||||
|
|
||||||
def test_final_annotation() -> None:
|
def test_final_annotation() -> None:
|
||||||
module_annotations = m.__annotations__
|
module_annotations = m.__annotations__
|
||||||
assert module_annotations['CONST_INT'] == 'Final[int]'
|
assert module_annotations["CONST_INT"] == "Final[int]"
|
||||||
|
Loading…
Reference in New Issue
Block a user