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

Conversation

waketzheng
Copy link
Contributor

Fixes #326

@waketzheng
Copy link
Contributor Author

Mini demo to check result:

from pathlib import Path
import tomlkit
 
doc = tomlkit.parse(Path('pyproject.toml').read_text())
poetry_conf = doc['tool']['poetry']
print(poetry_conf)
poetry_conf['version'] = '0'

@frostming
Copy link
Contributor

frostming commented Jun 4, 2024

But that is not right, you can't assume an abitrary item is a table.

You can't make that assumption in vanilla python either:

doc: dict[str, Any] = get_data()
print(doc['tool']['abc'])  # what type is doc['tool']?

Instead, you have to tell the typechecker the type information.

@frostming frostming closed this Jun 4, 2024
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.

MyPy errors when using tomlkit to modify toml documents
2 participants