From 7ab248ccb09e30a0764cb4eff17b5313c445b88c Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Fri, 28 Jun 2024 09:25:08 +0200 Subject: [PATCH] Sort slots - Fix RUF023 (#936) --- nornir/core/configuration.py | 10 +++++----- nornir/core/inventory.py | 10 +++++----- pyproject.toml | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/nornir/core/configuration.py b/nornir/core/configuration.py index 85f4e46b..43a5e844 100644 --- a/nornir/core/configuration.py +++ b/nornir/core/configuration.py @@ -68,7 +68,7 @@ def dict(self) -> Dict[str, Any]: class InventoryConfig(object): - __slots__ = "plugin", "options", "transform_function", "transform_function_options" + __slots__ = "options", "plugin", "transform_function", "transform_function_options" class Parameters: plugin = Parameter(typ=str, default="SimpleInventory", envvar="NORNIR_INVENTORY_PLUGIN") @@ -102,7 +102,7 @@ def dict(self) -> Dict[str, Any]: class LoggingConfig(object): - __slots__ = "enabled", "level", "log_file", "format", "to_console", "loggers" + __slots__ = "enabled", "format", "level", "log_file", "loggers", "to_console" class Parameters: enabled = Parameter(default=True, envvar="NORNIR_LOGGING_ENABLED") @@ -195,7 +195,7 @@ def configure(self) -> None: class RunnerConfig(object): - __slots__ = ("plugin", "options") + __slots__ = ("options", "plugin") class Parameters: plugin = Parameter(default="threaded", envvar="NORNIR_RUNNER_PLUGIN") @@ -232,10 +232,10 @@ def dict(self) -> Dict[str, Any]: class Config(object): __slots__ = ( "core", - "runner", - "ssh", "inventory", "logging", + "runner", + "ssh", "user_defined", ) diff --git a/nornir/core/inventory.py b/nornir/core/inventory.py index 524e7b35..d4e1077c 100644 --- a/nornir/core/inventory.py +++ b/nornir/core/inventory.py @@ -21,7 +21,7 @@ class BaseAttributes(object): - __slots__ = ("hostname", "port", "username", "password", "platform") + __slots__ = ("hostname", "password", "platform", "port", "username") def __init__( self, @@ -113,7 +113,7 @@ def add(self, group: "Group") -> None: class InventoryElement(BaseAttributes): - __slots__ = ("groups", "data", "connection_options") + __slots__ = ("connection_options", "data", "groups") def __init__( self, @@ -195,7 +195,7 @@ def extended_groups(self) -> List["Group"]: class Defaults(BaseAttributes): - __slots__ = ("data", "connection_options") + __slots__ = ("connection_options", "data") def __init__( self, @@ -234,7 +234,7 @@ def dict(self) -> Dict[str, Any]: class Host(InventoryElement): - __slots__ = ("name", "connections", "defaults") + __slots__ = ("connections", "defaults", "name") def __init__( self, @@ -577,7 +577,7 @@ def __call__(self, host: Host, **kwargs: Any) -> bool: ... class Inventory(object): - __slots__ = ("hosts", "groups", "defaults") + __slots__ = ("defaults", "groups", "hosts") def __init__( self, diff --git a/pyproject.toml b/pyproject.toml index 52b3cdb9..1f043f2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -161,7 +161,6 @@ ignore = [ "RSE102", # Unnecessary parentheses on raised exception "RUF001", # String contains ambiguous `–` (EN DASH). Did you mean `-` (HYPHEN-MINUS)? "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` - "RUF023", # `__slots__` is not sorted "RUF100", # Unused blanket `noqa` directive "S701", # By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities. "SLF001", # Private member accessed