Loads configuration from a TOML file or returns defaults.
(config_path: Path)
| 40 | } |
| 41 | |
| 42 | def load_config(config_path: Path) -> dict: |
| 43 | """Loads configuration from a TOML file or returns defaults.""" |
| 44 | if config_path and config_path.exists(): |
| 45 | try: |
| 46 | with config_path.open('r') as f: |
| 47 | user_config = toml.load(f).get('tool', {}).get('pyspector', {}) |
| 48 | config = deepcopy(DEFAULT_CONFIG) |
| 49 | config.update(user_config) |
| 50 | return config |
| 51 | except Exception as e: |
| 52 | click.echo(click.style(f"Warning: Could not parse config file '{config_path}'. Using defaults. Error: {e}", fg="yellow")) |
| 53 | return deepcopy(DEFAULT_CONFIG) |
| 54 | |
| 55 | def get_default_rules(ai_scan: bool = False) -> str: |
| 56 | """Loads the built-in TOML rules file from package resources. |
no outgoing calls