mirror of
https://github.com/soxoj/maigret.git
synced 2026-10-19 06:43:27 +02:00
The save at the end of Submitter.dialog read self.args.db, an attribute argparse never creates: maigret.py declares --db with dest="db_file", and the line right above it in the same block already reads self.args.db_file. So `maigret --submit <url> --db custom.json` ran the whole interactive dialog and then raised AttributeError on the final step. dialog() never returned True, so main() never reached save_db_safely() either, and the newly submitted site was lost after every question had been answered. The default path was unaffected, because the block is guarded by `db_file != settings.sites_db_path`. Removing the block rather than renaming the attribute: main() already persists the database after a successful submit, through save_db_safely(db, db_file, logger). That call takes its path from resolve_db_path(), which returns an absolute or module-relative path for a custom --db, so the removed line could have written to a different file than the rest of the run uses. save_db_safely also tolerates a read-only installation, which db.save_to_file() does not. The existing dialog tests pass a MagicMock, which answers to any attribute name, so the typo was invisible to them. The new test builds its namespace with the real parser. Co-authored-by: datrixlab <325650023+datrixlab@users.noreply.github.com>