Repository navigation
Enhance namespace package repr #98139
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Oct 10, 2022 This is tricky, the proposal removes the loader from the repr, which is useful information, and makes it possible to have ridiculously big reprs due to including the search paths, but it does produce arguably better reprs for lots of situations. I am slightly inclined towards keeping the current repr.
@jaraco thoughts?
I like this feature suggestion, I can think of a couple times it would have helped some people at work.
I'm not sure how intentional showing the loader in the repr was (e.g. 3.9 shows just
<module 'xx' (namespace)>), seems mostly that the change to introduce it was to avoid use of the deprecatedLoader.module_repr, if possible. Brett was the last person to touch this logic, in case we want his opinion.Reacted by Filipe LaínsIMO, the paths where the namespace is loaded are particularly useful. I'm +1 to the proposal. I'm not sure that I've ever used the repr of the loader except to recognize that it's a namespace package, which is retained in the proposal.
Filipe mentions the risk of ridiculously big reprs, which seems like a plausible scenario, even with just a couple of very long paths. Still, being able to see the paths in the repr seems a lot more valuable than the memory address of the loader.
I'm thinking that almost all uses of this repr are going to be for internal troubleshooting anyway, so I'm not terribly concerned about the size of the repr. I'm not aware of any situations where large reprs could cause problems, though I certainly don't have a full survey of user experiences.
Reacted by Filipe Laíns- added a commit that references this issue
on Nov 6, 2022 Implemented in #98870.
Feature or enhancement
After
Loader.module_reprhas been deprecated, the repr of namespace is like:<module 'xx' (<_frozen_bootstrap_external.NamespaceLoader object at 0x0000000>)>which is unreadable. So I purpose the following repr:
<module 'xx' (namespace) from ['path1', 'path2']>The change purposed to code is:
In my interpreter test:
If OK, I can open PR, and add test code.
Previous discussion