Skip to content

Fix 251 - #254

Merged
oberstet merged 2 commits into
crossbario:masterfrom
oberstet:fix_251
Nov 11, 2026
Merged

oberstet merged 2 commits into
crossbario:masterfrom
oberstet:fix_251

Conversation

@oberstet

Copy link
Copy Markdown
Contributor

fixes #251

… the rule (crossbario#251)

- _BatchedCall.cancel() (_common.py): a real bug. cancel() set _timer to
  None, so a second cancel() raised AttributeError. It is now a no-op,
  as asyncio's Handle.cancel() is.
- make_logger() (aio.py and tx.py, 12 sites): the same caller-frame
  lookup, duplicated in both. It is now one helper,
  _common._caller_namespace(), which raises a clear RuntimeError when
  there is no caller frame (inspect.currentframe() is None on a Python
  without stack frames) instead of an AttributeError on None. On CPython
  and PyPy the namespaces are unchanged.
- _log() (aio.py): `_categories.get(key)` right after `key in
  _categories` cannot be None; `_categories[key]` says so, same
  behaviour.
- check-typing: --ignore missing-union-attribute removed.

The issue had two locations swapped: the cancel() site is
_common.py:46, the format one aio.py:170.

tests/test_issue_251.py: cancel twice; the namespace from a function and
from a method; no stack frames gives the RuntimeError; make_logger()'s
namespace on Twisted and on asyncio.

Checked with ty 0.0.100 (the newest): check-format, check-lint and
check-typing pass. The test suite, 111 passed and 10 skipped, on
CPython 3.11, CPython 3.14 and PyPy 3.11, each against this source.
With the cancel() fix reverted, the new test fails with AttributeError
and check-typing reports the site again.

Note: This work was completed with AI assistance (Claude Code).
@oberstet
oberstet merged commit 3dd62c0 into crossbario:master Nov 11, 2026
5 checks passed
@oberstet
oberstet deleted the fix_251 branch November 11, 2026 01:22
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.

check-typing: fix the 14 missing-union-attribute sites, then stop ignoring the rule

1 participant