Import `packaging` package lazily
This commit is contained in:
parent
796fba6788
commit
f1f9c7792b
|
@ -23,7 +23,6 @@ from typing import Union
|
|||
|
||||
import attr
|
||||
import py
|
||||
from packaging.version import Version
|
||||
from pluggy import HookimplMarker
|
||||
from pluggy import HookspecMarker
|
||||
from pluggy import PluginManager
|
||||
|
@ -1059,6 +1058,9 @@ class Config:
|
|||
|
||||
minver = self.inicfg.get("minversion", None)
|
||||
if minver:
|
||||
# Imported lazily to improve start-up time.
|
||||
from packaging.version import Version
|
||||
|
||||
if Version(minver) > Version(pytest.__version__):
|
||||
raise pytest.UsageError(
|
||||
"%s:%d: requires pytest-%s, actual pytest-%s'"
|
||||
|
|
|
@ -9,8 +9,6 @@ from typing import cast
|
|||
from typing import Optional
|
||||
from typing import TypeVar
|
||||
|
||||
from packaging.version import Version
|
||||
|
||||
TYPE_CHECKING = False # avoid circular import through compat
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -217,6 +215,9 @@ def importorskip(
|
|||
return mod
|
||||
verattr = getattr(mod, "__version__", None)
|
||||
if minversion is not None:
|
||||
# Imported lazily to improve start-up time.
|
||||
from packaging.version import Version
|
||||
|
||||
if verattr is None or Version(verattr) < Version(minversion):
|
||||
raise Skipped(
|
||||
"module %r has __version__ %r, required is: %r"
|
||||
|
|
Loading…
Reference in New Issue