Skip to content

Implement iteration-based method for SettingsDict#201

Open
FichteFoll wants to merge 9 commits intomasterfrom
feature/iterable-dict
Open

Implement iteration-based method for SettingsDict#201
FichteFoll wants to merge 9 commits intomasterfrom
feature/iterable-dict

Conversation

@FichteFoll
Copy link
Member

Implements the methods that can reasonably be implemented using Settings.to_dict(self) and adjusts docstrings accordingly.

Closes #139

This implementation is closer to the type annotations (we specifically
support `dict`s and not arbitrary mappings) and follows the described
behavior of `dict.update` which iterates over the `dict`'s keys.

Additionally, adjust the typing annotation for the iterable version to
iterate over 2-tuples instead of `Iterable[str]`, which is closer to
the reality.

To my knowledge, it is not possible to express a 2-element iterable with
two distinct types in the current type system.
Also move caveat explanations to the class-level docstring.
@FichteFoll FichteFoll added this to the 2.2.0 milestone Feb 20, 2026
I forgot that we dropped support for the non-3.8 host already.
This aligns with the native dict signature.
@FichteFoll FichteFoll mentioned this pull request Feb 20, 2026
22 tasks
Copy link
Member

@deathaxe deathaxe left a comment

Choose a reason for hiding this comment

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

Haven't seen anyone using this class anywhere. There were probably good reasons for sublimehq to not natively implement Settings as a full Mapping. Regardless, this commit fills some gaps between Settings and Mappings.

@FichteFoll
Copy link
Member Author

Before merging this, I should implement some tests and have them pass locally at least.

Also adjust documentation accordingly.
mypy does not require these (anymore). ty does, but we don't use that
here.
@FichteFoll FichteFoll requested a review from deathaxe February 21, 2026 22:32
from collections.abc import Mapping

import sublime
from sublime_types import Value
Copy link
Member

Choose a reason for hiding this comment

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

Note, sublime_types being available as of ST4135+. Seems this change requires falling back to home grown Value type again :/

@FichteFoll
Copy link
Member Author

FichteFoll commented Feb 22, 2026

Feel free to continue with adding tests to this PR, btw. I won't work on it again until at least Friday.

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.

Since 4075, settings are iterable

2 participants