@@ -199,8 +199,9 @@ Partial Stub Packages
199
199
Many stub packages will only have part of the type interface for libraries
200
200
completed, especially initially. For the benefit of type checking and code
201
201
editors, packages can be "partial". This means modules not found in the stub
202
- package SHOULD be searched for in part four of the module resolution
203
- order below, namely :term: `inline ` packages.
202
+ package SHOULD be searched for in parts five and six of the module resolution
203
+ order below, namely :term: `inline ` packages and any third-party stubs the type
204
+ checker chooses to vendor.
204
205
205
206
Type checkers should merge the stub package and runtime package
206
207
directories. This can be thought of as the functional equivalent of copying the
@@ -235,19 +236,27 @@ resolve modules containing type information:
235
236
236
237
2. User code - the files the type checker is running on.
237
238
238
- 3. :term: `Stub <stub> ` packages - these packages SHOULD supersede any installed inline
239
+ 3. Typeshed stubs for the standard library. These will usually be vendored by
240
+ type checkers, but type checkers SHOULD provide an option for users to
241
+ provide a path to a directory containing a custom or modified version of
242
+ typeshed; if this option is provided, type checkers SHOULD use this as the
243
+ canonical source for standard-library types in this step.
244
+
245
+ 4. :term: `Stub <stub> ` packages - these packages SHOULD supersede any installed inline
239
246
package. They can be found in directories named ``foopkg-stubs `` for
240
247
package ``foopkg ``.
241
248
242
- 4 . Packages with a ``py.typed `` marker file - if there is nothing overriding
249
+ 5 . Packages with a ``py.typed `` marker file - if there is nothing overriding
243
250
the installed package, *and * it opts into type checking, the types
244
251
bundled with the package SHOULD be used (be they in ``.pyi `` type
245
252
stub files or inline in ``.py `` files).
246
253
247
- 5. Typeshed - only for modules in the standard library.
254
+ 6. If the type checker chooses to additionally vendor any third-party stubs
255
+ (from typeshed or elsewhere), these SHOULD come last in the module
256
+ resolution order.
248
257
249
258
If typecheckers identify a stub-only namespace package without the desired module
250
- in step 3 , they should continue to step 4/5 . Typecheckers should identify namespace packages
259
+ in step 4 , they should continue to step 5/6 . Typecheckers should identify namespace packages
251
260
by the absence of ``__init__.pyi ``. This allows different subpackages to
252
261
independently opt for inline vs stub-only.
253
262
0 commit comments