Replace toml with tomli (#787)

* Replace `toml` with `tomli`

* Replace `toml` with `tomli`
This commit is contained in:
Nikita Sobolev
2021-12-16 22:19:34 +03:00
committed by GitHub
parent b50a9077f8
commit 02a39f722d
3 changed files with 7 additions and 4 deletions

View File

@@ -7,6 +7,5 @@ pre-commit==2.13.0
pytest==6.1.1 pytest==6.1.1
pytest-mypy-plugins==1.9.2 pytest-mypy-plugins==1.9.2
psycopg2-binary psycopg2-binary
types-toml==0.1.1
-e ./django_stubs_ext -e ./django_stubs_ext
-e . -e .

View File

@@ -4,7 +4,7 @@ import textwrap
from functools import partial from functools import partial
from typing import Callable, Dict, List, NoReturn, Optional, Tuple, cast from typing import Callable, Dict, List, NoReturn, Optional, Tuple, cast
import toml import tomli
from django.db.models.fields.related import RelatedField from django.db.models.fields.related import RelatedField
from mypy.modulefinder import mypy_path from mypy.modulefinder import mypy_path
from mypy.nodes import MypyFile, TypeInfo from mypy.nodes import MypyFile, TypeInfo
@@ -103,7 +103,11 @@ def extract_django_settings_module(config_file_path: Optional[str]) -> str:
handler.error("'django_settings_module' not found or invalid: " + messages[error_type]) handler.error("'django_settings_module' not found or invalid: " + messages[error_type])
if config_file_path and helpers.is_toml(config_file_path): if config_file_path and helpers.is_toml(config_file_path):
toml_data = toml.load(config_file_path) try:
with open(config_file_path, encoding="utf-8") as config_file_obj:
toml_data = tomli.loads(config_file_obj.read())
except Exception:
exit_toml(1)
try: try:
config = toml_data["tool"]["django-stubs"] config = toml_data["tool"]["django-stubs"]
except KeyError: except KeyError:

View File

@@ -24,7 +24,7 @@ dependencies = [
"mypy>=0.910", "mypy>=0.910",
"django", "django",
"django-stubs-ext>=0.3.0", "django-stubs-ext>=0.3.0",
"toml", "tomli",
# Types: # Types:
"typing-extensions", "typing-extensions",
"types-pytz", "types-pytz",