Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore exceptions in autodoc_property_type #142

Merged
merged 6 commits into from
Aug 30, 2022
Merged

Ignore exceptions in autodoc_property_type #142

merged 6 commits into from
Aug 30, 2022

Conversation

jbms
Copy link
Owner

@jbms jbms commented Aug 13, 2022

Fixes #134.

@jbms jbms requested a review from 2bndy5 August 13, 2022 05:41
@jbms
Copy link
Owner Author

jbms commented Aug 13, 2022

I haven't tested this but I think it will fix the issue.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 13, 2022

sadly, this does fix the issue. It just hides the errros.

.. autoclass:: pyrf24.rf24_network.RF24NetworkHeader
    :members: to_node type from_node id reserved to_string

    .. property:: next_id
        :classmethod:

        The next sequential identifying number used for the next created header's `id`.

renders as
image


FYI: Only to_string is a function in that RF24NetworkHeader class. All the rest of the members are attributes. Custom signatures only applies to functions in pybind11, so I'm not entirely convinced it has something to do with me using custom signatures in the embedded docstrings.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 16, 2022

We can probably get rid of the unused variable:

--- a/sphinx_immaterial/apidoc/python/autodoc_property_type.py
+++ b/sphinx_immaterial/apidoc/python/autodoc_property_type.py
@@ -26,7 +26,6 @@ def _get_property_getter(obj: Any) -> Any:


 def _get_property_return_type(obj: Any) -> Optional[str]:
-    fget = _get_property_getter(obj)
     doc = obj.__doc__
     if doc is None:
         return None

I've got a working theory (assuming fget is a builtin function) for a fix here:

--- a/sphinx_immaterial/apidoc/python/autodoc_property_type.py
+++ b/sphinx_immaterial/apidoc/python/autodoc_property_type.py
@@ -19,7 +19,7 @@ property_sig_re = re.compile("^(\\(.*)\\)\\s*->\\s*(.*)$")
 def _get_property_getter(obj: Any) -> Any:
     # property
     func = sphinx.util.inspect.safe_getattr(obj, "fget", None)
-    if func is None:
+    if func is None or getattr(func, "__text_signature__", None) is None:
         # cached_property
         func = sphinx.util.inspect.safe_getattr(obj, "func", None)
     return func

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 29, 2022

When verifying the CI in #145, I added some config for black to the toml. This config alters the exit code returned by black. Previously, it was allowing unformatted code to pass in CI, but now it is properly alerting us to unformatted code.

Unfortunately, I don't see the file tests/python_apigen_test_modules/_alpha.py that it is complaining about here

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 29, 2022

I found the file on the main branch. Its weird that black scans the files that only exist on base branch.

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 29, 2022

This seems to be because the CI runs on both PR sync events and any push event. The PR sync events are the ones that black scans the base branch (resulting in alerts about files that don't exist on the head branch).

@jbms
Copy link
Owner Author

jbms commented Aug 29, 2022

Thanks --- I rebased this branch, and fixed the formatting issue.

@jbms
Copy link
Owner Author

jbms commented Aug 29, 2022

I also fixed the bug with the return types not being listed for pybind11 properties, and added some unit tests to prevent regressions in the future.

Copy link
Collaborator

@2bndy5 2bndy5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work (yet again) - especially with getting the return type annotations working for pybind11. Its good to see the new test pkg getting used for more than 1 test 👍🏼

jbms and others added 4 commits August 29, 2022 16:08
* add simple pybind11 example for testing

* move pytest reqs, & add pytest config to toml

* add failing test

also test to validate example pkg

* install test deps with pkg/lint tools

- force black exit code to reflect required changes
- ran black on object_toc.py
- move linting tools' config to pyproject.toml

The repo structure has changed since refactors (in previous PRs). So, the CI now does:
- run mypy on all py files.
- run pylint on all pkg files.
- run black on all py files.

* add pyyaml to test reqs

* use custon sig in pybind11 test

and show c'tor in test's rendered output
Co-authored-by: Brendan <[email protected]>
@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 30, 2022

I'm good to go here. I'm thinking of pushing a tag v0.9.0 (after this is merged) due to the added graphviz integration. Unless you prefer v0.8.2?

@jbms jbms merged commit 8c94664 into main Aug 30, 2022
@jbms
Copy link
Owner Author

jbms commented Aug 30, 2022

Pushing a tag sounds good.

@jbms jbms deleted the fix-134 branch August 30, 2022 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

problems using :members: for autoclass in v0.8.0
2 participants