Commit 55cba60
authored
Don't let a builtin name collision override a callable's real signature (#83)
`_robust_signature_of_callable` consulted the curated
`sigs_for_sigless_builtin_name` / `sigs_for_type_name` tables *before* trying
`inspect.signature`. Those tables are keyed by `__name__` (and by type name),
which is only a sound key for the C-level builtins they were written for. Any
callable that merely shared a builtin's name was therefore handed the builtin's
signature instead of its own:
f = mk_place_holder_func(['chunker', 'wfs'], name='map')
inspect.signature(f) # (chunker, wfs) <- correct
Sig(f) # (func, iterable, /, *iterables) <- wrong
Downstream this grew phantom parameters: every meshed DAG node built from a
function named `map` sprouted an extra `iterables` input.
The name-before-signature order was introduced to fix `operator` instances
(itemgetter/attrgetter/methodcaller), which in Python 3.12+ do have a signature
but a useless generic `(*args, **kwargs)`. That part is legitimate, so rather
than demote the tables to a pure fallback (which would change resolution for
`print`, `partialmethod`, the operator classes and the dunder wrappers, whose
`signature` succeeds but whose curated entries are intentionally richer), the
tables are now skipped only for callables that declare a signature of their own
-- Python-defined functions/methods, and anything carrying an explicit
`__signature__`. Genuine builtins declare neither, so they are unaffected.
Verified behaviour-neutral: resolution is byte-identical before and after across
all ~170 callables in `builtins`, `functools` and `operator` plus operator
instances. i2's own suite passes (699), and the 47-package dependents sweep has
an identical pass/fail set before and after (32 pass, 14 fail, all pre-existing).
Claude-Session: https://claude.ai/code/session_01Kug7UUbVeCQgruvNXUq63c1 parent d97bb09 commit 55cba60
2 files changed
Lines changed: 111 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
4311 | 4311 | | |
4312 | 4312 | | |
4313 | 4313 | | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
| 4343 | + | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
4314 | 4355 | | |
4315 | 4356 | | |
4316 | 4357 | | |
| |||
4330 | 4371 | | |
4331 | 4372 | | |
4332 | 4373 | | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
| 4377 | + | |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
| 4381 | + | |
4333 | 4382 | | |
4334 | | - | |
4335 | | - | |
4336 | | - | |
4337 | | - | |
4338 | | - | |
4339 | | - | |
4340 | | - | |
4341 | | - | |
4342 | | - | |
| 4383 | + | |
| 4384 | + | |
| 4385 | + | |
| 4386 | + | |
| 4387 | + | |
| 4388 | + | |
| 4389 | + | |
| 4390 | + | |
| 4391 | + | |
| 4392 | + | |
| 4393 | + | |
| 4394 | + | |
| 4395 | + | |
| 4396 | + | |
| 4397 | + | |
4343 | 4398 | | |
4344 | 4399 | | |
4345 | 4400 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2400 | 2400 | | |
2401 | 2401 | | |
2402 | 2402 | | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
0 commit comments