Skip to content

Restore opt-in COP001 without runtime import lookup - #7

Merged
vrslev merged 2 commits into
mainfrom
fix/static-module-imports
Oct 12, 2026
Merged

vrslev merged 2 commits into
mainfrom
fix/static-module-imports

Conversation

@vrslev

@vrslev vrslev commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

COP001 was disabled because module detection depended on how flake8 was invoked. Restore it using source and filesystem inspection, with project roots derived from the linted filename so console-script and python -m flake8 invocations agree.

Keep the existing COP extension. COP001 stays off when selecting the broad COP prefix; repositories opt in using extend-select = ["COP001"] or by selecting the exact COP001 code. Existing rules remain active without that opt-in.

The checker does not execute inspected packages, import hooks, native modules, or .pth files. It reports imports of more than two statically identifiable symbols, preserves the standard-library and existing import exemptions, and leaves unresolved imports and dynamic exports unchecked. Update the plugin's own three-symbol import to satisfy the restored rule.

Validation: 221 tests pass locally, including CLI and TOML opt-in, default compatibility, flat/src/namespace layouts, installed source and stub packages, both CLI entry points, and regressions for package initialization side effects and runtime import lookup. Ruff, flake8, mypy, and auto-typing-final pass on Python 3.13; the CI matrix covers Linux, macOS, and Windows on Python 3.10–3.14.

@vrslev vrslev changed the title Re-enable COP001 with static module resolution Restore opt-in COP001 without runtime import lookup Oct 12, 2026
@vrslev
vrslev marked this pull request as ready for review October 12, 2026 11:05
@vrslev
vrslev merged commit 3a84006 into main Oct 12, 2026
17 checks passed
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