Skip to content

fix: check for None before dividing completion times by 3600 - #61

Merged
ScrappyCocco merged 1 commit into
ScrappyCocco:masterfrom
Jah-yee:fix/null-check-comp-fields
Oct 2, 2026
Merged

ScrappyCocco merged 1 commit into
ScrappyCocco:masterfrom
Jah-yee:fix/null-check-comp-fields

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

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

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.
@ScrappyCocco
ScrappyCocco merged commit 4275a45 into ScrappyCocco:master Oct 2, 2026
4 checks passed
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.

[BUG] Null optional completion times raise TypeError in JSONResultParser

2 participants