You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature: have Alias inherit the public attribute from its target #495
(Not sure to consider this a feature request or a bug report)
Is your feature request related to a problem? Please describe.
I have a use case where I am trying to write a Griffe plugin for use with mkdocstrings that filters certain objects from my documentation by setting public = False.
This works for some objects, but the issue I've run into is that some Griffe methods/properties construct an alias of an object rather than returning the object itself (inherited_members and by extension all_members). Since Aliases are created with public = None the public attribute on the target object is ignored. Since these dynamically constructed aliases don't trigger plugin events, there's no way to affect their visibility.
classA:
deffoo(self): ...
classB(A): ...
This creates an unintuitive situation where for the code above if I set public=False on foo, A["foo"].is_public returns False but B["foo"].is_public returns True
Describe the solution you'd like
An easy fix would be to change the Alias init logic to check target and set public=None if it's a string, otherwise set public=target.public. That would ensure that manual overrides get propagated to temporary aliases as expected.
Describe alternatives you've considered
Originally I was going to suggest overriding is_public to fetch the value of final_target.public, but that creates resolution problems with as_dict.
If there's an existing solution to my problem let me know! I don't have much experience with Griffe so I might be missing something.
This creates an unintuitive situation where for the code above if I set public=False on foo, A["foo"].is_public returns False but B["foo"].is_public returns True
That indeed sounds like a bug. I'll comment on your PR.
Since these dynamically constructed aliases don't trigger plugin events, there's no way to affect their visibility.
Right, we do have an on_alias event, but it's not fired against inherited members, since we do not iterate those while iterate a package. This could deserve some work. Generally, we need to better specify the load phases. We have a first phase where things are being loaded, and a second phase where we want to be able to safely iterate on everything without worrying about caching incomplete data.
Activity
pawamoy commentedon Oct 16, 2026
Thanks for the report @sydduckworth.
That indeed sounds like a bug. I'll comment on your PR.
fix: Propagate `public` value to inherited members (aliases)
fix: Propagate `public` value to inherited members (aliases)
fix: Propagate `public` value to inherited members (aliases)
pawamoy commentedon Oct 16, 2026
Right, we do have an
on_aliasevent, but it's not fired against inherited members, since we do not iterate those while iterate a package. This could deserve some work. Generally, we need to better specify the load phases. We have a first phase where things are being loaded, and a second phase where we want to be able to safely iterate on everything without worrying about caching incomplete data.I've made a note in #505.