mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
fix import sorting
This commit is contained in:
parent
74827c02b9
commit
a8476f2ea9
44 changed files with 68 additions and 76 deletions
|
|
@ -1,12 +1,11 @@
|
|||
"""API Error Handlers."""
|
||||
|
||||
from hyperglass.log import log
|
||||
|
||||
# Third Party
|
||||
from fastapi import Request
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
from hyperglass.state import use_state
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ def build_ui(timeout: int) -> None:
|
|||
"""Create a new UI build."""
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
from hyperglass.configuration import init_user_config
|
||||
from hyperglass.frontend import build_frontend
|
||||
from hyperglass.configuration import init_user_config
|
||||
|
||||
# Populate configuration to Redis prior to accessing it.
|
||||
init_user_config()
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
BuiltinDirective,
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
# Project
|
||||
from hyperglass.models.directive import (
|
||||
Text,
|
||||
RuleWithIPv4,
|
||||
RuleWithIPv6,
|
||||
RuleWithPattern,
|
||||
Text,
|
||||
BuiltinDirective,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class PublicHyperglassError(HyperglassError):
|
|||
|
||||
def __init__(self, **kwargs: str) -> None:
|
||||
"""Format error message with keyword arguments."""
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
|
||||
if "error" in kwargs:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# Standard Library
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
|
||||
# Local
|
||||
from ._common import PublicHyperglassError
|
||||
|
||||
|
|
@ -82,6 +81,7 @@ class QueryLocationNotFound(NotFound):
|
|||
|
||||
def __init__(self, location: Any, **kwargs: Dict[str, Any]) -> None:
|
||||
"""Initialize a NotFound error for a query location."""
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
|
||||
(text := use_state("params").web.text)
|
||||
|
|
@ -94,6 +94,7 @@ class QueryTypeNotFound(NotFound):
|
|||
|
||||
def __init__(self, query_type: Any, **kwargs: Dict[str, Any]) -> None:
|
||||
"""Initialize a NotFound error for a query type."""
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
|
||||
(text := use_state("params").web.text)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
# Project
|
||||
# Standard Library
|
||||
import typing as t
|
||||
|
||||
# Third Party
|
||||
import pytest
|
||||
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
from hyperglass.models.api import Query
|
||||
from hyperglass.configuration import init_ui_params
|
||||
from hyperglass.models.config.params import Params
|
||||
from hyperglass.models.directive import Directives
|
||||
from hyperglass.models.config.params import Params
|
||||
from hyperglass.models.config.devices import Devices
|
||||
from hyperglass.state import use_state
|
||||
|
||||
# Local
|
||||
from .._construct import Construct
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
# Project
|
||||
from hyperglass.state import HyperglassState
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from hyperglass.log import log
|
|||
from hyperglass.util import copyfiles, check_path, dotenv_to_dict
|
||||
from hyperglass.state import use_state
|
||||
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
# Project
|
||||
from hyperglass.models.ui import UIParameters
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ from .util import cpu_count
|
|||
from .state import use_state
|
||||
from .settings import Settings
|
||||
|
||||
|
||||
log_level = "INFO" if Settings.debug is False else "DEBUG"
|
||||
|
||||
setup_lib_logging(log_level)
|
||||
|
|
@ -43,6 +42,7 @@ init_logger(log_level)
|
|||
|
||||
async def build_ui() -> bool:
|
||||
"""Perform a UI build prior to starting the application."""
|
||||
# Local
|
||||
from .frontend import build_frontend
|
||||
|
||||
state = use_state()
|
||||
|
|
@ -59,6 +59,7 @@ async def build_ui() -> bool:
|
|||
def register_all_plugins() -> None:
|
||||
"""Validate and register configured plugins."""
|
||||
|
||||
# Local
|
||||
from .plugins import register_plugin, init_builtin_plugins
|
||||
|
||||
state = use_state()
|
||||
|
|
@ -85,6 +86,7 @@ def register_all_plugins() -> None:
|
|||
|
||||
def unregister_all_plugins() -> None:
|
||||
"""Unregister all plugins."""
|
||||
# Local
|
||||
from .plugins import InputPluginManager, OutputPluginManager
|
||||
|
||||
for manager in (InputPluginManager, OutputPluginManager):
|
||||
|
|
@ -156,6 +158,7 @@ class HyperglassWSGI(BaseApplication):
|
|||
def start(*, log_level: str, workers: int, **kwargs) -> None:
|
||||
"""Start hyperglass via gunicorn."""
|
||||
|
||||
# Local
|
||||
from .log import CustomGunicornLogger
|
||||
|
||||
HyperglassWSGI(
|
||||
|
|
@ -181,6 +184,7 @@ def start(*, log_level: str, workers: int, **kwargs) -> None:
|
|||
|
||||
def run(_workers: int = None):
|
||||
"""Run hyperglass."""
|
||||
# Local
|
||||
from .configuration import init_user_config
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import secrets
|
|||
from datetime import datetime
|
||||
|
||||
# Third Party
|
||||
from pydantic import BaseModel, constr, field_validator, ConfigDict
|
||||
from pydantic import BaseModel, ConfigDict, constr, field_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
@ -20,7 +20,6 @@ from hyperglass.exceptions.private import InputValidationError
|
|||
# Local
|
||||
from ..config.devices import Device
|
||||
|
||||
|
||||
QueryLocation = constr(strip_whitespace=True, strict=True, min_length=1)
|
||||
QueryTarget = constr(strip_whitespace=True, min_length=1)
|
||||
QueryType = constr(strip_whitespace=True, strict=True, min_length=1)
|
||||
|
|
|
|||
|
|
@ -4,15 +4,7 @@
|
|||
import typing as t
|
||||
|
||||
# Third Party
|
||||
from pydantic import (
|
||||
BaseModel,
|
||||
StrictInt,
|
||||
StrictStr,
|
||||
StrictBool,
|
||||
field_validator,
|
||||
Field,
|
||||
ConfigDict,
|
||||
)
|
||||
from pydantic import Field, BaseModel, StrictInt, StrictStr, ConfigDict, StrictBool, field_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
# Standard Library
|
||||
# flake8: noqa
|
||||
import math
|
||||
import secrets
|
||||
import typing as t
|
||||
import secrets
|
||||
from datetime import datetime
|
||||
|
||||
# Third Party
|
||||
from pydantic import BaseModel, field_validator, ConfigDict, Field
|
||||
from pydantic import Field, BaseModel, ConfigDict, field_validator
|
||||
|
||||
"""Patterns:
|
||||
GET /.well-known/looking-glass/v1/ping/2001:DB8::35?protocol=2,1
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
"""Custom validation types."""
|
||||
|
||||
# Standard Library
|
||||
import typing as t
|
||||
|
||||
# Third Party
|
||||
from pydantic import AfterValidator
|
||||
|
||||
# Project
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from pathlib import Path
|
|||
from ipaddress import IPv4Address, IPv6Address
|
||||
|
||||
# Third Party
|
||||
from pydantic import FilePath, field_validator, ValidationInfo
|
||||
from pydantic import FilePath, ValidationInfo, field_validator
|
||||
from netmiko.ssh_dispatcher import CLASS_MAPPER # type: ignore
|
||||
|
||||
# Project
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"""Configuration for API docs feature."""
|
||||
|
||||
# Standard Library
|
||||
import typing as t
|
||||
|
||||
# Third Party
|
||||
|
|
|
|||
|
|
@ -5,12 +5,7 @@ import typing as t
|
|||
|
||||
# Third Party
|
||||
import httpx
|
||||
from pydantic import (
|
||||
FilePath,
|
||||
SecretStr,
|
||||
PrivateAttr,
|
||||
IPvAnyAddress,
|
||||
)
|
||||
from pydantic import FilePath, SecretStr, PrivateAttr, IPvAnyAddress
|
||||
|
||||
# Project
|
||||
from hyperglass.models import HyperglassModel
|
||||
|
|
|
|||
|
|
@ -5,13 +5,7 @@ import typing as t
|
|||
from pathlib import Path
|
||||
|
||||
# Third Party
|
||||
from pydantic import (
|
||||
ByteSize,
|
||||
SecretStr,
|
||||
AnyHttpUrl,
|
||||
DirectoryPath,
|
||||
field_validator,
|
||||
)
|
||||
from pydantic import ByteSize, SecretStr, AnyHttpUrl, DirectoryPath, field_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.constants import __version__
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import typing as t
|
|||
from pathlib import Path
|
||||
|
||||
# Third Party
|
||||
from pydantic import Field, field_validator, ValidationInfo, ConfigDict
|
||||
from pydantic import Field, ConfigDict, ValidationInfo, field_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.settings import Settings
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import typing as t
|
|||
from ipaddress import IPv4Address, IPv6Address
|
||||
|
||||
# Third Party
|
||||
from pydantic import field_validator, ValidationInfo
|
||||
from pydantic import ValidationInfo, field_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.util import resolve_hostname
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# Standard Library
|
||||
import typing as t
|
||||
|
||||
|
||||
# Local
|
||||
from ..main import HyperglassModel
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import typing as t
|
|||
from pathlib import Path
|
||||
|
||||
# Third Party
|
||||
from pydantic import HttpUrl, FilePath, constr, field_validator, model_validator, ValidationInfo
|
||||
from pydantic import HttpUrl, FilePath, ValidationInfo, constr, field_validator, model_validator
|
||||
from pydantic_extra_types.color import Color
|
||||
|
||||
# Project
|
||||
|
|
|
|||
|
|
@ -6,13 +6,7 @@ import typing as t
|
|||
from ipaddress import IPv4Network, IPv6Network, ip_network
|
||||
|
||||
# Third Party
|
||||
from pydantic import (
|
||||
field_validator,
|
||||
Field,
|
||||
FilePath,
|
||||
IPvAnyNetwork,
|
||||
PrivateAttr,
|
||||
)
|
||||
from pydantic import Field, FilePath, PrivateAttr, IPvAnyNetwork, field_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
@ -24,7 +18,6 @@ from hyperglass.exceptions.private import InputValidationError
|
|||
from .main import MultiModel, HyperglassModel, HyperglassUniqueModel
|
||||
from .fields import Action
|
||||
|
||||
|
||||
StringOrArray = t.Union[str, t.List[str]]
|
||||
Condition = t.Union[IPvAnyNetwork, str]
|
||||
RuleValidation = t.Union[t.Literal["ipv4", "ipv6", "pattern"], None]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import typing as t
|
|||
from pathlib import Path
|
||||
|
||||
# Third Party
|
||||
from pydantic import HttpUrl, BaseModel, PrivateAttr, RootModel, ConfigDict
|
||||
from pydantic import HttpUrl, BaseModel, RootModel, ConfigDict, PrivateAttr
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import typing as t
|
||||
from datetime import datetime
|
||||
|
||||
# Third Party
|
||||
from pydantic import ConfigDict
|
||||
|
||||
# Project
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import typing as t
|
|||
from datetime import datetime
|
||||
|
||||
# Third Party
|
||||
from pydantic import model_validator, ConfigDict
|
||||
from pydantic import ConfigDict, model_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import typing as t
|
||||
|
||||
# Third Party
|
||||
from pydantic import field_validator, model_validator, ConfigDict
|
||||
from pydantic import ConfigDict, field_validator, model_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ from pydantic import (
|
|||
SecretStr,
|
||||
DirectoryPath,
|
||||
IPvAnyAddress,
|
||||
field_validator,
|
||||
ValidationInfo,
|
||||
field_validator,
|
||||
)
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
# Project
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import typing as t
|
|||
from datetime import datetime
|
||||
|
||||
# Third Party
|
||||
from pydantic import model_validator, ConfigDict
|
||||
from pydantic import ConfigDict, model_validator
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# Project
|
||||
from hyperglass.models.config.devices import Device
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
"""Test BGP Community validation."""
|
||||
# Standard Library
|
||||
import typing as t
|
||||
|
||||
# Third Party
|
||||
import pytest
|
||||
|
||||
# Project
|
||||
from hyperglass.state import use_state
|
||||
from hyperglass.models.config.params import Params
|
||||
|
||||
# Local
|
||||
from .._builtin.bgp_community import ValidateBGPCommunity
|
||||
|
||||
from hyperglass.state import use_state
|
||||
from hyperglass.models.config.params import Params
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
# Project
|
||||
from hyperglass.state import HyperglassState
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ from hyperglass.models.config.devices import Device
|
|||
from hyperglass.models.data.bgp_route import BGPRouteTable
|
||||
|
||||
# Local
|
||||
from .._builtin.bgp_route_arista import BGPRoutePluginArista
|
||||
from ._fixtures import MockDevice
|
||||
from .._builtin.bgp_route_arista import BGPRoutePluginArista
|
||||
|
||||
DEPENDS_KWARGS = {
|
||||
"depends": [
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ from hyperglass.models.api.query import Query
|
|||
from hyperglass.models.data.bgp_route import BGPRouteTable
|
||||
|
||||
# Local
|
||||
from .._builtin.bgp_route_juniper import BGPRoutePluginJuniper
|
||||
from ._fixtures import MockDevice
|
||||
from .._builtin.bgp_route_juniper import BGPRoutePluginJuniper
|
||||
|
||||
DEPENDS_KWARGS = {
|
||||
"depends": [
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
"""Test state hooks."""
|
||||
|
||||
# Standard Library
|
||||
import typing as t
|
||||
import pytest
|
||||
|
||||
# Third Party
|
||||
import pytest
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from hyperglass.state import HyperglassState
|
||||
|
||||
# Project
|
||||
from hyperglass.models.ui import UIParameters
|
||||
from hyperglass.models.config.devices import Devices
|
||||
from hyperglass.configuration import init_ui_params
|
||||
from hyperglass.models.config.params import Params
|
||||
from hyperglass.models.directive import Directives
|
||||
from hyperglass.models.config.params import Params
|
||||
from hyperglass.models.config.devices import Devices
|
||||
|
||||
# Local
|
||||
from ..hooks import use_state
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue