Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
8e85fadf
Commit
8e85fadf
authored
Jun 27, 2020
by
Ashley Whetter
Committed by
Wenzel Jakob
Jun 29, 2020
Browse files
Render `py::none` as `None` in docstrings
Closes #2270
parent
8c0cd944
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
0 deletions
+11
-0
include/pybind11/cast.h
include/pybind11/cast.h
+1
-0
tests/test_pytypes.cpp
tests/test_pytypes.cpp
+5
-0
tests/test_pytypes.py
tests/test_pytypes.py
+5
-0
No files found.
include/pybind11/cast.h
View file @
8e85fadf
...
@@ -1609,6 +1609,7 @@ template <> struct handle_type_name<bytes> { static constexpr auto name = _(PYBI
...
@@ -1609,6 +1609,7 @@ template <> struct handle_type_name<bytes> { static constexpr auto name = _(PYBI
template
<
>
struct
handle_type_name
<
int_
>
{
static
constexpr
auto
name
=
_
(
"int"
);
};
template
<
>
struct
handle_type_name
<
int_
>
{
static
constexpr
auto
name
=
_
(
"int"
);
};
template
<
>
struct
handle_type_name
<
iterable
>
{
static
constexpr
auto
name
=
_
(
"Iterable"
);
};
template
<
>
struct
handle_type_name
<
iterable
>
{
static
constexpr
auto
name
=
_
(
"Iterable"
);
};
template
<
>
struct
handle_type_name
<
iterator
>
{
static
constexpr
auto
name
=
_
(
"Iterator"
);
};
template
<
>
struct
handle_type_name
<
iterator
>
{
static
constexpr
auto
name
=
_
(
"Iterator"
);
};
template
<
>
struct
handle_type_name
<
none
>
{
static
constexpr
auto
name
=
_
(
"None"
);
};
template
<
>
struct
handle_type_name
<
args
>
{
static
constexpr
auto
name
=
_
(
"*args"
);
};
template
<
>
struct
handle_type_name
<
args
>
{
static
constexpr
auto
name
=
_
(
"*args"
);
};
template
<
>
struct
handle_type_name
<
kwargs
>
{
static
constexpr
auto
name
=
_
(
"**kwargs"
);
};
template
<
>
struct
handle_type_name
<
kwargs
>
{
static
constexpr
auto
name
=
_
(
"**kwargs"
);
};
...
...
tests/test_pytypes.cpp
View file @
8e85fadf
...
@@ -32,6 +32,11 @@ TEST_SUBMODULE(pytypes, m) {
...
@@ -32,6 +32,11 @@ TEST_SUBMODULE(pytypes, m) {
for
(
auto
item
:
list
)
for
(
auto
item
:
list
)
py
::
print
(
"list item {}: {}"
_s
.
format
(
index
++
,
item
));
py
::
print
(
"list item {}: {}"
_s
.
format
(
index
++
,
item
));
});
});
// test_none
m
.
def
(
"get_none"
,
[]{
return
py
::
none
();});
m
.
def
(
"print_none"
,
[](
py
::
none
none
)
{
py
::
print
(
"none: {}"
_s
.
format
(
none
));
});
// test_set
// test_set
m
.
def
(
"get_set"
,
[]()
{
m
.
def
(
"get_set"
,
[]()
{
...
...
tests/test_pytypes.py
View file @
8e85fadf
...
@@ -37,6 +37,11 @@ def test_list(capture, doc):
...
@@ -37,6 +37,11 @@ def test_list(capture, doc):
assert
doc
(
m
.
print_list
)
==
"print_list(arg0: list) -> None"
assert
doc
(
m
.
print_list
)
==
"print_list(arg0: list) -> None"
def
test_none
(
capture
,
doc
):
assert
doc
(
m
.
get_none
)
==
"get_none() -> None"
assert
doc
(
m
.
print_none
)
==
"print_none(arg0: None) -> None"
def
test_set
(
capture
,
doc
):
def
test_set
(
capture
,
doc
):
s
=
m
.
get_set
()
s
=
m
.
get_set
()
assert
s
==
{
"key1"
,
"key2"
,
"key3"
}
assert
s
==
{
"key1"
,
"key2"
,
"key3"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment