Repository navigation
Support exported names starting with an underscore in __all__ - #3746
Conversation
| or n.mod_id != m.mod_id | ||
| or n.module_public != m.module_public): | ||
| or n.module_public != m.module_public | ||
| or n.module_public_even_with_underscore != m.module_public_even_with_underscore): |
There was a problem hiding this comment.
I wasn't sure of whether this should be included here or not, since it's affected by __all__ only. I would greatly appreciate if someone who has a better idea of the use of this function could comment on this.
|
Thanks for PR! Concerning your question on gitter about |
| self.add_submodules_to_parent_modules(i_id, True) | ||
| for name, node in m.names.items(): | ||
| node = self.normalize_type_alias(node, i) | ||
| if not name.startswith('_') and node.module_public: |
There was a problem hiding this comment.
Why isn't it possible to fix this by only changing the logic here? For example add a nested if that ignores the check for underscore here if m.names contains '__all__' TBH, I don't really like inclusion of a new flag.
There was a problem hiding this comment.
If we have access to __all__ here, not introducing a new flag does sound better! I wasn't sure of where we had access to what, so I was somewhat following how #1640 implemented __all__ originally.
Thank you for mentioning this, I'll change this.
There was a problem hiding this comment.
Note that we don't actually need to access its content, we just need to know that it is there, since in this case all names not in __all__ will have module_public = False.
There was a problem hiding this comment.
Ah right! Awesome, that's even better than what I misread you as saying - thanks!
Thanks to @ilevkivskyi for this!
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thanks! LGTM, I will merge this later if there are no objections.
|
Thank you! |
Fixes #3745, if that's something we want to do.
This seemed like a fairly small change, so I went ahead and made this pull request. I'm not 100% sure the name
module_public_even_with_underscoreis best here, if there are any suggestions on this or any other part of the PR please mention them.I added a new variable with the default
Falsesince it seemed like a good way to add this without introducing more overhead on any code which doesn't use this feature. I don't know this codebase very well though, so if there is a better or more clean way to do this, that would be excellent.