Skip to content

Drop the unused get_mod_state_by_cls() helper - #1520

Merged
asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:drop-unused-get-mod-state-by-cls
Sep 22, 2026
Merged

asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:drop-unused-get-mod-state-by-cls

Conversation

@asvetlov

Copy link
Copy Markdown
Member

What do these changes do?

get_mod_state_by_cls() in multidict/_multilib/state.h has no call
sites anywhere in the tree, so it is removed. Module state is reached
through get_mod_state(), get_mod_state_by_def() and
get_mod_state_by_def_checked() everywhere in the extension. Dropping
the helper also leaves PyType_GetModuleState() with no remaining
user; no include becomes unnecessary, since state.h gets that
declaration from Python.h.

C extension only; the pure-Python backend has no equivalent and needs
no matching change.

Are there changes in behavior for the user?

No. The helper was never reachable from Python.

Is it a substantial burden for the maintainers to support this?

No, it removes code.

Related issue number

None. Split out of #1518 so that pull request stays one logical change.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist — N/A, removal of dead code with no behaviour to test
  • Documentation reflects the changes — N/A, the helper was internal and undocumented
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt — N/A, no such file in this repo
  • Add a new news fragment into the CHANGES/ folder
  • make doc-spelling passes and any new technical words are added to docs/spelling_wordlist.txt

Drafted with Claude Code (Opus 5); reviewed by @asvetlov.

Agent run details (optional, for reviewers)

Verification that the helper is unreferenced:

$ grep -rn "get_mod_state_by_cls" .
CHANGES/1520.misc.rst:1:Removed ``get_mod_state_by_cls()``, an unused helper in the C extension

(only the news fragment, after the deletion). grep -rn "PyType_GetModuleState" over *.c/*.h excluding the vendored
pythoncapi_compat.h returns nothing afterwards.

Both backends, run after rebasing onto 1cdd934 (#1518):

C extension, CPython 3.14.7t

$ pip install -e . --force-reinstall --no-deps
$ python -m pytest tests -q
2187 passed, 23 skipped, 147 deselected in 90.67s

$ python -m pytest tests -q -m hypothesis
143 passed, 4 skipped, 2210 deselected in 58.40s

Pure Python

$ MULTIDICT_NO_EXTENSIONS=1 pip install -e . --force-reinstall --no-deps
$ MULTIDICT_NO_EXTENSIONS=1 python -m pytest tests -q --no-c-extensions
1104 passed, 1253 deselected in 107.44s

Docs

$ make doc-spelling
build succeeded.

pre-commit run over the changed files: clang-format and the
changelog :user: role check both pass.

The helper has had no call sites since it was introduced; module
state is reached through get_mod_state(), get_mod_state_by_def()
and get_mod_state_by_def_checked() everywhere in the extension.
Dropping it also leaves PyType_GetModuleState() unused.
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Sep 22, 2026
@codspeed

codspeed Bot commented Sep 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 298 untouched benchmarks


Comparing asvetlov:drop-unused-get-mod-state-by-cls (0f10dd8) with master (1cdd934)

Open in CodSpeed

@asvetlov
asvetlov marked this pull request as ready for review September 22, 2026 22:12
@asvetlov
asvetlov requested a review from webknjaz as a code owner September 22, 2026 22:12
@greptile-apps

greptile-apps Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

Safe to merge: the removed helper has no remaining dependency, and the compiled extension continues to build and pass focused coverage.

What we checked:

  • Authored and executed the C-extension validation script used for the pull request. T-Rex
  • Validated the pre-run state by inspecting the before-evidence log, which shows the parent helper definition, a clean C build, a compiled-extension import, and 52 passing focused C-extension tests. T-Rex
  • Validated the post-run state by inspecting the after-evidence log, which shows zero remaining non-release-note references, a clean GCC build with -Werror, a compiled-extension import, and 52 passing tests. T-Rex

Reviews (1) · Last reviewed commit: "Drop the unused get_mod_state_by_cls() h..."

@asvetlov
asvetlov merged commit 47f8f9c into aio-libs:master Sep 22, 2026
61 checks passed
@asvetlov
asvetlov deleted the drop-unused-get-mod-state-by-cls branch September 22, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant