Skip to content

feat: Have Alias inherit public from target - #496

Closed
sydduckworth wants to merge 1 commit into
mkdocstrings:mainfrom
sydduckworth:feat/alias-inherit-public
Closed

sydduckworth wants to merge 1 commit into
mkdocstrings:mainfrom
sydduckworth:feat/alias-inherit-public

Conversation

@sydduckworth

Copy link
Copy Markdown
Contributor

For reviewers

  • I did not use AI
  • I used AI and thoroughly reviewed every code/docs change

Description of the change

Updated Alias so its public attribute is now inherited from target if the target is a real object (and not a string).

Relevant resources

Closes #495

@pawamoy

pawamoy commented Oct 16, 2026

Copy link
Copy Markdown
Member

Thanks for the PR 🙂

So, I believe we have two things to consider regarding aliases:

  • aliases that represent actual indirections (import in another module, re-export, re-assignment, etc.)
  • aliases that represent inherited members

For inherited members, it makes sense to propagate the original member's public-ness. However, for indirections, it doesn't. For indirections, the alias should retain its own public-ness, independently of the original object.

For example: because pkg.foo.bar.Baz is public, it doesn't mean its (imported) alias at pkg.qux.Baz should be marked public.

# pkg/foo/bar.py
class Baz: ...  # public
# pkg/qux.py
from pkg.foo.bar import Baz  # shouldn't be explicitly public

Therefore, I believe we should only target inherited members with this change. I'll send a PR 🙂

@pawamoy pawamoy closed this Oct 16, 2026
@pawamoy

pawamoy commented Oct 16, 2026

Copy link
Copy Markdown
Member

Hmmm, actually, your test makes a good point about setting public in the original object and that it should automatically be reflected in its inherited versions.

@pawamoy pawamoy reopened this Oct 16, 2026
@pawamoy

pawamoy commented Oct 16, 2026

Copy link
Copy Markdown
Member

I'll still send another PR and set you as co-author.

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.

feature: have Alias inherit the public attribute from its target

2 participants