feat(types): Use typing.SupportsInt and typing.SupportsFloat and fix other typing based bugs. (#5540)

* init

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* remove import

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* remove uneeded function

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* style: pre-commit fixes

* Add missing import

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* style: pre-commit fixes

* Fix type behind detailed_message_enabled flag

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Fix type behind detailed_message_enabled flag

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Add io_name comment

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Extra loops to single function

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* style: pre-commit fixes

* Remove unneeded forward declaration

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Switch variable name away from macro

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Switch variable name away from macro

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Switch variable name away from macro

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* clang-tidy

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* remove stack import

* Fix bug in std::function Callable type

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* style: pre-commit fixes

* remove is_annotation argument

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* style: pre-commit fixes

* Update function name and arg names

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* style: pre-commit fixes

---------

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Michael Carlstrom
2025-03-18 07:56:34 -07:00
committed by GitHub
parent 16b5abd428
commit dfe7e65b45
19 changed files with 324 additions and 198 deletions

View File

@@ -19,9 +19,13 @@ def test_docstring_options():
assert m.test_overloaded3.__doc__ == "Overload docstr"
# options.enable_function_signatures()
assert m.test_function3.__doc__.startswith("test_function3(a: int, b: int) -> None")
assert m.test_function3.__doc__.startswith(
"test_function3(a: typing.SupportsInt, b: typing.SupportsInt) -> None"
)
assert m.test_function4.__doc__.startswith("test_function4(a: int, b: int) -> None")
assert m.test_function4.__doc__.startswith(
"test_function4(a: typing.SupportsInt, b: typing.SupportsInt) -> None"
)
assert m.test_function4.__doc__.endswith("A custom docstring\n")
# options.disable_function_signatures()
@@ -32,7 +36,9 @@ def test_docstring_options():
assert m.test_function6.__doc__ == "A custom docstring"
# RAII destructor
assert m.test_function7.__doc__.startswith("test_function7(a: int, b: int) -> None")
assert m.test_function7.__doc__.startswith(
"test_function7(a: typing.SupportsInt, b: typing.SupportsInt) -> None"
)
assert m.test_function7.__doc__.endswith("A custom docstring\n")
# when all options are disabled, no docstring (instead of an empty one) should be generated