Repository navigation
fix: check for None before dividing completion times by 3600 - #61
Merged
ScrappyCocco merged 1 commit intoOct 2, 2026
Merged
Conversation
Null completion time values (e.g. comp_main: null) raise TypeError when divided by 3600. The comment says 'Calculate only if value is not None' but the code only checks for key existence, not null values. Fix: add 'is not None' check to all 6 completion time fields.
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.
Bug Fix
Null completion time values (e.g. comp_main: null) raise TypeError when divided by 3600 in JSONResultParser.parse_json_element().
Root Cause
The code checks whether completion-time keys exist, but does not check whether the values are None. The comment says "Calculate only if value is not None" but implementation only checks key existence.
Fix
Add is not None checks to all 6 completion time fields: comp_main, comp_plus, comp_100, comp_all, invested_co, invested_mp.
Reproduction
from howlongtobeatpy.JSONResultParser import JSONResultParser
p = JSONResultParser('Example', 'https://example.com', 0)
p.parse_json_element({'game_id': 1, 'game_name': 'Example', 'comp_main': None})
Previously: TypeError. Now: handled correctly.
Fixes #60