Skip to content

[codex] Fix package import rewrites and benchmark docs - #15

Merged
alvinwan merged 2 commits into
mainfrom
dev/alvin/compress-followup
Apr 6, 2026
Merged

[codex] Fix package import rewrites and benchmark docs#15
alvinwan merged 2 commits into
mainfrom
dev/alvin/compress-followup

Conversation

@alvinwan

@alvinwan alvinwan commented Apr 6, 2026

Copy link
Copy Markdown
Owner

What changed

This updates package-mode import rewriting and refreshes the benchmark docs.

  • fixes package submodule rewrites for patterns like from . import minification when module renaming is enabled
  • preserves the local binding name for rewritten relative package imports so later function renames do not shadow the imported submodule
  • adds a CLI regression for relative package submodule imports under --rename-modules
  • updates the benchmark docs and wheel tables, including the repaired pymini + pyminifier wheel row and short failure notes for remaining failed experiments
  • adds .bench-repos/ to .gitignore

Why

The pymini + pyminifier wheel benchmark was still failing because the minified pyminifier/__init__.py kept from . import minification even after the file had been renamed. During wheel builds, importing pyminifier from setup.py then failed with a circular import error from the partially initialized package.

Impact

  • aggressive package mode now handles relative package submodule imports correctly when modules are renamed
  • the pymini + pyminifier wheel benchmark now succeeds
  • benchmark documentation now reflects the current results and explains remaining failures inline

Validation

  • PYTHONPATH=. .venv/bin/python -m pytest -q -> 58 passed
  • reproduced the pymini + pyminifier wheel benchmark flow and confirmed the wheel now builds successfully
  • refreshed benchmark numbers for the repaired pyminifier wheel row

@alvinwan
alvinwan marked this pull request as ready for review April 6, 2026 06:40
@alvinwan
alvinwan merged commit 496af96 into main Apr 6, 2026
10 checks passed
@alvinwan
alvinwan deleted the dev/alvin/compress-followup branch April 6, 2026 06:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96227eb8f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pymini/pymini.py
Comment on lines +1867 to +1870
if base_parts and rewritten_module.startswith(".".join(base_parts) + "."):
node.module = rewritten_module[len(".".join(base_parts)) + 1:]
else:
node.module = rewritten_module

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid rewriting bare relative imports to .pkg

This relative-import rewrite path assigns node.module to the package name when node.level > 0, which breaks statements like from . import helpers inside non-__init__ package modules. After renaming, it can unparse to from .pkg import ..., which resolves as pkg.pkg and fails at import time (ModuleNotFoundError) when --rename-modules is enabled. For bare relative imports, the module should stay unset (or be rewritten to a truly relative target), not forced to the absolute package name.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant