Skip to content

Python: chore: drop four module constants nothing reads - #10395

Open
Hyacinth-of-Security (lxcxjxhx) wants to merge 2 commits into
microsoft:mainfrom
lxcxjxhx:chore/drop-unread-constants
Open

Hyacinth-of-Security (lxcxjxhx) wants to merge 2 commits into
microsoft:mainfrom
lxcxjxhx:chore/drop-unread-constants

Conversation

@lxcxjxhx

Copy link
Copy Markdown
Contributor

Four module-level names that no code reads. Each appears exactly once in the repository — its own definition — and none is listed in an __all__.

The four

$ for s in CONVERSATION_ITEM_TYPE_CHECKPOINT CONVERSATION_TYPE_CHECKPOINT_CONTAINER \
           BEDROCK_OPTION_TRANSLATIONS AGUI_OPTION_TRANSLATIONS KNOWN_MEDIA_TYPES; do
    printf '%-42s ' "$s"; grep -rn "\b$s\b" --include=*.py . | wc -l
  done
CONVERSATION_ITEM_TYPE_CHECKPOINT          1
CONVERSATION_TYPE_CHECKPOINT_CONTAINER     1
BEDROCK_OPTION_TRANSLATIONS                1
AGUI_OPTION_TRANSLATIONS                   1
KNOWN_MEDIA_TYPES                          1
file name why it is a leftover
devui/.../_conversations.py CONVERSATION_ITEM_TYPE_CHECKPOINT, CONVERSATION_TYPE_CHECKPOINT_CONTAINER both call sites write the literal "type": "checkpoint" (lines 518, 785), so the constants were left behind when the literal replaced them
bedrock/.../_chat_client.py BEDROCK_OPTION_TRANSLATIONS the Converse request is assembled inline ("modelId": model, "inferenceConfig": {"maxTokens": …}); nothing consults the mapping
ag-ui/.../_types.py AGUI_OPTION_TRANSLATIONS an empty dict, unread
core/.../_types.py KNOWN_MEDIA_TYPES detect_media_type_from_base64 decides the media type; the list is unused

What this is not

  • Not an API change. None of the five is exported: bedrock/.../_chat_client.py has an __all__ and these are not in it; the other three modules have no __all__ and the names are not re-exported by their packages (grep across __init__.py files returns nothing).
  • Not a behaviour change. No call site, no signature, no default touched. 43 deleted lines, 0 added.

Verification

  • An AST pass over every .py in the repo (1365 files) reports these five as "defined once, read nowhere"; the same pass after this change reports only two constants inside python/samples/ and RESPONSE_TYPE in agent_framework_openai/_shared.py, which I left alone: removing that union would orphan eight imports, so it belongs in its own change.
  • python -m compileall on the four touched files, then ruff check and ruff format --check: clean.
  • I did not run the package test suites. A deletion of unread names cannot change their result, but if you want a run before merging, say so.

Precedent

#10239 removed OTEL_METRICS the same way and was merged, which is why I am proposing the leftovers in one pass rather than one PR per file.

Each name below appears exactly once in the repository — its own definition — and
is in no `__all__`:

* `CONVERSATION_ITEM_TYPE_CHECKPOINT` / `CONVERSATION_TYPE_CHECKPOINT_CONTAINER`
  (devui). The two checkpoint items are written as the `"checkpoint"` literal at
  both call sites, so the constants were left behind by a refactor.
* `BEDROCK_OPTION_TRANSLATIONS` (bedrock). The Converse request is assembled
  inline (`"modelId": model`, `"inferenceConfig": {...}`); nothing consults the
  mapping.
* `AGUI_OPTION_TRANSLATIONS` (ag-ui). An empty dict, unread.
* `KNOWN_MEDIA_TYPES` (core). `detect_media_type_from_base64` decides the media
  type; the list is unused.

Docstrings-only change to the module namespace: no call site, no signature, no
behaviour.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for this cleanup of unused module-level constants.

No open issues 🎉

What changed in this PR

Removes five unused module-level constants from four Python packages, continuing the dead-code cleanup established by #10239. No call sites, signatures, or defaults are changed.

Changes:

  • Removes two unused DevUI checkpoint constants.
  • Deletes unused Bedrock and AG-UI option-translation mappings.
  • Removes the unused core media-type list.
File Description
python/​packages/​devui/​agent_framework_devui/​_conversations.py Removes two checkpoint type constants.
python/​packages/​core/​agent_framework/​_types.py Removes KNOWN_MEDIA_TYPES.
python/​packages/​bedrock/​agent_framework_bedrock/​_chat_client.py Removes BEDROCK_OPTION_TRANSLATIONS and its docstring.
python/​packages/​ag-ui/​agent_framework_ag_ui/​_types.py Removes the empty AGUI_OPTION_TRANSLATIONS mapping and its docstring.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 3fa81db3 Deployed Nov 17, 2026 by lxcxjxhx via add_label #27945
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants