fix: validate config, separate comments/submissions, fix crash bugs#1
Open
dbeley wants to merge 1 commit into
Open
fix: validate config, separate comments/submissions, fix crash bugs#1dbeley wants to merge 1 commit into
dbeley wants to merge 1 commit into
Conversation
- Fix UnboundLocalError in read_config when file is missing - Fix IndexError in export_data on empty data - Fix AttributeError when reddit_connect returns None - Add safe dict access for config options (prevent KeyError) - Implement proper config validation (structure, required fields, valid export types) with descriptive error messages - Split comments and submissions into separate export options (comments → own comments, submissions → own posts) - Fix format variable shadowing built-in format() - Remove dead set_defaults(boolean_flag=False) line - Reformat with Black
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.
Summary
Bug fixes, config validation, and separation of
comments/submissionsexport options.Changes
Bug fixes:
read_config: FixedUnboundLocalErrorcrash when config file doesn't exist — now returnsNoneinstead of crashing.export_data: Added early return whendatais empty to preventIndexError.reddit_connect: AddedNoneguard inextract_data— if connection fails, returns empty list instead of crashing withAttributeError.config["options"]access (could raiseKeyError) to safe.get()with defaults.New features:
commentsandsubmissionsexports: Previouslysubmissionsexported both posts and comments together, while the config example advertised a- commentsoption that wasn't implemented. Now:comments→ exports only user commentssubmissions→ exports only user submissions (posts)validate_config()placeholder with real validation that checks for required fields, valid export types, and proper structure. Returns descriptive error messages.Code quality:
formatvariable that shadowed the built-informat()function (renamed tolog_format).parser.set_defaults(boolean_flag=False)line referencing a non-existent argument.# TODO Add config file validation.comment.