Skip to content

fix(http-client-python): preserve customized pyproject.toml fields#2

Closed
l0lawrence wants to merge 1 commit into
mainfrom
l0lawrence/python-pyproject-preserve-fields
Closed

fix(http-client-python): preserve customized pyproject.toml fields#2
l0lawrence wants to merge 1 commit into
mainfrom
l0lawrence/python-pyproject-preserve-fields

Conversation

@l0lawrence

Copy link
Copy Markdown
Owner

Fixes microsoft#10311

Problem

The Python emitter regenerates pyproject.toml on every emit and clobbers manual edits to fields it doesn't own — for example downcasing "AI" to "Ai" in the description, dropping Python versions from the classifiers list, and replacing a custom repository URL with the generic Azure SDK one.

Fix

Extend the existing KEEP_FIELDS preservation mechanism so the emitter preserves the following from an existing pyproject.toml instead of overwriting them:

  • project.description
  • project.classifiers
  • [project.urls]

On first emit (no existing file) these are still generated as before. When the file already exists, the user's values are carried through.

Changes

  • general_serializer.py: extract description, classifiers, and urls into KEEP_FIELDS.
  • pyproject.toml.jinja2: use preserved values when present, fall back to generated defaults otherwise.
  • Added unit tests in tests/unit/test_pyproject_keep_fields.py.
  • Added a changeset entry.

Validation

  • New unit tests pass.
  • Template renders valid TOML in both the default and preserved-fields branches (verified by round-tripping through tomli).
  • Black formatting passes with the repo config.

Preserve manually customized description, classifiers, and [project.urls]

fields from an existing pyproject.toml instead of overwriting them on emit.

Fixes microsoft#10311

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@l0lawrence l0lawrence closed this Jun 15, 2026
@github-actions

Copy link
Copy Markdown

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Preserve manually customized description, classifiers, and [project.urls] fields in an existing pyproject.toml instead of overwriting them on regeneration.

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.

[python] overwriting of pyproject fields

1 participant