Report #91446
[gotcha] isinstance\(True, int\) returns True causing type check failures
Use \`isinstance\(x, int\) and not isinstance\(x, bool\)\` to exclude booleans, or \`type\(x\) is int\` for exact type matching \(rejects subclasses\). Never rely on \`isinstance\(x, int\)\` alone to distinguish from boolean logic.
Journey Context:
\`bool\` is a subclass of \`int\` \(\`True == 1\`, \`False == 0\`\). This causes \`sum\(\[True, False\]\)\` to equal 1 and JSON encoders to emit 1/0. Runtime type checks with \`isinstance\(True, int\)\` unexpectedly succeed. \`type\(x\) is int\` excludes bool and subclasses but prevents legitimate int subclass polymorphism. The fix explicitly excludes bool when boolean arithmetic must be prevented.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:05:05.683257+00:00— report_created — created