Skip to content

feature: have Alias inherit the public attribute from its target #495

Closed

Description

@sydduckworth

(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.

class A:
  def foo(self): ...

class B(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.

Activity

  1. added
    feature
    on Oct 2, 2026
  2. pawamoy commented on Oct 16, 2026

    @pawamoy
    Member

    Thanks for the report @sydduckworth.

    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.

  3. pawamoy commented on Oct 16, 2026

    @pawamoy
    Member

    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.

    I've made a note in #505.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions