Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add isort to manage/sort imports #864

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pytest:
.PHONY: black
black:
poetry run black --check ${NORNIR_DIRS}
poetry run isort --check ${NORNIR_DIRS}

.PHONY: sphinx
sphinx:
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import sys
from typing import Dict

from nornir import __version__

from sphinx.application import Sphinx

from nornir import __version__

sys.path.insert(0, os.path.abspath("../"))


Expand Down
2 changes: 0 additions & 2 deletions docs/highlighter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from IPython.core.magic import register_line_magic
from IPython.display import HTML

from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_for_filename


HTML_TEMPLATE = """<style>
{}
</style>
Expand Down
2 changes: 1 addition & 1 deletion nornir/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import logging.config
from typing import List, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, List, Optional

from nornir.core.configuration import Config
from nornir.core.inventory import Inventory
Expand Down
6 changes: 3 additions & 3 deletions nornir/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import sys
import warnings
from pathlib import Path
from typing import Any, Dict, Optional, Type, TYPE_CHECKING, List, TypeVar

from nornir.core.exceptions import ConflictingConfigurationWarning
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, TypeVar

import ruamel.yaml

from nornir.core.exceptions import ConflictingConfigurationWarning

if TYPE_CHECKING:
from nornir.core.deserializer.inventory import Inventory # noqa

Expand Down
2 changes: 1 addition & 1 deletion nornir/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, TYPE_CHECKING
from typing import TYPE_CHECKING, Dict

if TYPE_CHECKING:
from nornir.core.connection import Connection
Expand Down
18 changes: 7 additions & 11 deletions nornir/core/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@
Any,
Callable,
Dict,
ItemsView,
Iterator,
KeysView,
List,
Optional,
Set,
TypeVar,
Union,
KeysView,
ValuesView,
ItemsView,
Iterator,
TypeVar,
)

from nornir.core.configuration import Config
from nornir.core.plugins.connections import (
ConnectionPlugin,
ConnectionPluginRegister,
)
from nornir.core.exceptions import ConnectionAlreadyOpen, ConnectionNotOpen

from mypy_extensions import Arg, KwArg

from nornir.core.configuration import Config
from nornir.core.exceptions import ConnectionAlreadyOpen, ConnectionNotOpen
from nornir.core.plugins.connections import ConnectionPlugin, ConnectionPluginRegister

HostOrGroup = TypeVar("HostOrGroup", "Host", "Group")

Expand Down
3 changes: 1 addition & 2 deletions nornir/core/plugins/connections.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Any, Dict, Type, Optional, Protocol
from typing import Any, Dict, Optional, Protocol, Type

from nornir.core.configuration import Config
from nornir.core.plugins.register import PluginRegister


CONNECTIONS_PLUGIN_PATH = "nornir.plugins.connections"


Expand Down
3 changes: 1 addition & 2 deletions nornir/core/plugins/inventory.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Any, Type, Protocol
from typing import Any, Protocol, Type

from nornir.core.inventory import Inventory, TransformFunction
from nornir.core.plugins.register import PluginRegister


INVENTORY_PLUGIN_PATH = "nornir.plugins.inventory"
TRANSFORM_FUNCTION_PLUGIN_PATH = "nornir.plugins.transform_function"

Expand Down
7 changes: 2 additions & 5 deletions nornir/core/plugins/register.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import sys
from typing import Dict, TypeVar, Generic
from typing import Dict, Generic, TypeVar

from nornir.core.exceptions import (
PluginAlreadyRegistered,
PluginNotRegistered,
)
from nornir.core.exceptions import PluginAlreadyRegistered, PluginNotRegistered

if sys.version_info >= (3, 10):
from importlib import metadata
Expand Down
5 changes: 2 additions & 3 deletions nornir/core/plugins/runners.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Any, List, Type, Protocol
from typing import Any, List, Protocol, Type

from nornir.core.task import AggregatedResult, Task
from nornir.core.inventory import Host
from nornir.core.plugins.register import PluginRegister

from nornir.core.task import AggregatedResult, Task

RUNNERS_PLUGIN_PATH = "nornir.plugins.runners"

Expand Down
2 changes: 2 additions & 0 deletions nornir/core/processor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import List, Protocol

from typing_extensions import Protocol
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemith It looks like you need to rebase to get the latest changes that I released last night.


from nornir.core.inventory import Host
from nornir.core.task import AggregatedResult, MultiResult, Task

Expand Down
2 changes: 1 addition & 1 deletion nornir/core/state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Set, Optional
from typing import Any, Dict, Optional, Set


class GlobalState(object):
Expand Down
5 changes: 2 additions & 3 deletions nornir/core/task.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logging
import traceback
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union, cast
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union, cast

from nornir.core.exceptions import NornirExecutionError
from nornir.core.exceptions import NornirSubTaskError
from nornir.core.exceptions import NornirExecutionError, NornirSubTaskError

if TYPE_CHECKING:
from nornir.core import Nornir
Expand Down
2 changes: 1 addition & 1 deletion nornir/init_nornir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from nornir.core import Nornir
from nornir.core.configuration import Config
from nornir.core.inventory import Inventory
from nornir.core.plugins.connections import ConnectionPluginRegister
from nornir.core.plugins.inventory import (
InventoryPluginRegister,
TransformFunctionRegister,
)
from nornir.core.plugins.connections import ConnectionPluginRegister
from nornir.core.plugins.runners import RunnerPlugin, RunnersPluginRegister
from nornir.core.state import GlobalState

Expand Down
12 changes: 6 additions & 6 deletions nornir/plugins/inventory/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
import pathlib
from typing import Any, Dict, Type

import ruamel.yaml

from nornir.core.inventory import (
Inventory,
ConnectionOptions,
Defaults,
Group,
Groups,
Host,
Hosts,
Defaults,
ConnectionOptions,
HostOrGroup,
Hosts,
Inventory,
ParentGroups,
)

import ruamel.yaml

logger = logging.getLogger(__name__)


Expand Down
4 changes: 2 additions & 2 deletions nornir/plugins/runners/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List
from concurrent.futures import ThreadPoolExecutor
from typing import List

from nornir.core.task import AggregatedResult, Task
from nornir.core.inventory import Host
from nornir.core.task import AggregatedResult, Task


class SerialRunner:
Expand Down
Loading
Loading