Skip to content

fix: preserve list order when merging settings - #723

Open
yangfan-yf-yf wants to merge 1 commit into
python-lsp:developfrom
yangfan-yf-yf:agent/preserve-merged-list-order
Open

fix: preserve list order when merging settings#723
yangfan-yf-yf wants to merge 1 commit into
python-lsp:developfrom
yangfan-yf-yf:agent/preserve-merged-list-order

Conversation

@yangfan-yf-yf

Copy link
Copy Markdown

Fixes #677.

Problem

merge_dicts() merges two list values with list(set(a + b)). The set removes duplicates but also discards first-occurrence order, so configuration lists can vary across hash seeds. This is observable for ordered argument lists such as pylsp_mypy overrides, where option and value positions matter.

The existing merge behavior, introduced in #38, concatenates both lists and removes duplicates. This change preserves that behavior rather than redefining duplicate handling.

Change

  • replace set-based deduplication with dict.fromkeys(...) so the first occurrence wins and list order is stable
  • add regression coverage for cross-list duplicates and a mixed string/boolean override list matching the reported configuration shape

Validation

  • pytest test/test_utils.py -q - 10 passed
  • $env:PYTHONUTF8='1'; python -m pytest test/ -q --deselect=test/test_language_server.py::test_missing_message - 190 passed, 21 skipped, 1 deselected
  • ruff check pylsp test
  • ruff format --check pylsp test
  • git diff --check

test_missing_message is the single deselected test. It times out in this local Windows environment on both the unmodified develop commit and this branch; it does not exercise _utils.merge_dicts.

@yangfan-yf-yf
yangfan-yf-yf marked this pull request as ready for review August 9, 2026 12:05
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.

Messed plugin config list order

1 participant