-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
GH-119668: expose importlib.machinery.NamespacePath #119669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 17 commits
3c5af73
668b8ff
02ceeb5
67cfa22
29df08f
fb73b9f
0dd0520
06b8906
cd506a4
6f441c4
137652a
ab0930f
d779a7f
be415ab
bb16ae1
9f52661
0494d7b
8ccb7ba
8bc2d6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1013,6 +1013,36 @@ | |
| :exc:`ImportError` is raised. | ||
|
|
||
|
|
||
| .. class:: NamespacePath(name, path, path_finder) | ||
|
|
||
| Represents a :term:`namespace package`'s path (:attr:`module.__path__`). | ||
|
|
||
| When its value is accessed, if necessary, it will be recomputed. | ||
FFY00 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| This keeps it in-sync with the global state (:attr:`sys.modules`). | ||
|
|
||
| The *name* argument is the name of the namespace module. | ||
|
|
||
| The *path* argument is the initial path value. | ||
|
|
||
| The *path_finder* argument is the callable used to recompute the path value. | ||
| It has the same signature as :meth:`MetaPathFinder.find_spec`. | ||
|
||
|
|
||
| When the parent's :attr:`module.__path__` attribute is updated, the path | ||
| value is recomputed. | ||
|
|
||
| If the parent module is missing from :data:`sys.modules`, then | ||
| :exc:`ModuleNotFoundError` will be raised. | ||
|
|
||
| For top-level modules, the parent module's path is :data:`sys.path`. | ||
|
|
||
| .. note:: | ||
|
|
||
| :meth:`PathFinder.invalidate_caches` invalidates :class:`NamespacePath`, | ||
| forcing the path value to be recomputed next time it is accessed. | ||
|
|
||
| .. versionadded:: next | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The attribute is set on |
||
| .. class:: SourceFileLoader(fullname, path) | ||
|
|
||
| A concrete implementation of :class:`importlib.abc.SourceLoader` by | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Expose :class:`importlib.machinery.NamespacePath`. | ||
FFY00 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.