mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 08:17:08 +08:00
Replace toml with tomli (#787)
* Replace `toml` with `tomli` * Replace `toml` with `tomli`
This commit is contained in:
@@ -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 .
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user