Skip to content

Fix: invoke/config.py:163 DataProxy.__setitem__ was typed as (self, key:... - #1081

Open
M001N wants to merge 1 commit into
pyinvoke:mainfrom
M001N:oss-engine/ed0e46e7-7f64028e
Open

Fix: invoke/config.py:163 DataProxy.__setitem__ was typed as (self, key:...#1081
M001N wants to merge 1 commit into
pyinvoke:mainfrom
M001N:oss-engine/ed0e46e7-7f64028e

Conversation

@M001N

@M001N M001N commented Aug 10, 2026

Copy link
Copy Markdown

Summary

Changed value: str to value: Any in DataProxy.setitem (invoke/config.py:163); Any was already imported from typing in that module. Pure type-annotation change, zero runtime behavior change.

Problem

pyinvoke/invoke issue reference: #1064 - Type hints of config do not accept other values than str

Root Cause

invoke/config.py:163 DataProxy.setitem was typed as (self, key: str, value: str) -> None, overly narrow since Config values are commonly non-str (bool, int, dict, etc.), matching getitem's Any return type and real runtime usage. This makes mypy flag valid downstream code as an [assignment] error, but only for consumers of invoke who don't have invoke's own disable_error_code=["assignment"] suppression in their mypy config.

Testing

PASS - check_type_fix.py exits 0 (mypy reports no [assignment] error) with the fix applied; empirically verified it exits 1 with 3 [assignment] errors when reverted to the original value: str annotation.

Related Issue

#1064 - Type hints of config do not accept other values than str

[!INFO]
🤖 This PR was prepared with AI assistance (Claude, via an autonomous engineering workflow with human review and approval gates). The fix was independently reviewed and manually verified by a human before submission.

DataProxy.__setitem__ was typed (key: str, value: str) -> None, but Config values are commonly non-str (bool, int, dict, etc), matching __getitem__ Any return type and actual usage. Change value: str to value: Any. Adds check_type_fix.py, a standalone mypy-based check (not pytest, since tests/conftest.py imports the Unix-only termios module) that reproduces the issue and bypasses this repo's own disable_error_code assignment suppression.
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.

1 participant