mirror of
https://github.com/lilydjwg/nvchecker
synced 2025-02-19 20:17:03 +00:00
fight mypy[1]
The following error will be reported without if: error: Name "tomllib" already defined (by an import) While this can be silenced by a "# type: ignore", in some case[2] mypy will report the following error: error: Unused "type: ignore" comment [1]: https://github.com/python/mypy/issues/1153 [2]: https://github.com/lilydjwg/nvchecker/actions/runs/4916840821/jobs/8793454970
This commit is contained in:
parent
62a3f336b8
commit
af77af34f3
@ -12,6 +12,7 @@ import argparse
|
||||
from typing import (
|
||||
Tuple, NamedTuple, Optional, List, Union,
|
||||
cast, Dict, Awaitable, Sequence, Any,
|
||||
TYPE_CHECKING,
|
||||
)
|
||||
import types
|
||||
from pathlib import Path
|
||||
@ -22,10 +23,13 @@ import json
|
||||
|
||||
import structlog
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError:
|
||||
import tomli as tomllib # type: ignore
|
||||
if TYPE_CHECKING:
|
||||
import tomli as tomllib
|
||||
else:
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError:
|
||||
import tomli as tomllib
|
||||
|
||||
import platformdirs
|
||||
|
||||
|
@ -14,10 +14,13 @@ from pathlib import Path
|
||||
import contextvars
|
||||
import abc
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError:
|
||||
import tomli as tomllib # type: ignore
|
||||
if TYPE_CHECKING:
|
||||
import tomli as tomllib
|
||||
else:
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError:
|
||||
import tomli as tomllib
|
||||
|
||||
import structlog
|
||||
|
||||
|
@ -5,11 +5,15 @@ import asyncio
|
||||
import structlog
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError:
|
||||
import tomli as tomllib # type: ignore
|
||||
if TYPE_CHECKING:
|
||||
import tomli as tomllib
|
||||
else:
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError:
|
||||
import tomli as tomllib
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
|
Loading…
Reference in New Issue
Block a user