Repository navigation
Conversation
organize_options imported services.auto_tagging.styles at module load, which runs services/__init__ and eventually reaches config.methodology, which imports OrganizationMethodology back from the half-initialized organize_options. This crashed `fo` at startup. Defer the styles import to OrganizeOptions.__post_init__, its only use site. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7 of 9 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
focrashes at startup on currentmain— every command, includingfo --help:No existing issue; found while running the CLI locally.
Root cause
#1783 (path-aware prompts & auto-tagging) added a module-scope import of
services.auto_tagging.stylestocore/organize_options.py. Importing anything underfile_organizer.servicesfirst executesservices/__init__.py, which eagerly importssmart_suggestions→models→models.text_model→config→config.manager→config.methodology, andconfig.methodologyimportsOrganizationMethodologyback fromorganize_options— which at that point hasn't reached the class definition yet.The CLI's import order (
cli.main→cli.organize→organization_service→file_ops→core.types→core.plan→organize_options) enters the cycle atorganize_options, so it fails. The test suite didn't catch it becauseconftestimportsfile_organizer.configfirst, which happens to load the modules in a cycle-safe order.What changed
src/file_organizer/core/organize_options.py: move thenormalize_tag_prompt/validate_tag_styleimport intoOrganizeOptions.__post_init__, its only use site, with a comment explaining why it's deferred.styles.pyitself depends only ontag_normalize, so the deferred import is cheap. This also removes acore→servicesmodule-load dependency from the domain contract.tests/core/test_import_cycles.py(new): cold-importscore.organize_options,core.plan, andcli.maineach in a fresh subprocess (same pattern astest_core_lazy_imports.py), so the cycle can't be masked by import order inside the test process.Type of change
How Has This Been Tested?
organize_options.py(all 3 parametrized cold imports fail with theImportErrorabove), GREEN after the fix.fo --helpruns again; cold imports oforganize_options,config.methodology,config,services,cli.main,core.planall succeed.tests/core,tests/cli,tests/config,tests/integration/test_setup_wizard_core.py,tests/integration/test_cli_setup.py: 1944 passed, 2 skipped.ruff check/ruff format --checkon changed files: clean.mypycould not be run locally: it aborts on a syntax error inside the installed PyQt6 stubs (QtGui.pyi) before reaching project files — environment issue, unrelated to this change.Checklist:
🤖 Generated with Claude Code