Conversation
loadjsons() called json.load twice on the return_paths=False branch:
data.append(json.load(json.load(open(filepath))))
The outer call is handed the dict the inner one produced, so the tool dies
with AttributeError: 'dict' object has no attribute 'read'. Since
__main__ calls loadjsons("../clusters") with the default return_paths=False,
the duplicate-name checker has never run. It went unnoticed because
chk_empty_strings.py -- the caller CI exercises -- passes return_paths=True
and hits the working branch.
Load the file once and reuse it. Also close the handles (open() without
`with` on both branches) and set encoding='utf-8', since 89 of the 131
cluster files contain non-ASCII.
The tool now completes and reports 4,355 duplicated names/synonyms.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HZGwPoa8MMfkhCw47rDLA4
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.
BLUF —
chk_dup.pyaborts before it checks anything becausejson.loadis called on a dict.tools/chk_dup.pypasses the result ofjson.loadintojson.loada second time on thereturn_paths=Falsebranch, so the tool dies withAttributeError: 'dict' object has no attribute 'read'. Its own__main__duplicate-name check uses exactly that branch, so the tool has never run.chk_dup.py, which now completes and reports 4,355 duplicated names and synonyms already present in the clusters.Problem
tools/chk_dup.pycallsjson.loadtwice on thereturn_paths=Falsebranch:json.loadexpects a file object; the outer call is handed the dict the inner call just produced. So running the tool crashes immediately:chk_dup.py's own duplicate-name detection underif __name__ == '__main__'callsloadjsons("../clusters")with the defaultreturn_paths=False, so the tool has never actually run. It has gone unnoticed because the only other caller,tools/chk_empty_strings.py(which CI does exercise viavalidate_all.sh), passesreturn_paths=Trueand hits the working branch.Fix
Load the file once and reuse the result for both branches. While here, the file handles were never closed on either branch (
open()withoutwith) — that is fixed with a context manager, andencoding='utf-8'is set explicitly since 89 of the 131 cluster files contain non-ASCII.Verification
Both branches now return data:
And the tool runs to completion, reporting 4,355 duplicated names/synonyms across galaxies:
This PR only makes the tool run; the duplicates it now reports are cross-galaxy name collisions (many legitimate, e.g. an industry code shared between NAICS and NACE) and are not touched here.
🤖 Generated with Claude Code