-
-
Notifications
You must be signed in to change notification settings - Fork 107
2.2.0 Throws Exception for class with custom metaclass #462
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
Comments
@tikuma-lsuhsc seems likely a regression caused by #459. |
Yep, I did not account for a string annotation as I wasn't even aware such is even an option. I'll look into it tonight. |
@b-phi - I tested all three class def's of yours but none produced the error that you reported. Built with **class mod._SchemaMeta(*args: Any, **kwargs: Any)**
**class mod.Schema**
**class mod.Foo**
**do_something(mod: Schema) -> None**
:Parameters:
**schema** (`Schema <#mod.Schema>`_) – Some
schema.
:Return type:
``None`` with the autodoc command in the input rst file: .. autoclass:: mod._SchemaMeta
:members:
.. autoclass:: mod.Schema
:members:
.. autoclass:: mod.Foo
:members: I've also written pytest cases within the repo without any success. Could you disclose more info? (relevant |
I am getting the following, very similar error:
This is also since 2.2.0 (pinning to 2.1.1 avoids the bug). I have not been able to determine the exact code sphinx-autodoc-typehints trips over. If and when I do, I'll share an example here to help reproduce the problem. |
As requested, some additional info. Will try to find some time to put together a reproducible example conf.py sections extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel',
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
]
# Autodoc Configuration
autodoc_default_options = {
'members': True,
'member-order': 'bysource',
'special-members': '__init__',
'undoc-members': True,
}
# Typehint Configuration
typehints_defaults = 'comma'
typehints_use_signature = True
typehints_use_signature_return = True rst where ...
.. autoclass:: path.to.class.Foo |
@b-phi - Thanks. Those options still won't trigger the error, unfortunately. The same goes with @bartfeenstra's Meanwhile, I have a fix candidate pushed to my fork: git+https://github.com/tikuma-lsuhsc/sphinx-autodoc-typehints/tree/fix-issue-462 If possible, could you try the above branch on your projects and see if it resolves the bug? |
Hey @tikuma-lsuhsc, unfortunately this branch does not resolve the error |
@bartfeenstra - hmm, that's unfortunate. Regarding your error, do you have a snippet of 2.1.1 output which contains |
Hey @tikuma-lsuhsc I've created a minimal example. Overriding from typing import Any
class _SchemaMeta(type):
def __eq__(cls, other: Any) -> bool:
return True
class Schema(metaclass=_SchemaMeta):
pass
def f(s: Schema) -> Schema:
"""
Do something.
Args:
s: Some schema.
"""
return s |
@b-phi - Confirmed! Thanks for putting the example together. |
@b-phi & @bartfeenstra - I think I have a solution to the issue. If you could please help me test again with my fork (don't forget to update if tried once above): git+https://github.com/tikuma-lsuhsc/sphinx-autodoc-typehints/tree/fix-issue-462 Thanks! |
That seems to have fixed it, thanks! |
This also appears to have fix issues I had (I dont know what they were). Thanks. |
Fix processing type aliases
* test update (non-reproducible) * fix candidate #1 * fixes issue #462 * Fix annotation check exception (#462) Fix processing type aliases * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * reverted test_integration.py * make _SchemaMeta hashable for ruff pre-commit test * pre-commit ci fix try no 2 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * _get_type_hint(): fixed the type hint of localns arg --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Closed by #463. |
I've including the relevant skeleton of the classes below.
Elsewhere in the code, we have this which causes the error
Edit: I've pinned to 2.1.1 for now, which doesn't throw an error in this case.
The text was updated successfully, but these errors were encountered: