Skip to content

Conversation

@DaisukeYoda
Copy link
Member

Summary

  • Fix -c flag to accept direct file paths (not just directories)
  • Fix config auto-discovery to search from target analysis paths, not just CWD
  • Prioritize .pyscn.toml over pyproject.toml across parent directories
  • Only use pyproject.toml if it contains [tool.pyscn] section

Problem

Previously, config file discovery had two issues:

  1. The -c flag expected a directory path, not a file path. Specifying a config file directly (e.g., -c myconfig.toml) didn't work.

  2. FindDefaultConfigFile only searched the current working directory. Config files in parent directories of the target weren't discovered.

For example, with this structure:

project/
├── .pyscn.toml          # pyscn config
└── subproject/
    ├── pyproject.toml   # subproject's own pyproject.toml
    └── src/

Running pyscn analyze project/subproject/src would find subproject/pyproject.toml instead of project/.pyscn.toml.

Solution

  • LoadConfig now handles both file paths and directory paths
  • FindConfigFileFromPath prioritizes .pyscn.toml across all parent directories before falling back to pyproject.toml
  • pyproject.toml is only used if it contains [tool.pyscn] section
  • analyze_usecase.go auto-discovers config from target paths when no explicit config is specified

Test plan

  • Build succeeds
  • All existing tests pass
  • Manual testing with nested directory structures
  • Verified -c flag works with direct file paths
  • Verified config auto-discovery from target paths

Previously, config file discovery had two issues:

1. The `-c` flag expected a directory path, not a file path, so specifying
   a config file directly (e.g., `-c myconfig.toml`) didn't work as expected.

2. `FindDefaultConfigFile` only searched the current working directory,
   not the target analysis path. This meant config files placed in parent
   directories of the target weren't discovered.

Changes:
- `LoadConfig` now handles both file paths and directory paths correctly
- Added `loadFromFile` to directly load a specified config file
- Added `LoadPyprojectConfigFromFile` for direct pyproject.toml loading
- `FindConfigFileFromPath` now prioritizes `.pyscn.toml` across all parent
  directories before falling back to `pyproject.toml`
- `pyproject.toml` is only used if it contains `[tool.pyscn]` section
- `analyze_usecase.go` now auto-discovers config from target paths when
  no explicit config is specified
- Simplified `FindDefaultConfigFile` in all config loaders to use the
  shared `FindConfigFileFromPath` implementation
@DaisukeYoda DaisukeYoda self-assigned this Feb 4, 2026
- resolve config path once at analyze entrypoint and reuse across phases
- load explicit --config file directly instead of rediscovering by directory
- centralize config discovery in TomlConfigLoader resolver methods
- parse pyproject.toml to detect [tool.pyscn] instead of string matching
- align default config discovery in service loaders
- add tests for explicit pyproject precedence and quoted [tool."pyscn"] sections
- isolate integration clone config test from repo-level config discovery
- return an error whenever ResolveConfigPath receives a missing configPath
- keep auto-discovery behavior only for implicit config resolution
- add coverage for missing non-toml explicit paths
- update LoadConfig non-existent path expectation to error
@LudoTechnologies LudoTechnologies requested review from LudoTechnologies and removed request for LudoTechnologies February 5, 2026 14:49
@DaisukeYoda DaisukeYoda requested review from LudoTechnologies and removed request for LudoTechnologies February 5, 2026 14:51
@DaisukeYoda DaisukeYoda merged commit f8d4b40 into main Feb 5, 2026
4 checks passed
@LudoTechnologies LudoTechnologies deleted the fix/config-file-discovery branch February 5, 2026 15:00
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