Skip to content

Process ivar fields and friends when introspecting code (wrt C-modules) #904

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

Merged
merged 5 commits into from
Jul 10, 2025

Conversation

tristanlatr
Copy link
Contributor

Fixes #903

@ntamas, this fixes the issue you reported lately.

The testing does not explicitely cover C-module, but I'm pretty confident this will do the trick.

If I understand correctly the initial problem, the ivar fields you were trying to use is just a workaround another issue in pydoctor, that is that property defined in C code are not recognized because they don't appear in the __dict__ attribute of classes. Maybe by using inspect.getmembers instead we could fix this issue as well? Tell me what you think, thanks.

@tristanlatr tristanlatr changed the title Process ivar fields and friends when introspecting code (wrf C-modules) Process ivar fields and friends when introspecting code (wrt C-modules) Jul 9, 2025
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.18%. Comparing base (c026873) to head (e7e6a58).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #904      +/-   ##
==========================================
+ Coverage   93.14%   93.18%   +0.04%     
==========================================
  Files          47       47              
  Lines        8733     8736       +3     
  Branches     1600     1601       +1     
==========================================
+ Hits         8134     8141       +7     
+ Misses        338      336       -2     
+ Partials      261      259       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This comment has been minimized.

This comment has been minimized.

@tristanlatr tristanlatr requested review from glyph and a team July 9, 2025 23:18

This comment has been minimized.

1 similar comment
Copy link

github-actions bot commented Jul 9, 2025

According to pydoctor_primer, this change doesn't affect pydoctor warnings on a corpus of open source code. ✅

@ntamas
Copy link
Contributor

ntamas commented Jul 10, 2025

I tested the igraph documentation with this PR and I can confirm that @ivar tags are now recognized properly in the docstring of a class defined in a C module so this can be merged.

At the same time, yes, you are correct, adding an @ivar in the Vertex and Edge classes of igraph is a workaround for the problem that getters/setters defined in a class of a C module are not processed by PyDoctor. They do appear in __dict__, but their value is of type getset_descriptor, which is not handled by any of the branches in _introspectThing:

>>> from igraph import Edge
>>> type(Edge.__dict__["index"])
<class 'getset_descriptor'>

@glyph
Copy link
Member

glyph commented Jul 10, 2025

I believe that this descriptor type is exposed publicly as types.GetSetDescriptorType .

@tristanlatr
Copy link
Contributor Author

Many thanks for your inputs. I’ll look at supporting introspection of property-like types implemented in c extensions in the near future.

@tristanlatr tristanlatr merged commit 97fc788 into master Jul 10, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Epytext fields are not processed in class docstrings if the class is defined in a C extension
3 participants