Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mypy errors when using tomlkit to modify toml document #356

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
11 changes: 11 additions & 0 deletions tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
Loading