Skip to content

0.16 namespace-package split causes ~2x pyright memory #313

Description

@sirianni

Note

AI-assisted bug report, reviewed by me

Summary

Since the schema split in 0.16.0, type-checking a project that imports githubkit schemas costs ~2× the memory and ~16× the import-resolution time compared to 0.15.x. The cause is that githubkit_schemas ships as a PEP 420 namespace package (no __init__.py). Adding a single __init__.py fully restores the old behavior.

Measurements

Same project, same basedpyright 1.29.5 (pyright 1.1.402), only the githubkit version differs:

githubkit Resolve Imports pyright peak RSS
0.15.2 0.51 s 1.50 GB
0.16.0 8.17 s 3.16 GB

Total files parsed and bound is nearly identical (5467 vs 5605) and files checked is identical (532) — the regression is entirely in import resolution, not in how much code is analyzed.

Root cause

githubkit_schemas has no top-level __init__.py, so it's an implicit namespace package. For namespace packages, the import resolver cannot short-circuit on first match — it must scan every entry on the search path to assemble the package (vs. a regular package, which resolves immediately once found).

Adding one empty __init__.py to the installed githubkit_schemas/ and re-running pyright reverts both metrics to 0.15 levels:

githubkit_schemas Resolve Imports pyright peak RSS
namespace package (default) 8.17 s 3.16 GB
+ __init__.py (regular package) 0.54 s 1.60 GB

Proposed fix

Ship an __init__.py in the githubkit_schemas package(s) so it's a regular package rather than an implicit namespace package.

Relationship to #312

This shares the same root cause as #312 (githubkit_schemas being a namespace package with no __init__.py): there it means the lazy-import hook isn't bootstrapped unless githubkit is imported first; here it means type checkers pay a large namespace-resolution penalty. A real __init__.py would address both — it could both install the lazy hook and make the package non-namespace.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions