mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 15:20:34 +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>
|
||||
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
|
||||
if (!isinstance<dict>(annotations_dict)){
|
||||
if (!isinstance<dict>(annotations_dict)) {
|
||||
annotations_dict = 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::Set<py::str>>("set_str") = py::set();
|
||||
|
||||
|
||||
struct Empty {};
|
||||
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();
|
||||
|
||||
m.attr_with_type<py::typing::Final<int>>("CONST_INT") = 3;
|
||||
|
||||
}
|
||||
|
@ -1106,18 +1106,19 @@ def test_dict_ranges(tested_dict, expected):
|
||||
def test_module_attribute_types() -> None:
|
||||
module_annotations = m.__annotations__
|
||||
|
||||
assert module_annotations['list_int'] == 'list[int]'
|
||||
assert module_annotations['set_str'] == 'set[str]'
|
||||
assert module_annotations["list_int"] == "list[int]"
|
||||
assert module_annotations["set_str"] == "set[str]"
|
||||
|
||||
|
||||
def test_class_attribute_types() -> None:
|
||||
empty_annotations = m.EmptyAnnotationClass.__annotations__
|
||||
annotations = m.Point.__annotations__
|
||||
|
||||
|
||||
assert empty_annotations == {}
|
||||
assert annotations['x'] == 'float'
|
||||
assert annotations['dict_str_int'] == 'dict[str, int]'
|
||||
assert annotations["x"] == "float"
|
||||
assert annotations["dict_str_int"] == "dict[str, int]"
|
||||
|
||||
|
||||
def test_final_annotation() -> None:
|
||||
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