diff --git a/CHANGELOG.md b/CHANGELOG.md index 833c2dc..2e1a922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed +- Fix mypy errors when using tomlkit to modify toml document. ([#326](https://github.com/python-poetry/tomlkit/issues/326)) - Fix the incompatiblity with 3.13 because of the `datetime.replace()` change. ([#333](https://github.com/python-poetry/tomlkit/issues/333)) - Revert the change of parsing out-of-order tables. ([#347](https://github.com/python-poetry/tomlkit/issues/347)) diff --git a/tomlkit/items.py b/tomlkit/items.py index 661e09c..452aec7 100644 --- a/tomlkit/items.py +++ b/tomlkit/items.py @@ -521,6 +521,17 @@ def __reduce__(self): def __reduce_ex__(self, protocol): return self.__class__, self._getstate(protocol) + # Leave it here to improve type hint for `tomlkit.parse` + # For example: + # doc = tomlkit.parse(Path('pyproject.toml').read_text()) + # print(doc['tool']['poetry']) + def __getitem__(self, key) -> Any: + raise NotImplementedError() + + # Improve type hint for document modify, ex: `doc['tool']['poetry']={}` + def __setitem__(self, key, value) -> None: + raise NotImplementedError() + class Whitespace(Item): """